mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 23:30:10 +01:00
freedreno/ir3: Call nir_opt_find_array_copies().
gfxbench vk-5-normal has a shader that sampels into a texels[] array at the top, then in a loop calls a GLSL function passing texels[] in by value. This resulted in a copy to a temp inside the loop, which got lowered to scratch stores since it was pretty big. By doing find_array_copies(), we notice that it's equivalent to copy_deref, then get to copy-propagate from the array at the top. Then we only have to set up the scratch array outside of the loop and load_scratch from it in the called function inside the loop. This also causes there to be less spilling, stps 1144 -> 354 and ldps 826->36. However, it doesn't seem to change performance on the test. So, while this seems to be an improvement for the shader, and we could maybe even do better by rematerializing the txl samples inside the loop instead of storing the texture fetches to scratch in the first place, it doesn't currently seem worth pursuing more optimization of this shader. No change on freedreno shader-db. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15982>
This commit is contained in:
parent
7ba0c44607
commit
1bcd848816
1 changed files with 7 additions and 2 deletions
|
|
@ -81,8 +81,6 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
|
|||
progress = false;
|
||||
|
||||
OPT_V(s, nir_lower_vars_to_ssa);
|
||||
progress |= OPT(s, nir_opt_copy_prop_vars);
|
||||
progress |= OPT(s, nir_opt_dead_write_vars);
|
||||
progress |= OPT(s, nir_lower_alu_to_scalar, NULL, NULL);
|
||||
progress |= OPT(s, nir_lower_phis_to_scalar, false);
|
||||
|
||||
|
|
@ -90,6 +88,11 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
|
|||
progress |= OPT(s, nir_opt_deref);
|
||||
progress |= OPT(s, nir_opt_dce);
|
||||
progress |= OPT(s, nir_opt_cse);
|
||||
|
||||
progress |= OPT(s, nir_opt_find_array_copies);
|
||||
progress |= OPT(s, nir_opt_copy_prop_vars);
|
||||
progress |= OPT(s, nir_opt_dead_write_vars);
|
||||
|
||||
static int gcm = -1;
|
||||
if (gcm == -1)
|
||||
gcm = env_var_as_unsigned("GCM", 0);
|
||||
|
|
@ -165,6 +168,8 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
|
|||
progress |= OPT(s, nir_opt_remove_phis);
|
||||
progress |= OPT(s, nir_opt_undef);
|
||||
} while (progress);
|
||||
|
||||
OPT(s, nir_lower_var_copies);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue