diff options
Diffstat (limited to 'src/compiler/nir/nir_deref.c')
-rw-r--r-- | src/compiler/nir/nir_deref.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index f1e6eee7745..90bb9a0dc3c 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -601,6 +601,8 @@ rematerialize_deref_src(nir_src *src, void *_state) * used. After this pass has been run, every use of a deref will be of a * deref in the same block as the use. Also, all unused derefs will be * deleted as a side-effect. + * + * Derefs used as sources of phi instructions are not rematerialized. */ bool nir_rematerialize_derefs_in_use_blocks_impl(nir_function_impl *impl) @@ -620,6 +622,12 @@ nir_rematerialize_derefs_in_use_blocks_impl(nir_function_impl *impl) nir_deref_instr_remove_if_unused(nir_instr_as_deref(instr))) continue; + /* If a deref is used in a phi, we can't rematerialize it, as the new + * derefs would appear before the phi, which is not valid. + */ + if (instr->type == nir_instr_type_phi) + continue; + state.builder.cursor = nir_before_instr(instr); nir_foreach_src(instr, rematerialize_deref_src, &state); } |