nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_instr *resume_instr = find_resume_instr(impl, call_idx);
+ /* Deref chains contain metadata information that is needed by other passes
+ * after this one. If we don't rematerialize the derefs in the blocks where
+ * they're used here, the following lowerings will insert phis which can
+ * prevent other passes from chasing deref chains.
+ */
+ nir_rematerialize_derefs_in_use_blocks_impl(impl);
+
if (duplicate_loop_bodies(impl, resume_instr)) {
nir_validate_shader(shader, "after duplicate_loop_bodies in "
"nir_lower_shader_calls");