nak/sm50: Use OpBfe instead of OpBRev for nir_op_find_lsb

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28000>
This commit is contained in:
Faith Ekstrand 2024-03-05 18:15:52 -06:00 committed by Marge Bot
parent 3d13d190e6
commit 11de561395
2 changed files with 24 additions and 26 deletions

View file

@ -467,6 +467,26 @@ pub trait SSABuilder: Builder {
dst
}
fn brev(&mut self, x: Src) -> SSARef {
let dst = self.alloc_ssa(RegFile::GPR, 1);
if self.sm() >= 70 {
self.push_op(OpBRev {
dst: dst.into(),
src: x,
});
} else {
// No BREV in Maxwell
self.push_op(OpBfe {
dst: dst.into(),
base: x,
signed: false,
range: Src::new_imm_u32(0x2000),
reverse: true,
});
}
dst
}
fn mufu(&mut self, op: MuFuOp, src: Src) -> SSARef {
let dst = self.alloc_ssa(RegFile::GPR, 1);
self.push_op(OpMuFu {

View file

@ -546,25 +546,7 @@ impl<'a> ShaderFromNir<'a> {
});
dst
}
nir_op_bitfield_reverse => {
let dst = b.alloc_ssa(RegFile::GPR, 1);
if self.info.sm >= 70 {
b.push_op(OpBRev {
dst: dst.into(),
src: srcs[0],
});
} else {
// No BREV in Maxwell
b.push_op(OpBfe {
dst: dst.into(),
base: srcs[0],
signed: false,
range: Src::new_imm_u32(0x2000),
reverse: true,
});
}
dst
}
nir_op_bitfield_reverse => b.brev(srcs[0]),
nir_op_ibitfield_extract | nir_op_ubitfield_extract => {
let range = b.alloc_ssa(RegFile::GPR, 1);
b.push_op(OpPrmt {
@ -647,16 +629,12 @@ impl<'a> ShaderFromNir<'a> {
dst
}
nir_op_find_lsb => {
let tmp = b.alloc_ssa(RegFile::GPR, 1);
b.push_op(OpBRev {
dst: tmp.into(),
src: srcs[0],
});
let rev = b.brev(srcs[0]);
let dst = b.alloc_ssa(RegFile::GPR, 1);
b.push_op(OpFlo {
dst: dst.into(),
src: tmp.into(),
signed: alu.op == nir_op_ifind_msb,
src: rev.into(),
signed: false,
return_shift_amount: true,
});
dst