Module: Mesa
Branch: staging/23.0
Commit: 95d24c496c183b74833dd8fe3d27819b4ca66754
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95d24c496c183b74833dd8fe3d27819b4ca66754

Author: Konstantin Seurer <[email protected]>
Date:   Tue Dec 20 18:26:34 2022 +0100

nir/lower_shader_calls: Remat derefs before lowering resumes

Closes: #7923
cc: mesa-stable

Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20399>
(cherry picked from commit 200e551cbb36c201b0083c6a6ba8930c9077a6e8)

---

 .pick_status.json                         | 2 +-
 src/compiler/nir/nir_lower_shader_calls.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6af4da8c687..009caa421f4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4675,7 +4675,7 @@
         "description": "nir/lower_shader_calls: Remat derefs before lowering 
resumes",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/nir/nir_lower_shader_calls.c 
b/src/compiler/nir/nir_lower_shader_calls.c
index 02c8478c46b..472e8b9a5b8 100644
--- a/src/compiler/nir/nir_lower_shader_calls.c
+++ b/src/compiler/nir/nir_lower_shader_calls.c
@@ -1182,6 +1182,13 @@ lower_resume(nir_shader *shader, int call_idx)
    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");

Reply via email to