summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-09-04 00:23:13 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-09-04 00:23:13 +0000
commit13046deef35374954dcbd164ba2f56f3166648e6 (patch)
treeaf8a6e1e10c871506b6e7225e3f1a8489606c1bd /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parent54e0614efdbbbe3fb58f15fb3ccf51a591afb5d2 (diff)
downloadbcm5719-llvm-13046deef35374954dcbd164ba2f56f3166648e6.tar.gz
bcm5719-llvm-13046deef35374954dcbd164ba2f56f3166648e6.zip
IndVarSimplify: Address review comments for r217102
No functional change intended, just some cleanups and comments added. llvm-svn: 217115
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index a5f0dae87ea..27e5ec8cf40 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1644,16 +1644,19 @@ LinearFunctionTestReplace(Loop *L,
// The BackedgeTaken expression contains the number of times that the
// backedge branches to the loop header. This is one less than the
// number of times the loop executes, so use the incremented indvar.
- llvm::Value *IncrementedIndvar = IndVar->getIncomingValueForBlock(L->getExitingBlock());
+ llvm::Value *IncrementedIndvar =
+ IndVar->getIncomingValueForBlock(L->getExitingBlock());
const auto *IncrementedIndvarSCEV =
cast<SCEVAddRecExpr>(SE->getSCEV(IncrementedIndvar));
// It is unsafe to use the incremented indvar if it has a wrapping flag, we
// don't want to compare against a poison value. Check the SCEV that
// corresponds to the incremented indvar, the SCEVExpander will only insert
// flags in the IR if the SCEV originally had wrapping flags.
- if (ScalarEvolution::maskFlags(IncrementedIndvarSCEV->getNoWrapFlags(),
- SCEV::FlagNUW | SCEV::FlagNSW) ==
- SCEV::FlagAnyWrap) {
+ // FIXME: In theory, SCEV could drop flags even though they exist in IR.
+ // A more robust solution would involve getting a new expression for
+ // CmpIndVar by applying non-NSW/NUW AddExprs.
+ if (!ScalarEvolution::maskFlags(IncrementedIndvarSCEV->getNoWrapFlags(),
+ SCEV::FlagNUW | SCEV::FlagNSW)) {
// Add one to the "backedge-taken" count to get the trip count.
// This addition may overflow, which is valid as long as the comparison is
// truncated to BackedgeTakenCount->getType().
OpenPOWER on IntegriCloud