DAGCombine: Avoid an edge case where it tried to create an i0 type for (x & 0) == 0.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 21 May 2013 08:51:09 +0000 (08:51 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 21 May 2013 08:51:09 +0000 (08:51 +0000)
Fixes PR16083.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182357 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/TargetLowering.cpp
test/CodeGen/X86/shrink-compare.ll

index 36add0351591a7fc1aa5c11669bed0fdea60f987..e8b6c04a48fc167a270b05d7ed19e12264fa5513 100644 (file)
@@ -1162,7 +1162,8 @@ TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
       }
 
       // Make sure we're not losing bits from the constant.
-      if (MinBits < C1.getBitWidth() && MinBits >= C1.getActiveBits()) {
+      if (MinBits > 0 &&
+          MinBits < C1.getBitWidth() && MinBits >= C1.getActiveBits()) {
         EVT MinVT = EVT::getIntegerVT(*DAG.getContext(), MinBits);
         if (isTypeDesirableForOp(ISD::SETCC, MinVT)) {
           // Will get folded away.
index 0c16f86ff13ec57c471d28b473852e84f693f862..83793f000d5952e20f2bf2f8a6d191f54e7b935b 100644 (file)
@@ -50,3 +50,19 @@ if.end:
 ; CHECK: test3:
 ; CHECK: cmpb $-1, %{{dil|cl}}
 }
+
+; PR16083
+define i1 @test4(i64 %a, i32 %b) {
+entry:
+  %tobool = icmp ne i32 %b, 0
+  br i1 %tobool, label %lor.end, label %lor.rhs
+
+lor.rhs:                                          ; preds = %entry
+  %and = and i64 0, %a
+  %tobool1 = icmp ne i64 %and, 0
+  br label %lor.end
+
+lor.end:                                          ; preds = %lor.rhs, %entry
+  %p = phi i1 [ true, %entry ], [ %tobool1, %lor.rhs ]
+  ret i1 %p
+}