Module: Mesa Branch: main Commit: 1a7e83c87f09eca150da25efa852fc36dd330105 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a7e83c87f09eca150da25efa852fc36dd330105
Author: Faith Ekstrand <faith.ekstr...@collabora.com> Date: Tue Dec 19 13:01:11 2023 -0600 nak/sm50: Properly legalize OpSel and drop an assert While we're here, update sm70 to be a bit more modern. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26587> --- src/nouveau/compiler/nak/encode_sm50.rs | 2 -- src/nouveau/compiler/nak/legalize.rs | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nouveau/compiler/nak/encode_sm50.rs b/src/nouveau/compiler/nak/encode_sm50.rs index 01fd55ba824..6ef74b2fe9d 100644 --- a/src/nouveau/compiler/nak/encode_sm50.rs +++ b/src/nouveau/compiler/nak/encode_sm50.rs @@ -285,8 +285,6 @@ impl SM50Instr { } fn encode_sel(&mut self, op: &OpSel) { - assert!(op.srcs[1].is_reg_or_zero()); - match &op.srcs[1].src_ref { SrcRef::Imm32(imm32) => { self.set_opcode(0x38a0); diff --git a/src/nouveau/compiler/nak/legalize.rs b/src/nouveau/compiler/nak/legalize.rs index f68874bfe9f..4878d7e806b 100644 --- a/src/nouveau/compiler/nak/legalize.rs +++ b/src/nouveau/compiler/nak/legalize.rs @@ -261,7 +261,12 @@ fn legalize_sm50_instr( copy_alu_src_if_not_reg(b, &mut op.src, SrcType::GPR); } Op::Sel(op) => { - copy_alu_src_if_not_reg(b, &mut op.srcs[1], SrcType::GPR); + let [ref mut src0, ref mut src1] = op.srcs; + if swap_srcs_if_not_reg(src0, src1) { + op.cond = op.cond.bnot(); + } + copy_alu_src_if_not_reg(b, src0, SrcType::ALU); + copy_alu_src_if_i20_overflow(b, src1, SrcType::ALU); } Op::Shfl(op) => { copy_alu_src_if_not_reg(b, &mut op.src, SrcType::GPR); @@ -529,9 +534,8 @@ fn legalize_sm70_instr( } Op::Sel(op) => { let [ref mut src0, ref mut src1] = op.srcs; - if !src_is_reg(src0) && src_is_reg(src1) { - std::mem::swap(src0, src1); - op.cond.src_mod = op.cond.src_mod.bnot(); + if swap_srcs_if_not_reg(src0, src1) { + op.cond = op.cond.bnot(); } copy_alu_src_if_not_reg(b, src0, SrcType::ALU); }