summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
-rw-r--r--llvm/lib/VMCore/Constants.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 70d43576a73..d71dc2cf710 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -607,7 +607,10 @@ Constant* ConstantVector::get(Constant* const* Vals, unsigned NumVals) {
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
Constant *C = getSDiv(C1, C2);
- cast<SDivOperator>(C)->setIsExact(true);
+ // Set exact attribute, assuming constant folding didn't eliminate the
+ // SDiv.
+ if (SDivOperator *SDiv = dyn_cast<SDivOperator>(C))
+ SDiv->setIsExact(true);
return C;
}
OpenPOWER on IntegriCloud