brw/cmod: Remove special handling of NOT

The previous commit converts any NOT that might have been affected by
this path into a simple MOV. Those MOVs are handled by other paths.

No shader-db or fossil-db changes on any Intel platform.

v2: Fix a bad squash. Changes that were accidentally in this commit were
supposed to be in the previous commit. Noticed by Ivan.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34509>
This commit is contained in:
Ian Romanick 2024-11-08 08:45:54 -08:00 committed by Marge Bot
parent 08fe7988d7
commit 8f0fd0e66e
2 changed files with 11 additions and 75 deletions

View file

@ -151,74 +151,6 @@ cmod_propagate_cmp_to_add(const intel_device_info *devinfo, brw_inst *inst)
return false;
}
/**
* Propagate conditional modifiers from NOT instructions
*
* Attempt to convert sequences like
*
* or(8) g78<8,8,1> g76<8,8,1>UD g77<8,8,1>UD
* ...
* not.nz.f0(8) null g78<8,8,1>UD
*
* into
*
* or.z.f0(8) g78<8,8,1> g76<8,8,1>UD g77<8,8,1>UD
*/
static bool
cmod_propagate_not(const intel_device_info *devinfo, brw_inst *inst)
{
const enum brw_conditional_mod cond = brw_negate_cmod(inst->conditional_mod);
bool read_flag = false;
const unsigned flags_written = inst->flags_written(devinfo);
if (cond != BRW_CONDITIONAL_Z && cond != BRW_CONDITIONAL_NZ)
return false;
foreach_inst_in_block_reverse_starting_from(brw_inst, scan_inst, inst) {
if (regions_overlap(scan_inst->dst, scan_inst->size_written,
inst->src[0], inst->size_read(devinfo, 0))) {
if (scan_inst->opcode != BRW_OPCODE_OR &&
scan_inst->opcode != BRW_OPCODE_AND)
break;
if (scan_inst->predicate ||
!scan_inst->dst.is_contiguous() ||
scan_inst->dst.offset != inst->src[0].offset ||
scan_inst->exec_size != inst->exec_size)
break;
/* If the scan instruction writes a different flag register than the
* instruction we're trying to propagate from, bail.
*
* FINISHME: The second part of the condition may be too strong.
* Perhaps (scan_inst->flags_written() & flags_written) !=
* flags_written?
*/
if (scan_inst->flags_written(devinfo) != 0 &&
scan_inst->flags_written(devinfo) != flags_written)
break;
if (scan_inst->can_do_cmod() &&
((!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();
return true;
}
break;
}
if ((scan_inst->flags_written(devinfo) & flags_written) != 0)
break;
read_flag = read_flag ||
(scan_inst->flags_read(devinfo) & flags_written) != 0;
}
return false;
}
static bool
opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
{
@ -227,8 +159,7 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
foreach_inst_in_block_reverse_safe(brw_inst, inst, block) {
if ((inst->opcode != BRW_OPCODE_AND &&
inst->opcode != BRW_OPCODE_CMP &&
inst->opcode != BRW_OPCODE_MOV &&
inst->opcode != BRW_OPCODE_NOT) ||
inst->opcode != BRW_OPCODE_MOV) ||
inst->predicate != BRW_PREDICATE_NONE ||
!inst->dst.is_null() ||
(inst->src[0].file != VGRF && inst->src[0].file != ATTR &&
@ -270,11 +201,6 @@ opt_cmod_propagation_local(const intel_device_info *devinfo, bblock_t *block)
continue;
}
if (inst->opcode == BRW_OPCODE_NOT) {
progress = cmod_propagate_not(devinfo, inst) || progress;
continue;
}
bool read_flag = false;
const unsigned flags_written = inst->flags_written(devinfo);
foreach_inst_in_block_reverse_starting_from(brw_inst, scan_inst, inst) {

View file

@ -1973,6 +1973,8 @@ TEST_F(cmod_propagation_test, not_to_or)
* 0: or.z.f0(8) dest src0 src1
*/
EXPECT_NO_PROGRESS(brw_opt_cmod_propagation, bld);
EXPECT_PROGRESS(brw_opt_algebraic, bld);
EXPECT_PROGRESS(brw_opt_cmod_propagation, bld);
exp.OR(dest, src0, src1)->conditional_mod = BRW_CONDITIONAL_Z;
@ -1995,6 +1997,8 @@ TEST_F(cmod_propagation_test, not_to_and)
bld.AND(dest, src0, src1);
bld.NOT(bld.null_reg_ud(), dest)->conditional_mod = BRW_CONDITIONAL_NZ;
EXPECT_NO_PROGRESS(brw_opt_cmod_propagation, bld);
EXPECT_PROGRESS(brw_opt_algebraic, bld);
EXPECT_PROGRESS(brw_opt_cmod_propagation, bld);
exp.AND(dest, src0, src1)->conditional_mod = BRW_CONDITIONAL_Z;
@ -2090,6 +2094,8 @@ TEST_F(cmod_propagation_test, not_to_or_intervening_flag_read_compatible_value)
set_predicate(BRW_PREDICATE_NORMAL, bld.SEL(dest1, src2, zero));
set_condmod(BRW_CONDITIONAL_NZ, bld.NOT(bld.null_reg_ud(), dest0));
EXPECT_NO_PROGRESS(brw_opt_cmod_propagation, bld);
EXPECT_PROGRESS(brw_opt_algebraic, bld);
EXPECT_PROGRESS(brw_opt_cmod_propagation, bld);
set_condmod(BRW_CONDITIONAL_Z, exp.OR(dest0, src0, src1));
@ -2163,6 +2169,8 @@ TEST_F(cmod_propagation_test, not_to_or_intervening_mismatch_flag_write)
->flag_subreg = 1;
set_condmod(BRW_CONDITIONAL_NZ, bld.NOT(bld.null_reg_ud(), dest0));
EXPECT_NO_PROGRESS(brw_opt_cmod_propagation, bld);
EXPECT_PROGRESS(brw_opt_algebraic, bld);
EXPECT_PROGRESS(brw_opt_cmod_propagation, bld);
set_condmod(BRW_CONDITIONAL_Z, exp.OR(dest0, src0, src1));
@ -2193,6 +2201,8 @@ TEST_F(cmod_propagation_test, not_to_or_intervening_mismatch_flag_read)
->flag_subreg = 1;
set_condmod(BRW_CONDITIONAL_NZ, bld.NOT(bld.null_reg_ud(), dest0));
EXPECT_NO_PROGRESS(brw_opt_cmod_propagation, bld);
EXPECT_PROGRESS(brw_opt_algebraic, bld);
EXPECT_PROGRESS(brw_opt_cmod_propagation, bld);
exp.OR(dest0, src0, src1)->conditional_mod = BRW_CONDITIONAL_Z;