Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit ff65de0

Browse files
committed
Merging r259381:
------------------------------------------------------------------------ r259381 | uweigand | 2016-02-01 10:31:19 -0800 (Mon, 01 Feb 2016) | 21 lines [SystemZ] Fix wrong-code generation for certain always-false conditions We've found another bug in the code generation logic conditions for a certain class of always-false conditions, those of the form if ((a & 1) < 0) These only reach the back end when compiling without optimization. The bug was introduced by the choice of using TEST UNDER MASK to implement a check for if ((a & MASK) < VAL) as if ((a & MASK) == 0) where VAL is less than the the lowest bit of MASK. This is correct in all cases except for VAL == 0, in which case the original condition is always false, but the replacement isn't. Fixed by excluding that particular case. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@259940 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 56d368f commit ff65de0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ static unsigned getTestUnderMaskCond(unsigned BitSize, unsigned CCMask,
18491849
if (CCMask == SystemZ::CCMASK_CMP_NE)
18501850
return SystemZ::CCMASK_TM_SOME_1;
18511851
}
1852-
if (EffectivelyUnsigned && CmpVal <= Low) {
1852+
if (EffectivelyUnsigned && CmpVal > 0 && CmpVal <= Low) {
18531853
if (CCMask == SystemZ::CCMASK_CMP_LT)
18541854
return SystemZ::CCMASK_TM_ALL_0;
18551855
if (CCMask == SystemZ::CCMASK_CMP_GE)

test/CodeGen/SystemZ/int-cmp-53.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; This used to incorrectly use a TMLL for an always-false test at -O0.
2+
;
3+
; RUN: llc -O0 < %s -mtriple=s390x-linux-gnu | FileCheck %s
4+
5+
define void @test(i8 *%input, i32 *%result) {
6+
entry:
7+
; CHECK-NOT: tmll
8+
9+
%0 = load i8, i8* %input, align 1
10+
%1 = trunc i8 %0 to i1
11+
%2 = zext i1 %1 to i32
12+
%3 = icmp sge i32 %2, 0
13+
br i1 %3, label %if.then, label %if.else
14+
15+
if.then:
16+
store i32 1, i32* %result, align 4
17+
br label %return
18+
19+
if.else:
20+
store i32 0, i32* %result, align 4
21+
br label %return
22+
23+
return:
24+
ret void
25+
}
26+

0 commit comments

Comments
 (0)