fix PR6940: sitofp(undef) folds to 0.0, not undef.
authorChris Lattner <sabre@nondot.org>
Mon, 26 Apr 2010 18:21:23 +0000 (18:21 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Apr 2010 18:21:23 +0000 (18:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102358 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SCCP.cpp
test/Transforms/SCCP/undef-resolve.ll

index 59cdee652dc74656d80b71ea8b06e05ee067ce6f..907ece8fcce97ca3a9982343b67b89bb12a652cc 100644 (file)
@@ -1452,6 +1452,8 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) {
         // After a zero extend, we know the top part is zero.  SExt doesn't have
         // to be handled here, because we don't know whether the top part is 1's
         // or 0's.
+      case Instruction::SIToFP:  // some FP values are not possible, just use 0.
+      case Instruction::UIToFP:  // some FP values are not possible, just use 0.
         markForcedConstant(I, Constant::getNullValue(ITy));
         return true;
       case Instruction::Mul:
index d2f3d0206d7a190656012f3917e1fa1b508c7748..bed561c8e4f24dd039657a4ed81f3332ecc1c7cf 100644 (file)
@@ -1,8 +1,19 @@
 ; RUN: opt %s -sccp -S | FileCheck %s
+
+
+; PR6940
+define double @test1() {
+  %t = sitofp i32 undef to double
+  ret double %t
+; CHECK: @test1
+; CHECK: ret double 0.0
+}
+
+
 ; rdar://7832370
 ; Check that lots of stuff doesn't get turned into undef.
-
-define i32 @main() nounwind readnone ssp {
+define i32 @test2() nounwind readnone ssp {
+; CHECK: @test2
 init:
   br label %control.outer.outer