diff options
author | Florian Hahn <flo@fhahn.com> | 2022-01-06 21:13:04 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2022-01-09 12:55:41 +0000 |
commit | 7f1bf68d7dd6e4d7d64e7b6b30055d62db3bbe32 (patch) | |
tree | 3a428e0e716c98b1f23c18a16c4e65ccbb017b50 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 1d21667ce2442b171e2449235123c7ece3277084 (diff) | |
download | llvm-7f1bf68d7dd6e4d7d64e7b6b30055d62db3bbe32.zip llvm-7f1bf68d7dd6e4d7d64e7b6b30055d62db3bbe32.tar.gz llvm-7f1bf68d7dd6e4d7d64e7b6b30055d62db3bbe32.tar.bz2 |
[SCEVExpander] Only check overflow if it is needed.
9345ab3a4550 updated generateOverflowCheck to skip creating checks that
always evaluate to false. This in turn means that we only need to check
for overflows if the result of the multiplication is actually used.
Sink the Or for the overflow check 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 | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index b749847..3b1e160 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -2553,7 +2553,7 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR, // Select the answer based on the sign of Step. EndCheck = Builder.CreateSelect(StepCompare, EndCompareGT, EndCompareLT); } - return EndCheck; + return Builder.CreateOr(EndCheck, OfMul); }; Value *EndCheck = ComputeEndCheck(); @@ -2571,7 +2571,7 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR, EndCheck = Builder.CreateOr(EndCheck, BackedgeCheck); } - return Builder.CreateOr(EndCheck, OfMul); + return EndCheck; } Value *SCEVExpander::expandWrapPredicate(const SCEVWrapPredicate *Pred, |