summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index b650971624a..a56a37a618b 100644
--- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -416,10 +416,13 @@ static void processOverflowIntrinsic(WithOverflowInst *WO) {
IRBuilder<> B(WO);
Value *NewOp = B.CreateBinOp(
WO->getBinaryOp(), WO->getLHS(), WO->getRHS(), WO->getName());
- if (WO->isSigned())
- cast<Instruction>(NewOp)->setHasNoSignedWrap();
- else
- cast<Instruction>(NewOp)->setHasNoUnsignedWrap();
+ // Constant-holing could have happened.
+ if (auto *Inst = dyn_cast<Instruction>(NewOp)) {
+ if (WO->isSigned())
+ Inst->setHasNoSignedWrap();
+ else
+ Inst->setHasNoUnsignedWrap();
+ }
Value *NewI = B.CreateInsertValue(UndefValue::get(WO->getType()), NewOp, 0);
NewI = B.CreateInsertValue(NewI, ConstantInt::getFalse(WO->getContext()), 1);
OpenPOWER on IntegriCloud