From: Davide Italiano Date: Thu, 8 Dec 2016 22:28:53 +0000 (+0000) Subject: [SCCP] Make sure SCCP and ConstantFolding agree on undef >> a. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a47129de893b3452da0006399603a6ef5620b7c1;p=llvm [SCCP] Make sure SCCP and ConstantFolding agree on undef >> a. 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 --- diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 32f486744f5..2c1364d77cf 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -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: diff --git a/test/Transforms/SCCP/undef-resolve.ll b/test/Transforms/SCCP/undef-resolve.ll index fcfe3f573ea..dd7f1f3dd88 100644 --- a/test/Transforms/SCCP/undef-resolve.ll +++ b/test/Transforms/SCCP/undef-resolve.ll @@ -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 }