Mesa (main): intel/fs: Fix a cmod prop bug when cmod is set to inst that doesn't support it

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 1 21:22:34 UTC 2021


Module: Mesa
Branch: main
Commit: 2dbb66997e2e2ab0a07a84a40df70d8d75fe2524
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2dbb66997e2e2ab0a07a84a40df70d8d75fe2524

Author: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
Date:   Thu Oct 21 23:06:29 2021 +0300

intel/fs: Fix a cmod prop bug when cmod is set to inst that doesn't support it

Fixes dEQP-VK.reconvergence.*nesting* tests.

There are cases when cmod is set to an instruction that cannot have
conditional modifier. E.g. following:

 find_live_channel(32) vgrf166:UD,  NoMask
 cmp.z.f0.0(32) null:D, vgrf166+0.0<0>:D, 0d

is optimized to:

 find_live_channel.z.f0.0(32) vgrf166:UD,  NoMask

v2:
 - Add unit test to check cmod is not set to 'find_live_channel' (Matt Turner)
 - Update flag_subreg when conditonal_mod is updated (Ian Romanick)

Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5431
Fixes: 32b7ba66b01 ("intel/compiler: fix cmod propagation optimisations")
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13268>

---

 src/intel/compiler/brw_fs_cmod_propagation.cpp  |  5 +++-
 src/intel/compiler/test_fs_cmod_propagation.cpp | 32 +++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_fs_cmod_propagation.cpp b/src/intel/compiler/brw_fs_cmod_propagation.cpp
index afbc34eef23..ed0c5aa0c70 100644
--- a/src/intel/compiler/brw_fs_cmod_propagation.cpp
+++ b/src/intel/compiler/brw_fs_cmod_propagation.cpp
@@ -135,6 +135,7 @@ cmod_propagate_cmp_to_add(const intel_device_info *devinfo, bblock_t *block,
              ((!read_flag && scan_inst->conditional_mod == BRW_CONDITIONAL_NONE) ||
               scan_inst->conditional_mod == cond)) {
             scan_inst->conditional_mod = cond;
+            scan_inst->flag_subreg = inst->flag_subreg;
             inst->remove(block, true);
             return true;
          }
@@ -203,6 +204,7 @@ cmod_propagate_not(const intel_device_info *devinfo, bblock_t *block,
              ((!read_flag && scan_inst->conditional_mod == BRW_CONDITIONAL_NONE) ||
               scan_inst->conditional_mod == cond)) {
             scan_inst->conditional_mod = cond;
+            scan_inst->flag_subreg = inst->flag_subreg;
             inst->remove(block, true);
             return true;
          }
@@ -458,8 +460,9 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
                   }
 
                   break;
-               } else if (!read_flag) {
+               } else if (!read_flag && scan_inst->can_do_cmod()) {
                   scan_inst->conditional_mod = inst->conditional_mod;
+                  scan_inst->flag_subreg = inst->flag_subreg;
                   inst->remove(block, true);
                   progress = true;
                   break;
diff --git a/src/intel/compiler/test_fs_cmod_propagation.cpp b/src/intel/compiler/test_fs_cmod_propagation.cpp
index 6d5851d6448..15ca26a3986 100644
--- a/src/intel/compiler/test_fs_cmod_propagation.cpp
+++ b/src/intel/compiler/test_fs_cmod_propagation.cpp
@@ -251,6 +251,38 @@ TEST_F(cmod_propagation_test, non_cmod_instruction)
    EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod);
 }
 
+TEST_F(cmod_propagation_test, non_cmod_livechannel)
+{
+   const fs_builder &bld = v->bld;
+   fs_reg dest = v->vgrf(glsl_type::uint_type);
+   fs_reg zero(brw_imm_d(0));
+   bld.emit(SHADER_OPCODE_FIND_LIVE_CHANNEL, dest)->exec_size = 32;
+   bld.CMP(bld.null_reg_d(), dest, zero, BRW_CONDITIONAL_Z)->exec_size = 32;
+
+   /* = Before =
+    *
+    * 0: find_live_channel(32) dest
+    * 1: cmp.z.f0.0(32)   null dest 0d
+    *
+    *
+    * = After =
+    * (no changes)
+    */
+
+   v->calculate_cfg();
+   bblock_t *block0 = v->cfg->blocks[0];
+
+   EXPECT_EQ(0, block0->start_ip);
+   EXPECT_EQ(1, block0->end_ip);
+
+   EXPECT_FALSE(cmod_propagation(v));
+   EXPECT_EQ(0, block0->start_ip);
+   EXPECT_EQ(1, block0->end_ip);
+   EXPECT_EQ(SHADER_OPCODE_FIND_LIVE_CHANNEL, instruction(block0, 0)->opcode);
+   EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode);
+   EXPECT_EQ(BRW_CONDITIONAL_Z, instruction(block0, 1)->conditional_mod);
+}
+
 TEST_F(cmod_propagation_test, intervening_flag_write)
 {
    const fs_builder &bld = v->bld;



More information about the mesa-commit mailing list