[all-commits] [llvm/llvm-project] bcda7d: [SCEV] Rename variables in applyLoopGuards (NFC)
Dmitry Makogon via All-commits
all-commits at lists.llvm.org
Mon Mar 13 10:06:43 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bcda7db5e503ea47e738c6f2ebe5bb42270c4ca7
https://github.com/llvm/llvm-project/commit/bcda7db5e503ea47e738c6f2ebe5bb42270c4ca7
Author: Dmitry Makogon <d.makogon at g.nsu.ru>
Date: 2023-03-14 (Tue, 14 Mar 2023)
Changed paths:
M llvm/lib/Analysis/ScalarEvolution.cpp
Log Message:
-----------
[SCEV] Rename variables in applyLoopGuards (NFC)
Commit: b60758374b7ba506ca1d163aaf0afdd566d1a985
https://github.com/llvm/llvm-project/commit/b60758374b7ba506ca1d163aaf0afdd566d1a985
Author: Dmitry Makogon <d.makogon at g.nsu.ru>
Date: 2023-03-14 (Tue, 14 Mar 2023)
Changed paths:
M llvm/lib/Analysis/ScalarEvolution.cpp
M llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info-rewrite-expressions.ll
Log Message:
-----------
[SCEV] Apply loop guards against min/max for its arguments
This replaces several rewriting rules in ScalarEvolution::applyLoopGuards
that are applied to min/max expressions with the equivalent ones but
applied to its arguments.
So previously given we had a loop guard min(a, b) >= c,
the min expression would get rewritten as max(c, min(a, b)).
With such approach, we were unable to apply the rewrite if min operands
were zext for example (min(zext(a), zext(b))), however it's equivalent
to the expression zext(min(a, b)) for which we could apply the rewrite.
Now we'd rewrite the min operands also with these expressions:
a -> max(c, a) and
b -> max(c, b).
and this would allow us to apply the loop guard in this and similar cases:
min(zext(a), zext(b)) would get rewritten as min(zext(max(c, a)), zext(max(c, b)))
instead of just being skipped.
The list of added rules (omitting predicates signedness for simplicity):
1. Guard: min(a, b) >= c
Old rule: min(a, b) -> max(c, min(a, b))
New rules: a -> max(a, c) and b -> max(b, c)
2. Guard: min(a, b) > c
Old rule: min(a, b) -> max(c + 1, min(a, b))
New rules: a -> max(a, c + 1) and b -> max(b, c + 1)
3. Guard: max(a, b) <= c
Old rule: max(a, b) -> min(c, max(a, b))
New rules: a -> min(a, c) and b -> min(b, c)
4. Guard: max(a, b) < c
Old rule: max(a, b) -> min(c - 1, max(a, b))
New rules: a -> min(a, c - 1) and b -> min(b, c - 1)
The old rewrites still hold.
Differential Revision: https://reviews.llvm.org/D145230
Compare: https://github.com/llvm/llvm-project/compare/eae70ccbf975...b60758374b7b
More information about the All-commits
mailing list