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>
(cherry picked from commit 37b55ee34f)
This commit is contained in:
Faith Ekstrand 2024-05-27 13:06:18 -05:00 committed by Eric Engestrom
parent 8e7ed15153
commit d1bc625bd1
2 changed files with 6 additions and 6 deletions

View file

@ -2234,7 +2234,7 @@
"description": "nak/legalize: Fold immediate sources before instructions",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "85462f74553cd835e9ba4c954330499cee832893",
"notes": null

View file

@ -816,6 +816,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 {
@ -824,11 +829,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() {