[SCCP] Make sure SCCP and ConstantFolding agree on undef >> a.
authorDavide Italiano <davide@freebsd.org>
Thu, 8 Dec 2016 22:28:53 +0000 (22:28 +0000)
committerDavide Italiano <davide@freebsd.org>
Thu, 8 Dec 2016 22:28:53 +0000 (22:28 +0000)
Currently SCCP folds the value to -1, while ConstantProp folds to
0. This changes SCCP to do what ConstantFolding does.

llvm-svn: 289147

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

index 32f4867..2c1364d 100644 (file)
@@ -1396,8 +1396,8 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) {
               break;
         }
 
-        // undef >>a X -> all ones
-        markForcedConstant(&I, Constant::getAllOnesValue(ITy));
+        // undef >>a X -> 0
+        markForcedConstant(&I, Constant::getNullValue(ITy));
         return true;
       case Instruction::LShr:
       case Instruction::Shl:
index fcfe3f5..dd7f1f3 100644 (file)
@@ -135,7 +135,7 @@ define i32 @test6() {
   %t = ashr i32 undef, 31
   ret i32 %t
 ; CHECK-LABEL: @test6(
-; CHECK: ret i32 -1
+; CHECK: ret i32 0
 }
 
 ; Make sure lshr produces a possible value
@@ -178,5 +178,5 @@ entry:
   %shr4 = ashr i32 undef, zext (i1 icmp eq (i32* bitcast (i32 (i1)* @test11 to i32*), i32* @GV) to i32)
   ret i32 %shr4
 ; CHECK-LABEL: @test11(
-; CHECK: ret i32 -1
+; CHECK: ret i32 0
 }