diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 3827ce40a44..5b3b265ab00 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -522,9 +522,10 @@ optimizations.extend([ (('ishl', ('iadd', ('imul', a, '#b'), '#c'), '#d'), ('iadd', ('imul', a, ('ishl', b, d)), ('ishl', c, d))), - # (a * #b) << #c - # a * (#b << #c) + # (a * #b) << #c => a * (#b << #c) (('ishl', ('imul', a, '#b'), '#c'), ('imul', a, ('ishl', b, c))), + # (a << #b) * #c => a * (#c << #b) + (('imul', ('ishl', a, '#b'), '#c'), ('imul', a, ('ishl', c, b))), ]) # Care must be taken here. Shifts in NIR uses only the lower log2(bitsize)