mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
IndVarSimplify: Address review comments for r217102
No functional change intended, just some cleanups and comments added. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b79ed97962
commit
e35ac41a3a
@ -1644,16 +1644,19 @@ LinearFunctionTestReplace(Loop *L,
|
|||||||
// The BackedgeTaken expression contains the number of times that the
|
// The BackedgeTaken expression contains the number of times that the
|
||||||
// backedge branches to the loop header. This is one less than the
|
// backedge branches to the loop header. This is one less than the
|
||||||
// number of times the loop executes, so use the incremented indvar.
|
// 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 =
|
const auto *IncrementedIndvarSCEV =
|
||||||
cast<SCEVAddRecExpr>(SE->getSCEV(IncrementedIndvar));
|
cast<SCEVAddRecExpr>(SE->getSCEV(IncrementedIndvar));
|
||||||
// It is unsafe to use the incremented indvar if it has a wrapping flag, we
|
// 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
|
// don't want to compare against a poison value. Check the SCEV that
|
||||||
// corresponds to the incremented indvar, the SCEVExpander will only insert
|
// corresponds to the incremented indvar, the SCEVExpander will only insert
|
||||||
// flags in the IR if the SCEV originally had wrapping flags.
|
// flags in the IR if the SCEV originally had wrapping flags.
|
||||||
if (ScalarEvolution::maskFlags(IncrementedIndvarSCEV->getNoWrapFlags(),
|
// FIXME: In theory, SCEV could drop flags even though they exist in IR.
|
||||||
SCEV::FlagNUW | SCEV::FlagNSW) ==
|
// A more robust solution would involve getting a new expression for
|
||||||
SCEV::FlagAnyWrap) {
|
// 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.
|
// 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
|
// This addition may overflow, which is valid as long as the comparison is
|
||||||
// truncated to BackedgeTakenCount->getType().
|
// truncated to BackedgeTakenCount->getType().
|
||||||
|
Loading…
Reference in New Issue
Block a user