[SCEVExpander] Only check overflow if it is needed.
authorFlorian Hahn <flo@fhahn.com>
Thu, 6 Jan 2022 21:13:04 +0000 (21:13 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sun, 9 Jan 2022 12:55:41 +0000 (12:55 +0000)
commit7f1bf68d7dd6e4d7d64e7b6b30055d62db3bbe32
tree3a428e0e716c98b1f23c18a16c4e65ccbb017b50
parent1d21667ce2442b171e2449235123c7ece3277084
[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.
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll
llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization.ll
llvm/test/Transforms/LoopVectorize/X86/pr35432.ll
llvm/test/Transforms/LoopVectorize/induction.ll
llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization.ll
llvm/test/Transforms/LoopVectorize/pr30654-phiscev-sext-trunc.ll
llvm/test/Transforms/LoopVersioning/wrapping-pointer-versioning.ll