nir/trivialize: Maintain divergence information

Because this pass is intended to be run after out-of-SSA and directly
before injesting the NIR into the back-end, it may come after divergence
analysis and needs to preserve the divergence information. Fortunately,
since all we ever do is insert nir_op_mov, this is easy.

Fixes: d313eba94e ("nir: Add pass for trivializing register access")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24153>
(cherry picked from commit f1f05cc7cf)
This commit is contained in:
Faith Ekstrand 2023-07-20 09:22:50 -05:00 committed by Dylan Baker
parent ad9f1802c0
commit 830ea32059
2 changed files with 3 additions and 1 deletions

View file

@ -24054,7 +24054,7 @@
"description": "nir/trivialize: Maintain divergence information",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "d313eba94ef0aebf6ee5217fc128f359e0ce1265",
"notes": null

View file

@ -70,6 +70,7 @@ trivialize_load(nir_intrinsic_instr *load)
nir_builder b = nir_builder_at(nir_after_instr(&load->instr));
nir_ssa_def *copy = nir_mov(&b, &load->dest.ssa);
copy->divergent = load->dest.ssa.divergent;
nir_ssa_def_rewrite_uses_after(&load->dest.ssa, copy, copy->parent_instr);
assert(list_is_singular(&load->dest.ssa.uses));
@ -152,6 +153,7 @@ isolate_store(nir_intrinsic_instr *store)
nir_builder b = nir_builder_at(nir_before_instr(&store->instr));
nir_ssa_def *copy = nir_mov(&b, store->src[0].ssa);
copy->divergent = store->src[0].ssa->divergent;
nir_instr_rewrite_src_ssa(&store->instr, &store->src[0], copy);
}