treewide: use nir_def_replace sometimes
Two Coccinelle patches here. Didn't catch nearly as much as I would've liked but
it's a start.
Coccinelle patch:
@@
expression intr, repl;
@@
-nir_def_rewrite_uses(&intr->def, repl);
-nir_instr_remove(&intr->instr);
+nir_def_replace(&intr->def, repl);
Coccinelle patch:
@@
identifier intr;
expression instr, repl;
@@
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
...
-nir_def_rewrite_uses(&intr->def, repl);
-nir_instr_remove(instr);
+nir_def_replace(&intr->def, repl);
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Juan A. Suarez Romero <jasuarez@igalia.com> [broadcom]
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> [lima]
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> [etna]
Reviewed-by: Pavel Ondračka <pavel.ondracka@gmail.com> [r300]
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29817>
This commit is contained in:
committed by
Marge Bot
parent
bbdd34b4ad
commit
da752ed7c1
@@ -543,11 +543,8 @@ nir_remove_llvm17_scratch(nir_shader *nir)
|
||||
if (offset == NULL)
|
||||
continue;
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
rebuild_value_from_store(
|
||||
&scratch_stores, &intrin->def,
|
||||
nir_src_as_uint(intrin->src[0])));
|
||||
nir_instr_remove(instr);
|
||||
nir_def_replace(&intrin->def,
|
||||
rebuild_value_from_store(&scratch_stores, &intrin->def, nir_src_as_uint(intrin->src[0])));
|
||||
|
||||
progress = true;
|
||||
}
|
||||
|
||||
@@ -433,9 +433,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir)
|
||||
nir_def_init(&load->instr, &load->def, 1, 32);
|
||||
nir_builder_instr_insert(&b, &load->instr);
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
&load->def);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, &load->def);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -546,8 +544,7 @@ lower_barycentric_per_sample(nir_builder *b,
|
||||
nir_def *centroid =
|
||||
nir_load_barycentric(b, nir_intrinsic_load_barycentric_sample,
|
||||
nir_intrinsic_interp_mode(intrin));
|
||||
nir_def_rewrite_uses(&intrin->def, centroid);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, centroid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1160,9 +1157,7 @@ brw_nir_zero_inputs_instr(struct nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
|
||||
nir_def *zero = nir_imm_zero(b, 1, 32);
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def, zero);
|
||||
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, zero);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -272,8 +272,7 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
|
||||
if (intrinsic->def.bit_size == 64)
|
||||
sysval = nir_u2u64(b, sysval);
|
||||
|
||||
nir_def_rewrite_uses(&intrinsic->def, sysval);
|
||||
nir_instr_remove(&intrinsic->instr);
|
||||
nir_def_replace(&intrinsic->def, sysval);
|
||||
|
||||
state->progress = true;
|
||||
}
|
||||
|
||||
@@ -92,15 +92,11 @@ lower_any_hit_for_intersection(nir_shader *any_hit)
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_ray_t_max:
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
hit_t);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, hit_t);
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_ray_hit_kind:
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
hit_kind);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, hit_kind);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -340,9 +340,7 @@ lower_rt_intrinsics_impl(nir_function_impl *impl,
|
||||
progress = true;
|
||||
|
||||
if (sysval) {
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
sysval);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, sysval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,7 @@ lower_rt_io_derefs(nir_shader *shader)
|
||||
nir_build_deref_cast(&b, call_data_addr,
|
||||
nir_var_function_temp,
|
||||
deref->var->type, 0);
|
||||
nir_def_rewrite_uses(&deref->def,
|
||||
&cast->def);
|
||||
nir_instr_remove(&deref->instr);
|
||||
nir_def_replace(&deref->def, &cast->def);
|
||||
progress = true;
|
||||
}
|
||||
} else if (nir_deref_mode_is(deref, nir_var_ray_hit_attrib)) {
|
||||
@@ -131,9 +129,7 @@ lower_rt_io_derefs(nir_shader *shader)
|
||||
nir_build_deref_cast(&b, hit_attrib_addr,
|
||||
nir_var_function_temp,
|
||||
deref->type, 0);
|
||||
nir_def_rewrite_uses(&deref->def,
|
||||
&cast->def);
|
||||
nir_instr_remove(&deref->instr);
|
||||
nir_def_replace(&deref->def, &cast->def);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
@@ -520,9 +516,7 @@ brw_nir_create_raygen_trampoline(const struct brw_compiler *compiler,
|
||||
b.cursor = nir_before_instr(&intrin->instr);
|
||||
nir_def *global_arg_addr =
|
||||
load_trampoline_param(&b, rt_disp_globals_addr, 1, 64);
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
global_arg_addr);
|
||||
nir_instr_remove(instr);
|
||||
nir_def_replace(&intrin->def, global_arg_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -330,9 +330,7 @@ elk_nir_lower_vs_inputs(nir_shader *nir,
|
||||
nir_def_init(&load->instr, &load->def, 1, 32);
|
||||
nir_builder_instr_insert(&b, &load->instr);
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def,
|
||||
&load->def);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, &load->def);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -451,8 +449,7 @@ lower_barycentric_per_sample(nir_builder *b,
|
||||
nir_def *centroid =
|
||||
nir_load_barycentric(b, nir_intrinsic_load_barycentric_sample,
|
||||
nir_intrinsic_interp_mode(intrin));
|
||||
nir_def_rewrite_uses(&intrin->def, centroid);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, centroid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1035,9 +1032,7 @@ elk_nir_zero_inputs_instr(struct nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
|
||||
nir_def *zero = nir_imm_zero(b, 1, 32);
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def, zero);
|
||||
|
||||
nir_instr_remove(&intrin->instr);
|
||||
nir_def_replace(&intrin->def, zero);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -272,8 +272,7 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
|
||||
if (intrinsic->def.bit_size == 64)
|
||||
sysval = nir_u2u64(b, sysval);
|
||||
|
||||
nir_def_rewrite_uses(&intrinsic->def, sysval);
|
||||
nir_instr_remove(&intrinsic->instr);
|
||||
nir_def_replace(&intrinsic->def, sysval);
|
||||
|
||||
state->progress = true;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,7 @@ split_conversion(nir_builder *b, nir_alu_instr *alu, nir_alu_type src_type,
|
||||
nir_def *src = nir_ssa_for_alu_src(b, alu, 0);
|
||||
nir_def *tmp = nir_type_convert(b, src, src_type, tmp_type, nir_rounding_mode_undef);
|
||||
nir_def *res = nir_type_convert(b, tmp, tmp_type, dst_type, nir_rounding_mode_undef);
|
||||
nir_def_rewrite_uses(&alu->def, res);
|
||||
nir_instr_remove(&alu->instr);
|
||||
nir_def_replace(&alu->def, res);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
Reference in New Issue
Block a user