Don't set the isexact flag if an sdiv operator has been folded into
authorDan Gohman <gohman@apple.com>
Tue, 11 Aug 2009 19:56:00 +0000 (19:56 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 11 Aug 2009 19:56:00 +0000 (19:56 +0000)
something else.

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

lib/VMCore/Constants.cpp

index 70d43576a7375b81f7b2a75b8e5fc3d5d3d0661c..d71dc2cf7100397afee8d736a508f6dfce3dbd58 100644 (file)
@@ -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;
 }