LSR, correct fix for rdar://9786536. Silly casting bug.
authorAndrew Trick <atrick@apple.com>
Thu, 21 Jul 2011 01:45:54 +0000 (01:45 +0000)
committerAndrew Trick <atrick@apple.com>
Thu, 21 Jul 2011 01:45:54 +0000 (01:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135654 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll

index 92864817aee28d8ba42dbaf3f2af9c5489e355db..e79071535bd70f9ab89e474a1aa701291ddc1c1c 100644 (file)
@@ -1480,8 +1480,8 @@ void LSRInstance::OptimizeShadowIV() {
     ConstantInt *Init = dyn_cast<ConstantInt>(PH->getIncomingValue(Entry));
     if (!Init) continue;
     Constant *NewInit = ConstantFP::get(DestTy, IsSigned ?
-                                        Init->getSExtValue() :
-                                        Init->getZExtValue());
+                                        (double)Init->getSExtValue() :
+                                        (double)Init->getZExtValue());
 
     BinaryOperator *Incr =
       dyn_cast<BinaryOperator>(PH->getIncomingValue(Latch));
index aecb06cfb87de4dbd3986a345b6da600ebe902fa..5d9ed64ef4223372012c93fdbd7ae1df7ce81a03 100644 (file)
@@ -25,7 +25,7 @@ for.end:
 
 ; Now check that the computed double constant is correct.
 ; CHECK: @doubleIV
-; CHECK: phi double [ 0x43F0000000000000, %entry ]
+; CHECK: phi double [ -3.900000e+01, %entry ]
 ; CHECK: br
 define void @doubleIV() nounwind {
 entry: