[llvm-commits] [llvm] r73598 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll

Eli Friedman eli.friedman at gmail.com
Tue Jun 16 19:57:37 PDT 2009


Author: efriedma
Date: Tue Jun 16 21:57:36 2009
New Revision: 73598

URL: http://llvm.org/viewvc/llvm-project?rev=73598&view=rev
Log:
PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for 
SRem.


Added:
    llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73598&r1=73597&r2=73598&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jun 16 21:57:36 2009
@@ -1336,7 +1336,7 @@
     if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
       APInt RA = Rem->getValue().abs();
       if (RA.isPowerOf2()) {
-        if (DemandedMask.ule(RA))    // srem won't affect demanded bits
+        if (DemandedMask.ult(RA))    // srem won't affect demanded bits
           return I->getOperand(0);
 
         APInt LowBits = RA - 1;

Added: llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll?rev=73598&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll Tue Jun 16 21:57:36 2009
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep srem
+; PR3439
+
+define i32 @a(i32 %x) nounwind {
+entry:
+	%rem = srem i32 %x, 2
+	%and = and i32 %rem, 2
+	ret i32 %and
+}
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep srem
+; PR3439
+
+define i32 @a(i32 %x) nounwind {
+entry:
+	%rem = srem i32 %x, 2
+	%and = and i32 %rem, 2
+	ret i32 %and
+}





More information about the llvm-commits mailing list