[llvm-branch-commits] [llvm-branch] r118519 - 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
Tue Nov 9 09:27:54 PST 2010


Author: ddunbar
Date: Tue Nov  9 11:27:54 2010
New Revision: 118519

URL: http://llvm.org/viewvc/llvm-project?rev=118519&view=rev
Log:
Merge r117953:
--
Author: Owen Anderson <owen at apple.com>
Date:   Mon Nov 1 21:08:20 2010 +0000

    When folding away a (shl (shr)) pair, we need to check that the bits that will BECOME the low
    bits are zero, not that the current low bits are zero.  Fixes <rdar://problem/8606771>.

Added:
    llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
Modified:
    llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp

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=118519&r1=118518&r2=118519&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
+++ llvm/branches/Apple/whitney/lib/Transforms/InstCombine/InstCombineShifts.cpp Tue Nov  9 11:27:54 2010
@@ -157,7 +157,7 @@
     if (CI->getZExtValue() > NumBits) {
       unsigned LowBits = CI->getZExtValue() - NumBits;
       if (MaskedValueIsZero(I->getOperand(0),
-                            APInt::getLowBitsSet(TypeWidth, LowBits)))
+                          APInt::getLowBitsSet(TypeWidth, LowBits) << NumBits))
         return true;
     }
       

Added: 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=118519&view=auto
==============================================================================
--- llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll (added)
+++ llvm/branches/Apple/whitney/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Tue Nov  9 11:27:54 2010
@@ -0,0 +1,20 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+; <rdar://problem/8606771>
+
+define i32 @main(i32 %argc) nounwind ssp {
+entry:
+  %tmp3151 = trunc i32 %argc to i8
+  %tmp3161 = or i8 %tmp3151, -17
+  %tmp3162 = and i8 %tmp3151, 122
+  %tmp3163 = xor i8 %tmp3162, -17
+  %tmp4114 = shl i8 %tmp3163, 6
+  %tmp4115 = xor i8 %tmp4114, %tmp3163
+  %tmp4120 = xor i8 %tmp3161, %tmp4115
+; CHECK: lshr i8 %tmp4115, 1
+; CHECK-NOT: shl i8 %tmp4126, 6
+  %tmp4126 = lshr i8 %tmp4120, 7
+  %tmp4127 = mul i8 %tmp4126, 64
+  %tmp4086 = zext i8 %tmp4127 to i32
+; CHECK: ret i32
+  ret i32 %tmp4086
+}





More information about the llvm-branch-commits mailing list