diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 75414ef3864..c75c948329c 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1416,6 +1416,14 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // X >>a undef -> undef. if (Op1LV.isUndefined()) break; + // Shifting by the bitwidth or more is undefined. + if (Op1LV.isConstant()) { + auto *ShiftAmt = Op1LV.getConstantInt(); + if (ShiftAmt->getLimitedValue() >= + ShiftAmt->getType()->getScalarSizeInBits()) + break; + } + // undef >>a X -> all ones markForcedConstant(&I, Constant::getAllOnesValue(ITy)); return true; @@ -1425,6 +1433,14 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // X >> undef -> undef. if (Op1LV.isUndefined()) break; + // Shifting by the bitwidth or more is undefined. + if (Op1LV.isConstant()) { + auto *ShiftAmt = Op1LV.getConstantInt(); + if (ShiftAmt->getLimitedValue() >= + ShiftAmt->getType()->getScalarSizeInBits()) + break; + } + // undef << X -> 0 // undef >> X -> 0 markForcedConstant(&I, Constant::getNullValue(ITy)); |