|
|
@@ -50,7 +50,7 @@ enum Val {
|
|
|
|
|
|
pub(crate) struct Lowered {
|
|
|
pub dxil: Vec<u8>,
|
|
|
- /// Bit n: immediate sampler n is used for comparisons.
|
|
|
+ /// Bit n: immediate sampler n is a comparison sampler.
|
|
|
pub cmp_samplers: u64,
|
|
|
pub root_cbvs: Vec<u8>,
|
|
|
pub root_srvs: Vec<u8>,
|
|
|
@@ -5226,6 +5226,10 @@ impl<'a> Lower<'a> {
|
|
|
let x = crate::resource::inline(*k).ok_or("a special operand")?;
|
|
|
Ok(l.s.m.i32(if (x as i32) < 0 { u32::MAX } else { 0 }))
|
|
|
}
|
|
|
+ // Of a signed operand, a literal sign-extends too.
|
|
|
+ Some(&Operand::Literal(x)) if name.ends_with("_i64") => {
|
|
|
+ Ok(l.s.m.i32(if (x as i32) < 0 { u32::MAX } else { 0 }))
|
|
|
+ }
|
|
|
_ => Ok(l.s.m.i32(0)),
|
|
|
}
|
|
|
};
|
|
|
@@ -5312,6 +5316,20 @@ impl<'a> Lower<'a> {
|
|
|
l.s.m.cmp(c, pred::NE, o, z)
|
|
|
};
|
|
|
return match name {
|
|
|
+ "s_quadmask_b64" => {
|
|
|
+ let (a, b) = (half(self, 0, 0)?, half(self, 0, 1)?);
|
|
|
+ let low = self.quad_mask(a);
|
|
|
+ let high = self.quad_mask(b);
|
|
|
+ let k8 = self.s.m.i32(8);
|
|
|
+ let high = self.s.m.bin(c, Bin::Shl, high, k8);
|
|
|
+ let mask = self.s.m.bin(c, Bin::Or, low, high);
|
|
|
+ let zero = self.s.m.i32(0);
|
|
|
+ self.set(lo, Val::I32(mask));
|
|
|
+ self.set(hi, Val::I32(zero));
|
|
|
+ let nonzero = self.s.m.cmp(c, pred::NE, mask, zero);
|
|
|
+ self.set(scc, Val::Bit(nonzero));
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
"s_bcnt1_i32_b64" => {
|
|
|
let (a, b) = (half(self, 0, 0)?, half(self, 0, 1)?);
|
|
|
let i32t = self.s.t.i32;
|
|
|
@@ -5437,6 +5455,10 @@ impl<'a> Lower<'a> {
|
|
|
let (r, carry): (V, Option<V>) = match name {
|
|
|
"s_mov_b32" => (src32(self, 0)?, None),
|
|
|
"s_movk_i32" => (sext16(self), None),
|
|
|
+ "s_quadmask_b32" => {
|
|
|
+ let pixels = src32(self, 0)?;
|
|
|
+ (self.quad_mask(pixels), None)
|
|
|
+ }
|
|
|
"s_cselect_b32" => {
|
|
|
let cond = self.scc_in(inst)?;
|
|
|
let (a, b) = (src32(self, 0)?, src32(self, 1)?);
|
|
|
@@ -5630,6 +5652,29 @@ impl<'a> Lower<'a> {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+ /// Packs whether each consecutive group of four pixels has a set bit.
|
|
|
+ fn quad_mask(&mut self, pixels: V) -> V {
|
|
|
+ let c = self.cur;
|
|
|
+ let one = self.s.m.i32(1);
|
|
|
+ let shifted = self.s.m.bin(c, Bin::LShr, pixels, one);
|
|
|
+ let mut mask = self.s.m.bin(c, Bin::Or, pixels, shifted);
|
|
|
+ // Fold each nibble into its bottom bit, then gather those bits into
|
|
|
+ // the low byte in three stages without needing a 64-bit operation.
|
|
|
+ for (distance, keep) in [
|
|
|
+ (2, 0x1111_1111),
|
|
|
+ (3, 0x0303_0303),
|
|
|
+ (6, 0x000f_000f),
|
|
|
+ (12, 0x0000_00ff),
|
|
|
+ ] {
|
|
|
+ let distance = self.s.m.i32(distance);
|
|
|
+ let shifted = self.s.m.bin(c, Bin::LShr, mask, distance);
|
|
|
+ let combined = self.s.m.bin(c, Bin::Or, mask, shifted);
|
|
|
+ let keep = self.s.m.i32(keep);
|
|
|
+ mask = self.s.m.bin(c, Bin::And, combined, keep);
|
|
|
+ }
|
|
|
+ mask
|
|
|
+ }
|
|
|
+
|
|
|
/// `a + b (+ cin)` or `a - b (- cin)` with the carry (borrow) out, as the
|
|
|
/// scalar and vector add-with-carry instructions set it.
|
|
|
fn add_sub_carry(&mut self, c: usize, add: bool, a: V, b: V, cin: Option<V>) -> (V, V) {
|
|
|
@@ -6300,20 +6345,34 @@ impl<'a> Lower<'a> {
|
|
|
l.s.m.bin(c, Bin::AShr, t, k)
|
|
|
};
|
|
|
let f32t = self.s.t.f32;
|
|
|
+ // A normalized format's ends are exactly 1.0 and -1.0. The host
|
|
|
+ // may divide through a reciprocal and land just below 1.0: RDNA
|
|
|
+ // 4 loaded 16_16_UNORM's 65535 as the half 0x3BFF, not 0x3C00.
|
|
|
let x = match numeric {
|
|
|
Numeric::Unorm => {
|
|
|
let f = self.s.m.cast(c, Cast::UiToFp, field, f32t);
|
|
|
- let max = self.s.m.f32((((1u64 << w) - 1) as f32).to_bits());
|
|
|
+ let top = (1u64 << w) - 1;
|
|
|
+ let max = self.s.m.f32((top as f32).to_bits());
|
|
|
let q = self.s.m.bin(c, Bin::SDiv, f, max);
|
|
|
+ let (high, one) = (self.s.m.i32(top as u32), self.s.m.f32(1.0f32.to_bits()));
|
|
|
+ let at_top = self.s.m.cmp(c, pred::EQ, field, high);
|
|
|
+ let q = self.s.m.select(c, at_top, one, q);
|
|
|
float(self, q)
|
|
|
}
|
|
|
Numeric::Snorm => {
|
|
|
let s = signed(self);
|
|
|
let f = self.s.m.cast(c, Cast::SiToFp, s, f32t);
|
|
|
- let max = self.s.m.f32((((1u64 << (w - 1)) - 1) as f32).to_bits());
|
|
|
+ let top = (1u32 << (w - 1)) - 1;
|
|
|
+ let max = self.s.m.f32((top as f32).to_bits());
|
|
|
let q = self.s.m.bin(c, Bin::SDiv, f, max);
|
|
|
- let lo = self.s.m.f32((-1.0f32).to_bits());
|
|
|
- let q = self.binary(35, q, lo);
|
|
|
+ // The lowest value is -1.0 too, as is the one above it.
|
|
|
+ let (high, one) = (self.s.m.i32(top), self.s.m.f32(1.0f32.to_bits()));
|
|
|
+ let at_top = self.s.m.cmp(c, pred::SGE, s, high);
|
|
|
+ let q = self.s.m.select(c, at_top, one, q);
|
|
|
+ let low = self.s.m.i32(top.wrapping_neg());
|
|
|
+ let minus_one = self.s.m.f32((-1.0f32).to_bits());
|
|
|
+ let at_bottom = self.s.m.cmp(c, pred::SLE, s, low);
|
|
|
+ let q = self.s.m.select(c, at_bottom, minus_one, q);
|
|
|
float(self, q)
|
|
|
}
|
|
|
Numeric::Uscaled => {
|
|
|
@@ -6355,6 +6414,39 @@ impl<'a> Lower<'a> {
|
|
|
Ok(out)
|
|
|
}
|
|
|
|
|
|
+ /// Channels of buffer format `format`, as [`Self::format_load`] gives
|
|
|
+ /// them, as d16 data: 16 bits each, two per dword, low half first (an
|
|
|
+ /// odd last high half 0). Integer formats keep their low 16 bits; the
|
|
|
+ /// others become f16.
|
|
|
+ fn d16_channels(&mut self, format: u8, channels: Vec<V>) -> Result<Vec<V>, Why> {
|
|
|
+ let (_, numeric) = buffer_format(format).ok_or("a buffer format")?;
|
|
|
+ let c = self.cur;
|
|
|
+ let mut halves = Vec::new();
|
|
|
+ for x in channels {
|
|
|
+ halves.push(if matches!(numeric, Numeric::Uint | Numeric::Sint) {
|
|
|
+ let m = self.s.m.i32(0xFFFF);
|
|
|
+ self.s.m.bin(c, Bin::And, x, m)
|
|
|
+ } else {
|
|
|
+ let (f, i32t) = (self.as_float(x), self.s.t.i32);
|
|
|
+ self.s
|
|
|
+ .op(c, "legacyF32ToF16", Attr::ReadNone, i32t, 130, &[f])
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let mut out = Vec::new();
|
|
|
+ for pair in halves.chunks(2) {
|
|
|
+ out.push(match *pair {
|
|
|
+ [lo, hi] => {
|
|
|
+ let k16 = self.s.m.i32(16);
|
|
|
+ let hi = self.s.m.bin(c, Bin::Shl, hi, k16);
|
|
|
+ self.s.m.bin(c, Bin::Or, lo, hi)
|
|
|
+ }
|
|
|
+ [lo] => lo,
|
|
|
+ _ => unreachable!("chunks of one or two"),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Ok(out)
|
|
|
+ }
|
|
|
+
|
|
|
/// The byte offset a buffer descriptor built around a root descriptor adds
|
|
|
/// (constant and computed parts); none for other descriptors.
|
|
|
fn built_offset(&mut self, src: &Source) -> Result<(u32, Option<V>), Why> {
|
|
|
@@ -6467,23 +6559,8 @@ impl<'a> Lower<'a> {
|
|
|
Ok(h)
|
|
|
}
|
|
|
Source::Constant(words) if sampler => {
|
|
|
- let words: [u32; 4] = words
|
|
|
- .get(..4)
|
|
|
- .and_then(|w| w.try_into().ok())
|
|
|
- .ok_or("a sampler constant")?;
|
|
|
- let n = match self.samplers.iter().position(|w| *w == words) {
|
|
|
- Some(n) => n,
|
|
|
- None => {
|
|
|
- self.samplers.push(words);
|
|
|
- self.samplers.len() - 1
|
|
|
- }
|
|
|
- };
|
|
|
- if props.0 & 0x8000 != 0 {
|
|
|
- // shortcut: one sampler used with and without comparison
|
|
|
- // would need two static samplers; it becomes a comparison one.
|
|
|
- self.s.cmp_samplers |= 1 << n;
|
|
|
- }
|
|
|
- Ok(self.s.sampler_handle(self.cur, n as u32))
|
|
|
+ let n = self.register_sampler(words, props.0 & 0x8000 != 0)?;
|
|
|
+ Ok(self.s.sampler_handle(self.cur, n))
|
|
|
}
|
|
|
Source::Constant(_) => Err("a constant resource descriptor"),
|
|
|
Source::Built { address, .. } => {
|
|
|
@@ -6594,22 +6671,30 @@ impl<'a> Lower<'a> {
|
|
|
Ok(phi)
|
|
|
}
|
|
|
|
|
|
- /// Registers an immediate sampler constant and returns its slot index.
|
|
|
+ /// Registers an immediate sampler constant and returns its slot index: a
|
|
|
+ /// constant used with and without comparison takes one slot for each.
|
|
|
fn register_sampler(&mut self, words: &[u32], cmp: bool) -> Result<u32, Why> {
|
|
|
let words: [u32; 4] = words
|
|
|
.get(..4)
|
|
|
.and_then(|w| w.try_into().ok())
|
|
|
.ok_or("a sampler constant")?;
|
|
|
- let n = match self.samplers.iter().position(|w| *w == words) {
|
|
|
+ let slot = self
|
|
|
+ .samplers
|
|
|
+ .iter()
|
|
|
+ .enumerate()
|
|
|
+ .position(|(n, w)| *w == words && (self.s.cmp_samplers >> n & 1 != 0) == cmp);
|
|
|
+ let n = match slot {
|
|
|
Some(n) => n,
|
|
|
None => {
|
|
|
+ let n = self.samplers.len();
|
|
|
+ if n >= u64::BITS as usize {
|
|
|
+ return Err("more than 64 immediate sampler slots");
|
|
|
+ }
|
|
|
self.samplers.push(words);
|
|
|
- self.samplers.len() - 1
|
|
|
+ self.s.cmp_samplers |= u64::from(cmp) << n;
|
|
|
+ n
|
|
|
}
|
|
|
};
|
|
|
- if cmp && n < 64 {
|
|
|
- self.s.cmp_samplers |= 1 << n;
|
|
|
- }
|
|
|
Ok(n as u32)
|
|
|
}
|
|
|
|
|
|
@@ -7630,6 +7715,17 @@ impl<'a> Lower<'a> {
|
|
|
let r = self.s.m.cast(c, op, a, self.s.t.f32);
|
|
|
float(self, r)
|
|
|
}
|
|
|
+ "v_cvt_off_f32_i4" => {
|
|
|
+ // The low nibble as a signed 4-bit integer, over 16.
|
|
|
+ let a = s(self, 0)?;
|
|
|
+ let k28 = self.s.m.i32(28);
|
|
|
+ let a = self.s.m.bin(c, Bin::Shl, a, k28);
|
|
|
+ let a = self.s.m.bin(c, Bin::AShr, a, k28);
|
|
|
+ let f = self.s.m.cast(c, Cast::SiToFp, a, self.s.t.f32);
|
|
|
+ let k = self.s.m.f32(0.0625f32.to_bits());
|
|
|
+ let r = self.s.m.bin(c, Bin::Mul, f, k);
|
|
|
+ float(self, r)
|
|
|
+ }
|
|
|
"v_fma_mix_f32" | "v_fma_mixlo_f16" | "v_fma_mixhi_f16" => {
|
|
|
// Each source is f32, or with op_sel_hi the low (op_sel: high)
|
|
|
// f16 half; neg_hi is the absolute value here.
|
|
|
@@ -8065,8 +8161,14 @@ impl<'a> Lower<'a> {
|
|
|
let x = crate::resource::inline(k).ok_or("a special operand")?;
|
|
|
Ok(self.s.m.int_const(i64t, i64::from(x as i32)))
|
|
|
}
|
|
|
+ // A signed 64-bit operand sign-extends its 32-bit literal, as
|
|
|
+ // the hardware does (LLVM's AMDGPU operand rules).
|
|
|
+ Operand::Literal(x) if inst.name().ends_with("_i64") => {
|
|
|
+ Ok(self.s.m.int_const(i64t, i64::from(x as i32)))
|
|
|
+ }
|
|
|
_ => {
|
|
|
- // Literals and the null register: zero-extended.
|
|
|
+ // Literals (of unsigned and bit operands) and the null
|
|
|
+ // register: zero-extended.
|
|
|
let x = self.operand(inst, &op)?;
|
|
|
Ok(self.s.m.cast(c, Cast::ZExt, x, i64t))
|
|
|
}
|
|
|
@@ -9019,6 +9121,18 @@ impl<'a> Lower<'a> {
|
|
|
let b = self.s.m.bin(c, op, b, sh);
|
|
|
self.s.m.bin(c, Bin::Mul, a, b)
|
|
|
}
|
|
|
+ "v_mul_hi_u32_u24" | "v_mul_hi_i32_i24" => {
|
|
|
+ // The high dword of the same 48-bit product: the low 24 bits
|
|
|
+ // of each operand, zero- or sign-extended, multiplied.
|
|
|
+ let (a, b) = (s(self, 0)?, s(self, 1)?);
|
|
|
+ let signed = name == "v_mul_hi_i32_i24";
|
|
|
+ let (sh, op) = (k(self, 8), if signed { Bin::AShr } else { Bin::LShr });
|
|
|
+ let a = self.s.m.bin(c, Bin::Shl, a, sh);
|
|
|
+ let a = self.s.m.bin(c, op, a, sh);
|
|
|
+ let b = self.s.m.bin(c, Bin::Shl, b, sh);
|
|
|
+ let b = self.s.m.bin(c, op, b, sh);
|
|
|
+ self.mul_hi(a, b, signed)
|
|
|
+ }
|
|
|
"v_bfe_u32" | "v_bfe_i32" => {
|
|
|
let (a, off, w) = (s(self, 0)?, s(self, 1)?, s(self, 2)?);
|
|
|
let w = m31(self, w);
|
|
|
@@ -9097,6 +9211,44 @@ impl<'a> Lower<'a> {
|
|
|
let m = self.s.m.bin(c, Bin::Mul, a, b);
|
|
|
self.s.m.bin(c, Bin::Add, m, d)
|
|
|
}
|
|
|
+ "v_sad_u8" | "v_sad_hi_u8" | "v_sad_u16" | "v_sad_u32" | "v_msad_u8" => {
|
|
|
+ // src2 plus the sum of the unsigned differences |a - b| of
|
|
|
+ // the operands' bytes, halves or whole dwords, wrapping at 32
|
|
|
+ // bits. v_sad_hi_u8 adds the sum shifted to the high half;
|
|
|
+ // v_msad_u8 leaves out a byte whose mask byte (src1) is 0.
|
|
|
+ let (a, b, d) = (s(self, 0)?, s(self, 1)?, s(self, 2)?);
|
|
|
+ let (width, parts) = match name {
|
|
|
+ "v_sad_u16" => (16, 2),
|
|
|
+ "v_sad_u32" => (32, 1),
|
|
|
+ _ => (8, 4),
|
|
|
+ };
|
|
|
+ let zero = k(self, 0);
|
|
|
+ let mut sum = zero;
|
|
|
+ for i in 0..parts {
|
|
|
+ let (mut x, mut y) = (a, b);
|
|
|
+ if width < 32 {
|
|
|
+ let (sh, mask) = (k(self, width * i), k(self, (1 << width) - 1));
|
|
|
+ x = self.s.m.bin(c, Bin::LShr, x, sh);
|
|
|
+ x = self.s.m.bin(c, Bin::And, x, mask);
|
|
|
+ y = self.s.m.bin(c, Bin::LShr, y, sh);
|
|
|
+ y = self.s.m.bin(c, Bin::And, y, mask);
|
|
|
+ }
|
|
|
+ let above = self.s.m.cmp(c, pred::IUGT, x, y);
|
|
|
+ let hi = self.s.m.select(c, above, x, y);
|
|
|
+ let lo = self.s.m.select(c, above, y, x);
|
|
|
+ let mut diff = self.s.m.bin(c, Bin::Sub, hi, lo);
|
|
|
+ if name == "v_msad_u8" {
|
|
|
+ let masked = self.s.m.cmp(c, pred::NE, y, zero);
|
|
|
+ diff = self.s.m.select(c, masked, diff, zero);
|
|
|
+ }
|
|
|
+ sum = self.s.m.bin(c, Bin::Add, sum, diff);
|
|
|
+ }
|
|
|
+ if name == "v_sad_hi_u8" {
|
|
|
+ let k16 = k(self, 16);
|
|
|
+ sum = self.s.m.bin(c, Bin::Shl, sum, k16);
|
|
|
+ }
|
|
|
+ self.s.m.bin(c, Bin::Add, sum, d)
|
|
|
+ }
|
|
|
"v_min3_i32" | "v_max3_i32" | "v_min3_u32" | "v_max3_u32" | "v_med3_i32"
|
|
|
| "v_med3_u32" => {
|
|
|
let (a, b, d) = (s(self, 0)?, s(self, 1)?, s(self, 2)?);
|
|
|
@@ -10689,8 +10841,9 @@ impl<'a> Lower<'a> {
|
|
|
"buffer_load_sshort" => Some((16, true)),
|
|
|
_ => None,
|
|
|
};
|
|
|
- // d16: two 16-bit channels per VGPR, low half first.
|
|
|
- let d16 = name.starts_with("buffer_") && name.contains("_format_d16_");
|
|
|
+ // d16: two 16-bit channels per VGPR, low half first (buffer and
|
|
|
+ // tbuffer formats alike).
|
|
|
+ let d16 = name.contains("_format_d16_");
|
|
|
let plain = name.replace("_format_d16_", "_format_");
|
|
|
let (typed, count) = match plain
|
|
|
.strip_prefix("buffer_load_")
|
|
|
@@ -11024,7 +11177,11 @@ impl<'a> Lower<'a> {
|
|
|
let Some(Operand::Vector { reg, .. }) = *data else {
|
|
|
return Err("a buffer result");
|
|
|
};
|
|
|
- for (k, x) in self.format_load(h, off, f, count)?.into_iter().enumerate() {
|
|
|
+ let mut xs = self.format_load(h, off, f, count)?;
|
|
|
+ if d16 {
|
|
|
+ xs = self.d16_channels(f, xs)?;
|
|
|
+ }
|
|
|
+ for (k, x) in xs.into_iter().enumerate() {
|
|
|
self.write(inst, Reg::V(reg + k as u8), x, guard);
|
|
|
}
|
|
|
return Ok(());
|
|
|
@@ -11361,8 +11518,11 @@ impl<'a> Lower<'a> {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
- /// Mesh: `exp prim` as the lane's primitive. Bit 31 culls it (all
|
|
|
- /// indices 0: no area).
|
|
|
+ /// Mesh: `exp prim` as the lane's primitive. Each corner takes ten
|
|
|
+ /// bits: a 9-bit vertex index and, above it, its edge flag (bits 9, 19
|
|
|
+ /// and 29), which only the console's edge-flag rasterisation reads and
|
|
|
+ /// which is no part of the index. Bit 31 culls it (all indices 0: no
|
|
|
+ /// area).
|
|
|
fn emit_indices(&mut self, e: &Export, guard: Option<V>) -> Result<(), Why> {
|
|
|
let v = e.values[0].ok_or("a primitive export without its indices")?;
|
|
|
let x = self.i32_of(v)?;
|
|
|
@@ -11395,7 +11555,7 @@ impl<'a> Lower<'a> {
|
|
|
});
|
|
|
let mut indices = [z; 3];
|
|
|
for (k, slot) in indices.iter_mut().enumerate() {
|
|
|
- let (shift, mask) = (self.s.m.i32(10 * k as u32), self.s.m.i32(0x3FF));
|
|
|
+ let (shift, mask) = (self.s.m.i32(10 * k as u32), self.s.m.i32(0x1FF));
|
|
|
let i = self.s.m.bin(c, Bin::LShr, x, shift);
|
|
|
let i = self.s.m.bin(c, Bin::And, i, mask);
|
|
|
if let Some(n) = written {
|
|
|
@@ -11994,6 +12154,55 @@ mod tests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// Lowers a one-thread compute program that copies four root constants
|
|
|
+ /// (s0..s3) into v1..v4, runs `body`, and stores v0 to a raw buffer from a
|
|
|
+ /// descriptor table, so the vector instructions in `body` have an effect.
|
|
|
+ fn lowers_valu(body: &[u32]) -> Result<(), crate::ShaderError> {
|
|
|
+ let mut words = vec![
|
|
|
+ 0xBE85_0380, // s_mov_b32 s5, 0
|
|
|
+ 0xF408_0202, // s_load_dwordx4 s[8:11], s[4:5], 0
|
|
|
+ 0xFA00_0000,
|
|
|
+ ];
|
|
|
+ // v_mov_b32 v1..v4, s0..s3
|
|
|
+ words.extend((0..4u32).map(|i| 0x7E00_0200 | (i + 1) << 17 | i));
|
|
|
+ words.extend_from_slice(body);
|
|
|
+ words.extend_from_slice(&[
|
|
|
+ 0xE070_0000, // buffer_store_dword v0, off, s[8:11], 0
|
|
|
+ 0x8002_0000,
|
|
|
+ S_ENDPGM,
|
|
|
+ ]);
|
|
|
+ let constants = RootParam {
|
|
|
+ sgprs: 4,
|
|
|
+ ..root(RootType::Constants, 0, 0)
|
|
|
+ };
|
|
|
+ let buffer = UsedResource {
|
|
|
+ kind: ResourceType::Uav,
|
|
|
+ root: RootType::Table,
|
|
|
+ table_offset_dwords: 0,
|
|
|
+ lower_bound: 0,
|
|
|
+ stride: 0,
|
|
|
+ dwords: 4,
|
|
|
+ user_data: 4,
|
|
|
+ slot: 1,
|
|
|
+ };
|
|
|
+ lower_with(
|
|
|
+ &words,
|
|
|
+ vec![constants, root(RootType::Table, 4, 1)],
|
|
|
+ vec![buffer],
|
|
|
+ )
|
|
|
+ .map(|_| ())
|
|
|
+ }
|
|
|
+
|
|
|
+ #[test]
|
|
|
+ fn the_24_bit_multiplies_lower_both_halves() {
|
|
|
+ // VOP2 `op v0, v1, v2`: v_mul_i32_i24 and v_mul_u32_u24 (the low
|
|
|
+ // dword) and v_mul_hi_i32_i24 and v_mul_hi_u32_u24 (the high one).
|
|
|
+ for op in [0x09u32, 0x0A, 0x0B, 0x0C] {
|
|
|
+ let word = op << 25 | 2 << 9 | 0x101;
|
|
|
+ lowers_valu(&[word]).unwrap_or_else(|e| panic!("VOP2 {op:#x}: {e}"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#[test]
|
|
|
fn buffer_cache_invalidations_lower_as_no_ops() {
|
|
|
// MUBUF opcode 0x071/0x072 with no data operand: the title asks the
|
|
|
@@ -12002,6 +12211,16 @@ mod tests {
|
|
|
assert!(lowers(&[0xE1C8_0000, 0, S_ENDPGM], 0).is_ok(), "buffer_gl1_inv");
|
|
|
}
|
|
|
|
|
|
+ #[test]
|
|
|
+ fn sums_of_absolute_differences_lower() {
|
|
|
+ // VOP3 `op v0, v1, v2, v3`: v_sad_u8, v_sad_hi_u8, v_sad_u16,
|
|
|
+ // v_sad_u32 and v_msad_u8.
|
|
|
+ for op in [0x15Au32, 0x15B, 0x15C, 0x15D, 0x171] {
|
|
|
+ let words = [0xD400_0000 | op << 16, 0x101 | 0x102 << 9 | 0x103 << 18];
|
|
|
+ lowers_valu(&words).unwrap_or_else(|e| panic!("VOP3 {op:#x}: {e}"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#[test]
|
|
|
fn a_scalar_carry_chain_reaches_the_select() {
|
|
|
// The high dword of a 64-bit add or subtract, then a select on the
|