[llvm-branch-commits] [llvm-branch] r121536 - in /llvm/branches/Apple/whitney: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
Daniel Dunbar
daniel at zuster.org
Fri Dec 10 13:32:11 PST 2010
Author: ddunbar
Date: Fri Dec 10 15:32:11 2010
New Revision: 121536
URL: http://llvm.org/viewvc/llvm-project?rev=121536&view=rev
Log:
Merge r121353:
--
Author: Dan Gohman <gohman at apple.com>
Date: Thu Dec 9 02:52:17 2010 +0000
Really check that the bits that will become zero are actually already zero
before eliminating the operation that zeros them. This fixes rdar://8739316.
Modified:
llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
Modified: llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=121536&r1=121535&r2=121536&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
+++ llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp Fri Dec 10 15:32:11 2010
@@ -155,9 +155,8 @@
// We can always turn lshr(c1)+shl(c2) -> lshr(c3)+and(c4), but it isn't
// profitable unless we know the and'd out bits are already zero.
if (CI->getZExtValue() > NumBits) {
- unsigned LowBits = CI->getZExtValue() - NumBits;
if (MaskedValueIsZero(I->getOperand(0),
- APInt::getLowBitsSet(TypeWidth, LowBits) << NumBits))
+ APInt::getLowBitsSet(TypeWidth, NumBits)))
return true;
}
Modified: llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll?rev=121536&r1=121535&r2=121536&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll (original)
+++ llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Fri Dec 10 15:32:11 2010
@@ -1,6 +1,7 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
-; <rdar://problem/8606771>
+; <rdar://problem/8606771>
+; CHECK: @main
define i32 @main(i32 %argc) nounwind ssp {
entry:
%tmp3151 = trunc i32 %argc to i8
@@ -18,3 +19,26 @@
; CHECK: ret i32
ret i32 %tmp4086
}
+
+; rdar://8739316
+; CHECK: @foo
+define i8 @foo(i8 %arg, i8 %arg1) nounwind {
+bb:
+ %tmp = shl i8 %arg, 7
+ %tmp2 = and i8 %arg1, 84
+ %tmp3 = and i8 %arg1, -118
+ %tmp4 = and i8 %arg1, 33
+ %tmp5 = sub i8 -88, %tmp2
+ %tmp6 = and i8 %tmp5, 84
+ %tmp7 = or i8 %tmp4, %tmp6
+ %tmp8 = xor i8 %tmp, %tmp3
+ %tmp9 = or i8 %tmp7, %tmp8
+ %tmp10 = lshr i8 %tmp8, 7
+ %tmp11 = shl i8 %tmp10, 5
+
+; CHECK: %0 = lshr i8 %tmp8, 2
+; CHECK: %tmp11 = and i8 %0, 32
+
+ %tmp12 = xor i8 %tmp11, %tmp9
+ ret i8 %tmp12
+}
More information about the llvm-branch-commits
mailing list