agx: const fold after discard lowering

to avoid silly xor op with an unconditional discard.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26963>
This commit is contained in:
Alyssa Rosenzweig 2023-12-31 18:50:44 -04:00
parent 1006e27627
commit 4071baf1b3

View file

@ -3112,14 +3112,13 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
if (nir->info.stage == MESA_SHADER_FRAGMENT && key->fs.nr_samples) {
if (agx_nir_lower_sample_mask(nir, key->fs.nr_samples)) {
/* Clean up ixor(bcsel) patterns created from sample mask lowering.
* If this succeeds, we'll have expressions to constant fold to get the
* benefit. We need to rescalarize after folding constants.
* Also constant fold to get the benefit. We need to rescalarize after
* folding constants.
*/
if (agx_nir_opt_ixor_bcsel(nir)) {
NIR_PASS_V(nir, nir_opt_constant_folding);
NIR_PASS_V(nir, nir_lower_load_const_to_scalar);
NIR_PASS_V(nir, nir_opt_dce);
}
NIR_PASS_V(nir, agx_nir_opt_ixor_bcsel);
NIR_PASS_V(nir, nir_opt_constant_folding);
NIR_PASS_V(nir, nir_lower_load_const_to_scalar);
NIR_PASS_V(nir, nir_opt_dce);
}
}