nak/opt_copy_prop: Add force_alu_src_type

This is just a code cleanup - it shouldn't change any shaders.

Cc: mesa-stable
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Faith Ekstrand <None>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33420>
This commit is contained in:
Mel Henning 2025-02-05 18:33:48 -05:00 committed by Marge Bot
parent a5b267980a
commit 2fa557d29d

View file

@ -638,45 +638,28 @@ impl CopyPropPass {
CBufRule::Yes
};
match &mut instr.op {
Op::IAdd2(add) => {
// Carry-out interacts funny with SrcMod::INeg so we can
// only propagate with modifiers if no carry is written.
use SrcType::{ALU, I32};
let [src0, src1] = &mut add.srcs;
if add.carry_out.is_none() {
self.prop_to_src(I32, &cbuf_rule, src0);
self.prop_to_src(I32, &cbuf_rule, src1);
} else {
self.prop_to_src(ALU, &cbuf_rule, src0);
self.prop_to_src(ALU, &cbuf_rule, src1);
}
}
// Carry-out and overflow interact funny with SrcMod::INeg so we
// can only propagate with modifiers if no carry/overflow is
// written.
let force_alu_src_type = match &instr.op {
Op::IAdd2(add) => !add.carry_out.is_none(),
Op::IAdd3(add) => {
// Overflow interacts funny with SrcMod::INeg so we can
// only propagate with modifiers if no overflow values
// are written.
use SrcType::{ALU, I32};
let [src0, src1, src2] = &mut add.srcs;
if add.overflow[0].is_none()
&& add.overflow[1].is_none()
{
self.prop_to_src(I32, &cbuf_rule, src0);
self.prop_to_src(I32, &cbuf_rule, src1);
self.prop_to_src(I32, &cbuf_rule, src2);
} else {
self.prop_to_src(ALU, &cbuf_rule, src0);
self.prop_to_src(ALU, &cbuf_rule, src1);
self.prop_to_src(ALU, &cbuf_rule, src2);
}
}
_ => {
let src_types = instr.src_types();
for (i, src) in instr.srcs_mut().iter_mut().enumerate()
{
self.prop_to_src(src_types[i], &cbuf_rule, src);
}
!add.overflow[0].is_none() || !add.overflow[1].is_none()
}
_ => false,
};
let src_types = instr.src_types();
for (i, src) in instr.srcs_mut().iter_mut().enumerate() {
let mut src_type = src_types[i];
if force_alu_src_type {
src_type = match src_type {
SrcType::I32 => SrcType::ALU,
SrcType::Pred => SrcType::Pred,
_ => panic!("Unhandled src_type"),
};
};
self.prop_to_src(src_type, &cbuf_rule, src);
}
}
}