[PATCH] D129643: [SCEV] Use context to strengthen flags of BinOps
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 07:31:09 PDT 2022
mkazantsev created this revision.
mkazantsev added reviewers: nikic, lebedev.ri, skatkov, reames.
Herald added subscribers: javed.absar, zzheng, hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Sometimes SCEV cannot infer nuw/nsw from something as simple as
len in [0, MAX_INT]
...
iv = phi(0, iv.next)
guard(iv <s len)
guard(iv <u len)
iv.next = iv + 1
just because flag strenthening only relies on definition and does not use local facts.
This patch adds support for the simplest case: inference of flags of `add(x, constant)`
if we can contextually prove that `x <= max_int - constant`.
In case if it has negative CT impact, there is an option to disable this logic. I woudln't
expect that though.
https://reviews.llvm.org/D129643
Files:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll
llvm/test/Transforms/IndVarSimplify/X86/iv-widen.ll
llvm/test/Transforms/IndVarSimplify/X86/pr35406.ll
llvm/test/Transforms/IndVarSimplify/bbi-63564.ll
llvm/test/Transforms/IndVarSimplify/cycled_phis.ll
llvm/test/Transforms/IndVarSimplify/eliminate-comparison.ll
llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll
llvm/test/Transforms/IndVarSimplify/loop-predication.ll
llvm/test/Transforms/IndVarSimplify/trivial-guard.ll
llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129643.444251.patch
Type: text/x-patch
Size: 19278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220713/13bb13c1/attachment.bin>
More information about the llvm-commits
mailing list