[PATCH] D145230: [ScalarEvolution] Apply loop guards against min/max for its arguments
Dmitry Makogon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 3 04:28:44 PST 2023
dmakogon created this revision.
dmakogon added reviewers: mkazantsev, nikic, fhahn, aleksandr.popov.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
dmakogon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This adds following rules for rewriting in `ScalarEvolution::applyLoopGuards`:
- `min(a, b) >(=) c -> a >(=) c && b >(=) c`
- `max(a, b) <(=) c -> a <(=) c && b <(=) c`
This allows us to apply loop guards against min/max calls for its arguments.
For example, imagine there is a loop guard `min(a, b) >= c` and loop IV uses `min(a, zext(b))`.
Previously the guard would give us a rewrite rule `min(a, b) -> max(c, min(a, b))` and it wouldn't allow us to apply it to `min(a, zext(b))`, which is the same as `zext(min(a, b))`.
Now we apply the guards against min/max-s for its arguments and in the above example we would have two rules:
- `a -> max(c, a)` and
- `b -> max(c, b)`.
This way we can apply the rule for `b `in `min(a, zext(b))` and actually make the guard useful.
https://reviews.llvm.org/D145230
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info-rewrite-expressions.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145230.502097.patch
Type: text/x-patch
Size: 26634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230303/c8e07084/attachment.bin>
More information about the llvm-commits
mailing list