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;