aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-06-17 02:57:36 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-06-17 02:57:36 +0000
commit579c57231ac1d5fd29760eb98bf6fd76a56cf6b1 (patch)
tree5dfed37e58f5c1e478219374981edd9730493e02
parent4923d3e4643e680b2febc726cd48ee4ffe4c0b2f (diff)
downloadexternal_llvm-579c57231ac1d5fd29760eb98bf6fd76a56cf6b1.zip
external_llvm-579c57231ac1d5fd29760eb98bf6fd76a56cf6b1.tar.gz
external_llvm-579c57231ac1d5fd29760eb98bf6fd76a56cf6b1.tar.bz2
PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for
SRem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73598 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp2
-rw-r--r--test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 8dc8659..170b476 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1336,7 +1336,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
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;
diff --git a/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll b/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
new file mode 100644
index 0000000..230e245
--- /dev/null
+++ b/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
@@ -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
+}