Don't try to zExt just to check if an integer constant is zero, it might
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 10 Apr 2012 00:16:22 +0000 (00:16 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 10 Apr 2012 00:16:22 +0000 (00:16 +0000)
not fit in a i64.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/Generic/pr12507.ll [new file with mode: 0644]

index dbc1ca909a2932611526a2569650843e946f4b4b..cf7ce587f3627d64378b41336a959886099fb0aa 100644 (file)
@@ -4431,9 +4431,9 @@ static bool isTruncateOf(SelectionDAG &DAG, SDValue N, SDValue &Op,
 
   ConstantSDNode *COp0 = dyn_cast<ConstantSDNode>(Op0);
   ConstantSDNode *COp1 = dyn_cast<ConstantSDNode>(Op1);
-  if (COp0 && COp0->getZExtValue() == 0)
+  if (COp0 && COp0->isNullValue())
     Op = Op1;
-  else if (COp1 && COp1->getZExtValue() == 0)
+  else if (COp1 && COp1->isNullValue())
     Op = Op0;
   else
     return false;
diff --git a/test/CodeGen/Generic/pr12507.ll b/test/CodeGen/Generic/pr12507.ll
new file mode 100644 (file)
index 0000000..c793358
--- /dev/null
@@ -0,0 +1,18 @@
+; RUN: llc < %s
+
+@c = external global i32, align 4
+
+define void @foo(i160 %x) {
+entry:
+  %cmp.i = icmp ne i160 %x, 340282366920938463463374607431768211456
+  %conv.i = zext i1 %cmp.i to i32
+  %tobool.i = icmp eq i32 %conv.i, 0
+  br i1 %tobool.i, label %if.then.i, label %fn1.exit
+
+if.then.i:
+  store i32 0, i32* @c, align 4
+  br label %fn1.exit
+
+fn1.exit:
+  ret void
+}