diff options
author | Florian Hahn <flo@fhahn.com> | 2022-01-10 11:31:26 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2022-01-10 11:31:27 +0000 |
commit | aecad5828ee7c3cd6d7dea5ea9f552251e4362df (patch) | |
tree | 39885f5ab58aa842374c0fb7d81b9e74697ef99f /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 3a094d8b272c15aa329db92d85c6d483004b4f6e (diff) | |
download | llvm-aecad5828ee7c3cd6d7dea5ea9f552251e4362df.zip llvm-aecad5828ee7c3cd6d7dea5ea9f552251e4362df.tar.gz llvm-aecad5828ee7c3cd6d7dea5ea9f552251e4362df.tar.bz2 |
[SCEVExpander] Only create trunc when needed.
9345ab3a4550 updated generateOverflowCheck to skip creating checks that
always evaluate to false. This in turn means that we only need to
create TruncTripCount if it is actually used.
Sink the TruncTripCount creating into ComputeEndCheck, so it is only
created when there's an actual check.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 70d284f..68edfe0 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -2490,9 +2490,6 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR, Value *StepCompare = Builder.CreateICmp(ICmpInst::ICMP_SLT, StepValue, Zero); Value *AbsStep = Builder.CreateSelect(StepCompare, NegStepValue, StepValue); - // Get the backedge taken count and truncate or extended to the AR type. - Value *TruncTripCount = Builder.CreateZExtOrTrunc(TripCountVal, Ty); - // Compute |Step| * Backedge // Compute: // 1. Start + |Step| * Backedge < Start @@ -2506,6 +2503,9 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR, if (!Signed && Start->isZero() && SE.isKnownPositive(Step)) return ConstantInt::getFalse(Loc->getContext()); + // Get the backedge taken count and truncate or extended to the AR type. + Value *TruncTripCount = Builder.CreateZExtOrTrunc(TripCountVal, Ty); + Value *MulV, *OfMul; if (Step->isOne()) { // Special-case Step of one. Potentially-costly `umul_with_overflow` isn't |