intel/compiler: Fold constants after distributing source modifiers
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 4 May 2023 07:55:42 +0000 (00:55 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 9 May 2023 07:16:40 +0000 (00:16 -0700)
commitf00143acc3afe4e4009cef007a643ff10ab0eada
tree7886e58ac71d5f5ff1d5b4ed67e158f756404209
parent0c64ff6c2afe4f0a59cf8186dea440fb524e010d
intel/compiler: Fold constants after distributing source modifiers

This can generate things like fneg! of load_const, which is silly.
Fold those away into an actual constant.  Only do so on the scalar
backend because there's a comment above that the vec4 backend doesn't
want any new constants this late, and I'm inclined to believe it.

fossil-db stats show a very minor improvement:

   Totals:
   Instrs: 203091223 -> 203091099 (-0.00%); split: -0.00%, +0.00%
   Cycles: 14410638075 -> 14410577067 (-0.00%); split: -0.00%, +0.00%

   Totals from 20 (0.00% of 665070) affected shaders:
   Instrs: 27067 -> 26943 (-0.46%); split: -0.47%, +0.01%
   Cycles: 2687958 -> 2626950 (-2.27%); split: -2.27%, +0.00%

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22881>
src/intel/compiler/brw_nir.c