Just mark the sign bit as known zero, rather than any other irrelevant bits
known zero in the LHS. Fixes PR12541.
llvm-svn: 155818
diff --git a/llvm/test/Transforms/InstCombine/2012-04-30-SRem.ll b/llvm/test/Transforms/InstCombine/2012-04-30-SRem.ll
new file mode 100644
index 0000000..a285d5a
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/2012-04-30-SRem.ll
@@ -0,0 +1,12 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+; PR12541
+
+define i32 @foo(i32 %x) {
+ %y = xor i32 %x, 3
+ %z = srem i32 1656690544, %y
+ %sext = shl i32 %z, 24
+ %s = ashr exact i32 %sext, 24
+ ret i32 %s
+; CHECK-NOT: and
+; The shifts were wrongly being turned into an and with 112
+}