]> granicus.if.org Git - llvm/commitdiff
[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.

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

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

index 32f486744f5fc042e279cacc8da930e6a4ed3df9..2c1364d77cfc7fb79e6ace00da0ceb79d4998b33 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 fcfe3f573ea2fd7b45dc042815c59b0b416388b6..dd7f1f3dd880133762000c1c5fb8efea1005cc07 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
 }