nir: replace undef only used by ALU opcodes with 0 or NaN
authorMarek Olšák <marek.olsak@amd.com>
Thu, 6 Jul 2023 08:52:16 +0000 (04:52 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Sep 2023 03:24:16 +0000 (03:24 +0000)
commit861d274453c016e04da0997ee75d1c4ab26e95f0
tree5488647bef336c070703b0f9c36b9e0e5a40b655
parent2b128c570b9848d9f9b8621278b2365ff690f170
nir: replace undef only used by ALU opcodes with 0 or NaN

If undef is consumed by an FP opcode, replace it with NaN to eliminate
that opcode, else replace it with 0, but there are exceptions, such as
when undef is used by stores or phis, it's not touched.

This also contains workarounds for viewperf shaders.

radeonsi:
TOTALS FROM AFFECTED SHADERS (1987/58918)
  Code Size: 5158692 -> 5143796 (-0.29 %) bytes
  Max Waves: 22456 -> 22513 (0.25 %)
  Outputs: 3726 -> 3726 (0.00 %)
  Patch Outputs: 0 -> 0 (0.00 %)

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24059>
src/compiler/nir/nir_opt_undef.c