[llvm] r182038 - DAGCombine: Also shrink eq compares where the constant is exactly as large as the smaller type.
Benjamin Kramer
benny.kra at googlemail.com
Thu May 16 11:47:58 PDT 2013
Author: d0k
Date: Thu May 16 13:47:58 2013
New Revision: 182038
URL: http://llvm.org/viewvc/llvm-project?rev=182038&view=rev
Log:
DAGCombine: Also shrink eq compares where the constant is exactly as large as the smaller type.
if ((x & 255) == 255)
before: movzbl %al, %eax
cmpl $255, %eax
after: cmpb $-1, %al
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/trunk/test/CodeGen/X86/shrink-compare.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=182038&r1=182037&r2=182038&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Thu May 16 13:47:58 2013
@@ -1160,7 +1160,7 @@ TargetLowering::SimplifySetCC(EVT VT, SD
}
// Make sure we're not losing bits from the constant.
- if (MinBits < C1.getBitWidth() && MinBits > C1.getActiveBits()) {
+ if (MinBits < C1.getBitWidth() && MinBits >= C1.getActiveBits()) {
EVT MinVT = EVT::getIntegerVT(*DAG.getContext(), MinBits);
if (isTypeDesirableForOp(ISD::SETCC, MinVT)) {
// Will get folded away.
Modified: llvm/trunk/test/CodeGen/X86/shrink-compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/shrink-compare.ll?rev=182038&r1=182037&r2=182038&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/shrink-compare.ll (original)
+++ llvm/trunk/test/CodeGen/X86/shrink-compare.ll Thu May 16 13:47:58 2013
@@ -34,3 +34,19 @@ if.end:
; CHECK: test2:
; CHECK: cmpb $47, %{{dil|cl}}
}
+
+define void @test3(i32 %X) nounwind {
+entry:
+ %and = and i32 %X, 255
+ %cmp = icmp eq i32 %and, 255
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ tail call void @bar() nounwind
+ br label %if.end
+
+if.end:
+ ret void
+; CHECK: test3:
+; CHECK: cmpb $-1, %{{dil|cl}}
+}
More information about the llvm-commits
mailing list