From 5654366a55793d82663d2ec9ac5d64a42ff8e4cf Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 22 Sep 2023 12:19:30 -0500 Subject: [PATCH] nak: Fold source modifiers in legalize We were smashing them to None later but didn't actually take them into account in fold_lop_src() to ensure the smash was valid. Part-of: --- src/nouveau/compiler/nak_legalize.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nouveau/compiler/nak_legalize.rs b/src/nouveau/compiler/nak_legalize.rs index c9d330631b5..a78ad256c30 100644 --- a/src/nouveau/compiler/nak_legalize.rs +++ b/src/nouveau/compiler/nak_legalize.rs @@ -38,6 +38,9 @@ fn fold_lop_src(src: &Src, x: &mut u8) { if let Some(i) = src_as_lop_imm(src) { *x = if i { !0 } else { 0 }; } + if src.src_mod.is_bnot() { + *x = !*x; + } } fn copy_src(b: &mut impl SSABuilder, src: &mut Src, file: RegFile) { @@ -159,7 +162,7 @@ fn legalize_instr(b: &mut impl SSABuilder, instr: &mut Instr) { copy_src_if_not_reg(b, src0, RegFile::GPR); } Op::Lop3(op) => { - /* Fold constants if we can */ + /* Fold constants and modifiers if we can */ op.op = LogicOp::new_lut(&|mut x, mut y, mut z| { fold_lop_src(&op.srcs[0], &mut x); fold_lop_src(&op.srcs[1], &mut y); @@ -206,7 +209,7 @@ fn legalize_instr(b: &mut impl SSABuilder, instr: &mut Instr) { copy_src_if_not_reg(b, src0, RegFile::GPR); } Op::PLop3(op) => { - /* Fold constants if we can */ + /* Fold constants and modifiers if we can */ for lop in &mut op.ops { *lop = LogicOp::new_lut(&|mut x, mut y, mut z| { fold_lop_src(&op.srcs[0], &mut x);