Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions crates/xcl/src/gpu/recomp/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,22 +1341,16 @@ impl Em {
}

fn salu64(&mut self, d: &Decoded, name: &str, dst: &Dst, ins: &[&Operand]) -> Result<(), &'static str> {
let a = match ins.first() {
Some(o) => Some(self.read64(d, o, false).ok_or("op")?),
None => None,
};
let b = match ins.get(1) {
Some(o) => {
// shift amounts / bfe controls are 32-bit
if o.size == 32 {
let v = self.read(d, o, false).ok_or("op")?;
Some((v, "0u".into()))
} else {
Some(self.read64(d, o, false).ok_or("op")?)
}
let read_op = |this: &mut Self, o: &Operand| -> Result<(String, String), &'static str> {
// 32-bit controls / shift amounts / s_bfm_b64 width and offset
if o.size == 32 {
Ok((this.read(d, o, false).ok_or("op")?, "0u".into()))
} else {
this.read64(d, o, false).ok_or("op")
}
None => None,
};
let a = ins.first().map(|o| read_op(self, o)).transpose()?;
let b = ins.get(1).map(|o| read_op(self, o)).transpose()?;
let (al, ah) = a.clone().unwrap_or_default();
let (bl, bh) = b.clone().unwrap_or_default();
let (t0, t1) = (self.t(), self.t());
Expand Down
18 changes: 18 additions & 0 deletions crates/xcl/src/gpu/recomp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7306,6 +7306,24 @@ fn gpu_sdwa_f16_inline_constants() {
}
}

#[test]
fn gpu_s_bfm_b64_accepts_32bit_ssrc0() {
for wave64 in gpu_waves() {
let p = prog(&[
// SSRC0 = m0 (124, 32-bit), SSRC1 = 128 (0) -> 4-bit mask at bit 0 = 0x0F
("S_BFM_B64", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 124), ("SSRC1", 128)], None),
// SSRC0 = s105 (32-bit register at end of SGPR bank, not a valid 64-bit pair), SSRC1 = 160 (32) -> 8-bit mask at bit 32
("S_BFM_B64", "ENC_SOP2", &[("SDST", 2), ("SSRC0", 105), ("SSRC1", 160)], None),
]);
let mut st = KernelState::default();
st.sgpr[124] = 4;
st.sgpr[105] = 8;
let (r, lanes) = run_wave(&p, &st, wave64);
assert_eq!((r.sgpr[0], r.sgpr[1]), (0xF, 0), "wave{lanes} s_bfm_b64 with m0");
assert_eq!((r.sgpr[2], r.sgpr[3]), (0, 0xFF), "wave{lanes} s_bfm_b64 with s105");
}
}

#[test]
fn fspx_compute_user_sgprs_from_rsrc2() {
use crate::gpu::xbox::tests::container;
Expand Down
Loading