mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 06:40:08 +01:00
nir: Add a few more algebraic optimizations to help address calculation.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9201>
This commit is contained in:
parent
9f9b0f583b
commit
132171dc4e
1 changed files with 7 additions and 1 deletions
|
|
@ -340,9 +340,15 @@ optimizations.extend([
|
|||
# instruction or a constant offset field for in load / store instructions.
|
||||
(('ishl', ('iadd', a, '#b'), '#c'), ('iadd', ('ishl', a, c), ('ishl', b, c))),
|
||||
|
||||
# (a + #b) * #c
|
||||
# (a + #b) * #c => (a * #c) + (#b * #c)
|
||||
(('imul', ('iadd(is_used_once)', a, '#b'), '#c'), ('iadd', ('imul', a, c), ('imul', b, c))),
|
||||
|
||||
# ((a + #b) + c) * #d => ((a + c) * #d) + (#b * #d)
|
||||
(('imul', ('iadd(is_used_once)', ('iadd(is_used_once)', a, '#b'), c), '#d'),
|
||||
('iadd', ('imul', ('iadd', a, c), d), ('imul', b, d))),
|
||||
(('ishl', ('iadd(is_used_once)', ('iadd(is_used_once)', a, '#b'), c), '#d'),
|
||||
('iadd', ('ishl', ('iadd', a, c), d), ('ishl', b, d))),
|
||||
|
||||
# Comparison simplifications
|
||||
(('~inot', ('flt', a, b)), ('fge', a, b)),
|
||||
(('~inot', ('fge', a, b)), ('flt', a, b)),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue