[llvm-commits] [llvm] r156600 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/cast.ll
Eli Friedman
eli.friedman at gmail.com
Thu May 10 18:32:59 PDT 2012
Author: efriedma
Date: Thu May 10 20:32:59 2012
New Revision: 156600
URL: http://llvm.org/viewvc/llvm-project?rev=156600&view=rev
Log:
Fix a minor logic mistake transforming compares in instcombine. PR12514.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/cast.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=156600&r1=156599&r2=156600&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu May 10 20:32:59 2012
@@ -1035,7 +1035,7 @@
if ((KnownZero|KnownOne).countLeadingOnes() >= SrcBits-DstBits) {
// Pull in the high bits from known-ones set.
APInt NewRHS = RHS->getValue().zext(SrcBits);
- NewRHS |= KnownOne;
+ NewRHS |= KnownOne & APInt::getHighBitsSet(SrcBits, SrcBits-DstBits);
return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
ConstantInt::get(ICI.getContext(), NewRHS));
}
Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=156600&r1=156599&r2=156600&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cast.ll Thu May 10 20:32:59 2012
@@ -679,3 +679,18 @@
; CHECK: @test_mmx_const
; CHECK-NOT: x86_mmx
}
+
+; PR12514
+define i1 @test67(i1 %a, i32 %b) {
+ %tmp2 = zext i1 %a to i32
+ %conv6 = xor i32 %tmp2, 1
+ %and = and i32 %b, %conv6
+ %sext = shl nuw nsw i32 %and, 24
+ %neg.i = xor i32 %sext, -16777216
+ %conv.i.i = ashr exact i32 %neg.i, 24
+ %trunc = trunc i32 %conv.i.i to i8
+ %tobool.i = icmp eq i8 %trunc, 0
+ ret i1 %tobool.i
+; CHECK: @test67
+; CHECK: ret i1 false
+}
More information about the llvm-commits
mailing list