brw/sat: Eliminate non-defs saturate propagation
The intervening_saturating_copy test is removed. The defs version of the pass does not handle this case. It should not occur often in practice anyway. Copy propagation and brw_nir_opt_fsat should prevent this scenario from happening. No shader-db changes on any Intel platform. fossil-db: All Intel platforms had similar results. (Lunar Lake shown) Totals: Instrs: 212677275 -> 212677278 (+0.00%) Cycle count: 30466062848 -> 30466056040 (-0.00%) Totals from 1 (0.00% of 706300) affected shaders: Instrs: 1343 -> 1346 (+0.22%) Cycle count: 411664 -> 404856 (-1.65%) v2: Stop counting ip. The non-defs part of the pass was the only thing that used it. v3: Also delete "if (block != def->block) continue;" code. I noticed this while working on some other changes to this function. It's the last thing in the loop, so it's totally useless. Delete some other spurious continues too. Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> [v2] Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31497>
This commit is contained in:
@@ -91,13 +91,8 @@ opt_saturate_propagation_local(brw_shader &s,
|
||||
bblock_t *block)
|
||||
{
|
||||
bool progress = false;
|
||||
int ip = ips.end(block) + 1;
|
||||
|
||||
/* Walk backwards so IPs don't become invalid. */
|
||||
|
||||
foreach_inst_in_block_reverse(brw_inst, inst, block) {
|
||||
ip--;
|
||||
|
||||
if (inst->opcode != BRW_OPCODE_MOV ||
|
||||
!inst->saturate ||
|
||||
inst->dst.file != VGRF ||
|
||||
@@ -122,69 +117,11 @@ opt_saturate_propagation_local(brw_shader &s,
|
||||
if (def->saturate) {
|
||||
inst->saturate = false;
|
||||
progress = true;
|
||||
continue;
|
||||
} else if (defs.get_use_count(def->dst) == 1 &&
|
||||
def->can_do_saturate() &&
|
||||
propagate_sat(inst, def)) {
|
||||
progress = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the def is in a different block the liveness based pass will
|
||||
* not be able to make progress, so skip it.
|
||||
*/
|
||||
if (block != def->block)
|
||||
continue;
|
||||
}
|
||||
|
||||
const brw_live_variables &live = s.live_analysis.require();
|
||||
int src_var = live.var_from_reg(inst->src[0]);
|
||||
int src_end_ip = live.end[src_var];
|
||||
|
||||
bool interfered = false;
|
||||
foreach_inst_in_block_reverse_starting_from(brw_inst, scan_inst, inst) {
|
||||
if (scan_inst->exec_size == inst->exec_size &&
|
||||
regions_overlap(scan_inst->dst, scan_inst->size_written,
|
||||
inst->src[0], inst->size_read(s.devinfo, 0))) {
|
||||
if (scan_inst->is_partial_write() ||
|
||||
(scan_inst->dst.type != inst->dst.type &&
|
||||
!scan_inst->can_change_types()))
|
||||
break;
|
||||
|
||||
if (scan_inst->flags_written(s.devinfo) != 0)
|
||||
break;
|
||||
|
||||
if (scan_inst->saturate) {
|
||||
inst->saturate = false;
|
||||
progress = true;
|
||||
} else if (src_end_ip == ip || inst->dst.equals(inst->src[0])) {
|
||||
if (scan_inst->can_do_saturate() &&
|
||||
propagate_sat(inst, scan_inst)) {
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < scan_inst->sources; i++) {
|
||||
if (scan_inst->src[i].file == VGRF &&
|
||||
scan_inst->src[i].nr == inst->src[0].nr &&
|
||||
regions_overlap(
|
||||
scan_inst->src[i], scan_inst->size_read(s.devinfo, i),
|
||||
inst->src[0], inst->size_read(s.devinfo, 0))) {
|
||||
if (scan_inst->opcode != BRW_OPCODE_MOV ||
|
||||
!scan_inst->saturate ||
|
||||
scan_inst->src[0].abs ||
|
||||
scan_inst->src[0].negate ||
|
||||
scan_inst->src[0].abs != inst->src[0].abs ||
|
||||
scan_inst->src[0].negate != inst->src[0].negate) {
|
||||
interfered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (interfered)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -264,30 +264,6 @@ TEST_F(saturate_propagation_test, producer_saturates)
|
||||
EXPECT_SHADERS_MATCH(bld, exp);
|
||||
}
|
||||
|
||||
TEST_F(saturate_propagation_test, intervening_saturating_copy)
|
||||
{
|
||||
brw_builder bld = make_shader(MESA_SHADER_FRAGMENT, 16);
|
||||
brw_builder exp = make_shader(MESA_SHADER_FRAGMENT, 16);
|
||||
|
||||
brw_reg dst0 = vgrf(bld, exp, BRW_TYPE_F);
|
||||
brw_reg dst1 = vgrf(bld, exp, BRW_TYPE_F);
|
||||
brw_reg dst2 = vgrf(bld, exp, BRW_TYPE_F);
|
||||
brw_reg src0 = vgrf(bld, exp, BRW_TYPE_F);
|
||||
brw_reg src1 = vgrf(bld, exp, BRW_TYPE_F);
|
||||
|
||||
bld.ADD(dst0, bld.LOAD_REG(src0), bld.LOAD_REG(src1));
|
||||
bld.MOV(dst1, dst0)->saturate = true;
|
||||
bld.MOV(dst2, dst0)->saturate = true;
|
||||
|
||||
EXPECT_PROGRESS(brw_opt_saturate_propagation, bld);
|
||||
|
||||
exp.ADD(dst0, exp.LOAD_REG(src0), exp.LOAD_REG(src1))->saturate = true;
|
||||
exp.MOV(dst1, dst0);
|
||||
exp.MOV(dst2, dst0);
|
||||
|
||||
EXPECT_SHADERS_MATCH(bld, exp);
|
||||
}
|
||||
|
||||
TEST_F(saturate_propagation_test, intervening_dest_write)
|
||||
{
|
||||
brw_builder bld = make_shader(MESA_SHADER_FRAGMENT, 16);
|
||||
|
||||
Reference in New Issue
Block a user