nak/legalize: Fold immediate sources before instructions

This way, if we insert a copy to move the immediate to a GPR, the
immediate we place in the copy is also folded.

Fixes: 85462f7455 ("nak: Legalize immediates with source modifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
This commit is contained in:
Faith Ekstrand
2024-05-27 13:06:18 -05:00
committed by Marge Bot
parent 00c6244ca2
commit 37b55ee34f
+5 -5
View File
@@ -815,6 +815,11 @@ fn legalize_instr(
ip: usize,
instr: &mut Instr,
) {
let src_types = instr.src_types();
for (i, src) in instr.srcs_mut().iter_mut().enumerate() {
*src = src.fold_imm(src_types[i]);
}
if b.sm() >= 70 {
legalize_sm70_instr(b, bl, ip, instr);
} else if b.sm() >= 50 {
@@ -823,11 +828,6 @@ fn legalize_instr(
panic!("Unknown shader model SM{}", b.sm());
}
let src_types = instr.src_types();
for (i, src) in instr.srcs_mut().iter_mut().enumerate() {
*src = src.fold_imm(src_types[i]);
}
let mut vec_src_map: HashMap<SSARef, SSARef> = HashMap::new();
let mut vec_comps = HashSet::new();
for src in instr.srcs_mut() {