From: Dan Gohman Date: Fri, 9 Oct 2009 16:35:06 +0000 (+0000) Subject: Revert r83606 and add comments explaining why it isn't safe. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7a721956f886d465f920d06bebb64c0f0b328c39;p=oota-llvm.git Revert r83606 and add comments explaining why it isn't safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83649 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index bdf31f9a706..62f3aa1dcae 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2951,20 +2951,18 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { Operator *U = cast(V); switch (Opcode) { - case Instruction::Add: { - AddOperator *A = cast(U); + case Instruction::Add: + // Don't transfer the NSW and NUW bits from the Add instruction to the + // Add expression, because the Instruction may be guarded by control + // flow and the no-overflow bits may not be valid for the expression in + // any context. return getAddExpr(getSCEV(U->getOperand(0)), - getSCEV(U->getOperand(1)), - A->hasNoUnsignedWrap(), - A->hasNoSignedWrap()); - } - case Instruction::Mul: { - MulOperator *M = cast(U); + getSCEV(U->getOperand(1))); + case Instruction::Mul: + // Don't transfer the NSW and NUW bits from the Mul instruction to the + // Mul expression, as with Add. return getMulExpr(getSCEV(U->getOperand(0)), - getSCEV(U->getOperand(1)), - M->hasNoUnsignedWrap(), - M->hasNoSignedWrap()); - } + getSCEV(U->getOperand(1))); case Instruction::UDiv: return getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1)));