Remove a bunch of old SCEVExpander FIXME's for preserving NoWrap.

The great thing about the SCEVAddRec No-Wrap flag (unlike nsw/nuw) is
that is can be preserved while normalizing (reassociating and
factoring).

The bad thing is that is can't be tranfered back to IR, which is one
of the reasons I don't like the concept of SCEVExpander.

Sorry, I can't think of a direct way to test this, which is why these
were FIXMEs for so long. I just think it's a good time to finally
clean it up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2013-07-14 03:10:08 +00:00
parent 409443b1c6
commit 6f71dd765a

View File

@ -294,8 +294,8 @@ static bool FactorOutConstant(const SCEV *&S,
const SCEV *Start = A->getStart(); const SCEV *Start = A->getStart();
if (!FactorOutConstant(Start, Remainder, Factor, SE, TD)) if (!FactorOutConstant(Start, Remainder, Factor, SE, TD))
return false; return false;
// FIXME: can use A->getNoWrapFlags(FlagNW) S = SE.getAddRecExpr(Start, Step, A->getLoop(),
S = SE.getAddRecExpr(Start, Step, A->getLoop(), SCEV::FlagAnyWrap); A->getNoWrapFlags(SCEV::FlagNW));
return true; return true;
} }
@ -348,8 +348,7 @@ static void SplitAddRecs(SmallVectorImpl<const SCEV *> &Ops,
AddRecs.push_back(SE.getAddRecExpr(Zero, AddRecs.push_back(SE.getAddRecExpr(Zero,
A->getStepRecurrence(SE), A->getStepRecurrence(SE),
A->getLoop(), A->getLoop(),
// FIXME: A->getNoWrapFlags(FlagNW) A->getNoWrapFlags(SCEV::FlagNW)));
SCEV::FlagAnyWrap));
if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Start)) { if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Start)) {
Ops[i] = Zero; Ops[i] = Zero;
Ops.append(Add->op_begin(), Add->op_end()); Ops.append(Add->op_begin(), Add->op_end());
@ -846,8 +845,7 @@ static void ExposePointerBase(const SCEV *&Base, const SCEV *&Rest,
SE.getAddRecExpr(SE.getConstant(A->getType(), 0), SE.getAddRecExpr(SE.getConstant(A->getType(), 0),
A->getStepRecurrence(SE), A->getStepRecurrence(SE),
A->getLoop(), A->getLoop(),
// FIXME: A->getNoWrapFlags(FlagNW) A->getNoWrapFlags(SCEV::FlagNW)));
SCEV::FlagAnyWrap));
} }
if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(Base)) { if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(Base)) {
Base = A->getOperand(A->getNumOperands()-1); Base = A->getOperand(A->getNumOperands()-1);
@ -1185,8 +1183,7 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) {
Normalized = cast<SCEVAddRecExpr>( Normalized = cast<SCEVAddRecExpr>(
SE.getAddRecExpr(Start, Normalized->getStepRecurrence(SE), SE.getAddRecExpr(Start, Normalized->getStepRecurrence(SE),
Normalized->getLoop(), Normalized->getLoop(),
// FIXME: Normalized->getNoWrapFlags(FlagNW) Normalized->getNoWrapFlags(SCEV::FlagNW)));
SCEV::FlagAnyWrap));
} }
// Strip off any non-loop-dominating component from the addrec step. // Strip off any non-loop-dominating component from the addrec step.
@ -1196,11 +1193,9 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) {
PostLoopScale = Step; PostLoopScale = Step;
Step = SE.getConstant(Normalized->getType(), 1); Step = SE.getConstant(Normalized->getType(), 1);
Normalized = Normalized =
cast<SCEVAddRecExpr>(SE.getAddRecExpr(Start, Step, cast<SCEVAddRecExpr>(SE.getAddRecExpr(
Normalized->getLoop(), Start, Step, Normalized->getLoop(),
// FIXME: Normalized Normalized->getNoWrapFlags(SCEV::FlagNW)));
// ->getNoWrapFlags(FlagNW)
SCEV::FlagAnyWrap));
} }
// Expand the core addrec. If we need post-loop scaling, force it to // Expand the core addrec. If we need post-loop scaling, force it to
@ -1293,8 +1288,7 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
for (unsigned i = 0, e = S->getNumOperands(); i != e; ++i) for (unsigned i = 0, e = S->getNumOperands(); i != e; ++i)
NewOps[i] = SE.getAnyExtendExpr(S->op_begin()[i], CanonicalIV->getType()); NewOps[i] = SE.getAnyExtendExpr(S->op_begin()[i], CanonicalIV->getType());
Value *V = expand(SE.getAddRecExpr(NewOps, S->getLoop(), Value *V = expand(SE.getAddRecExpr(NewOps, S->getLoop(),
// FIXME: S->getNoWrapFlags(FlagNW) S->getNoWrapFlags(SCEV::FlagNW)));
SCEV::FlagAnyWrap));
BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint(); BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
BasicBlock::iterator NewInsertPt = BasicBlock::iterator NewInsertPt =
@ -1312,8 +1306,8 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
if (!S->getStart()->isZero()) { if (!S->getStart()->isZero()) {
SmallVector<const SCEV *, 4> NewOps(S->op_begin(), S->op_end()); SmallVector<const SCEV *, 4> NewOps(S->op_begin(), S->op_end());
NewOps[0] = SE.getConstant(Ty, 0); NewOps[0] = SE.getConstant(Ty, 0);
// FIXME: can use S->getNoWrapFlags() const SCEV *Rest = SE.getAddRecExpr(NewOps, L,
const SCEV *Rest = SE.getAddRecExpr(NewOps, L, SCEV::FlagAnyWrap); S->getNoWrapFlags(SCEV::FlagNW));
// Turn things like ptrtoint+arithmetic+inttoptr into GEP. See the // Turn things like ptrtoint+arithmetic+inttoptr into GEP. See the
// comments on expandAddToGEP for details. // comments on expandAddToGEP for details.