[llvm-commits] [llvm] r161452 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/2008-11-08-FCmp.ll
Bob Wilson
bob.wilson at apple.com
Tue Aug 7 15:35:16 PDT 2012
Author: bwilson
Date: Tue Aug 7 17:35:16 2012
New Revision: 161452
URL: http://llvm.org/viewvc/llvm-project?rev=161452&view=rev
Log:
Fix a serious typo in InstCombine's optimization of comparisons.
An unsigned value converted to floating-point will always be greater than
a negative constant. Unfortunately InstCombine reversed the check so that
unsigned values were being optimized to always be greater than all positive
floating-point constants. <rdar://problem/12029145>
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/2008-11-08-FCmp.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=161452&r1=161451&r2=161452&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Aug 7 17:35:16 2012
@@ -2824,7 +2824,7 @@
case ICmpInst::ICMP_UGE:
// (float)int >= -4.4 --> true
// (float)int >= 4.4 --> int > 4
- if (!RHS.isNegative())
+ if (RHS.isNegative())
return ReplaceInstUsesWith(I, ConstantInt::getTrue(I.getContext()));
Pred = ICmpInst::ICMP_UGT;
break;
Modified: llvm/trunk/test/Transforms/InstCombine/2008-11-08-FCmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-11-08-FCmp.ll?rev=161452&r1=161451&r2=161452&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-11-08-FCmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/2008-11-08-FCmp.ll Tue Aug 7 17:35:16 2012
@@ -45,3 +45,12 @@
ret i1 %2
; CHECK: ret i1 false
}
+
+; Check that optimizing unsigned >= comparisons correctly distinguishes
+; positive and negative constants. <rdar://problem/12029145>
+define i1 @test7(i32 %val) {
+ %1 = uitofp i32 %val to double
+ %2 = fcmp oge double %1, 3.200000e+00
+ ret i1 %2
+; CHECK: icmp ugt i32 %val, 3
+}
More information about the llvm-commits
mailing list