From 72bf5f7e329e7a25cfa2c15046d6792b84aca3e1 Mon Sep 17 00:00:00 2001 From: elforeign <324243036+elforeign@users.noreply.github.com> Date: Tue, 24 Nov 2026 04:55:45 -0600 Subject: [PATCH] validation: VOP2 integer review gaps: reserved SRC0, literal under empty EXEC, VCC under partial EXEC (#215) A Codex review found three ways a defective interpreter would still pass: selectors 209-232 were never refused (a negative inline range one too long passed), the literal was never decoded with EXEC = 0, and VCC was only checked under full EXEC, so a VCC write limited to active lanes went unseen. Each now has cases; a reference accepting selector 209 and one ANDing VCC_LO with EXEC were both shown failing. Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com> --- tests/validation/tests/vop2_integer.rs | 49 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/tests/validation/tests/vop2_integer.rs b/tests/validation/tests/vop2_integer.rs index ab1484f..b112302 100644 --- a/tests/validation/tests/vop2_integer.rs +++ b/tests/validation/tests/vop2_integer.rs @@ -246,15 +246,15 @@ const COUNTS: [(&str, usize); 11] = [ ("vop2 sgpr source", 12 * 2 * 3), ("vop2 vcc_lo source", 12 * 3), ("vop2 max register", 12 * 3), - ("vop2 exec", 12 * (7 + 2)), + ("vop2 exec", 12 * (7 + 3)), ("vop2 partial wave", 12 * 3), - ("vop2 no vcc or scc write", 12 * 4), + ("vop2 no vcc or scc write", 12 * 5), ]; /// Per form: a missing literal, 9 float inline constants, 8 other special -/// SRC0 selectors, SDWA, DPP16 and two DPP8 forms, and the VOP3 form with +/// SRC0 selectors, the 24 reserved selectors 209-232, SDWA, DPP16 and two DPP8 forms, and the VOP3 form with /// clamp; and for each form but ADD_NC (whose plain VOP3 form is supported /// already) the plain VOP3 form. -const REJECTIONS: usize = 12 * (1 + 9 + 8 + 4 + 1) + 11; +const REJECTIONS: usize = 12 * (1 + 9 + 8 + 24 + 4 + 1) + 11; const LITERAL: u32 = 255; const VCC_LO: u32 = 106; @@ -516,14 +516,17 @@ fn cases() -> Vec { cases.push(case(entry, family, label, code, lanes(), |n, x| { masked(exec, n, f(value, x), x ^ OLD) })); - let mut before = setup.clone(); - before.extend(smov(126, exec)); - let alu = [vop2(op, 2, LITERAL, 1), value]; - let code = program(&before, &alu, &[FULL_EXEC], 2); - let label = format!("exec {exec:#x}, literal {value:#x}, v1"); - cases.push(case(entry, family, label, code, lanes(), |n, x| { - masked(exec, n, f(value, x), x ^ OLD) - })); + // The literal also under empty EXEC: its dword is still consumed. + for exec in [exec, 0] { + let mut before = setup.clone(); + before.extend(smov(126, exec)); + let alu = [vop2(op, 2, LITERAL, 1), value]; + let code = program(&before, &alu, &[FULL_EXEC], 2); + let label = format!("exec {exec:#x}, literal {value:#x}, v1"); + cases.push(case(entry, family, label, code, lanes(), |n, x| { + masked(exec, n, f(value, x), x ^ OLD) + })); + } // A final wave with absent lanes: 7 lanes, and 45 lanes (one full wave // and 13 lanes), also with partial EXEC in both waves. let family = "vop2 partial wave"; @@ -571,6 +574,22 @@ fn cases() -> Vec { })); } } + // The same under partial EXEC with SCC = 1 and VCC_LO bits both inside + // and outside EXEC, so a VCC write limited to active lanes also shows. + let (exec, vcc) = (0x0f0f_0f0f, 0x0000_00f3); + let mut before = setup.clone(); + before.extend(vmov(3, b)); + before.extend(smov(VCC_LO, vcc)); + before.push(SCC_SET); + before.extend(smov(126, exec)); + let mut after = vec![FULL_EXEC]; + after.extend(FLAG_TAIL); + let code = program(&before, &[vop2(op, 2, vgpr(1), 3)], &after, 2); + let label = format!("exec {exec:#x}, vcc_lo {vcc:#x}, scc true"); + let family = "vop2 no vcc or scc write"; + cases.push(case(entry, family, label, code, lanes(), |n, x| { + masked(exec, n, f(x, b), x ^ OLD) ^ vcc ^ x + })); } cases } @@ -588,8 +607,10 @@ fn rejections() -> Vec<(String, Vec, usize)> { code.push(vop2(op, 2, LITERAL, 1)); all.push((format!("{name} missing literal"), words(&code), offset)); // Float inline constants 240-248 (0.5 to -4.0 and 1/(2*pi)), VCC_HI, - // M0, NULL, EXEC_LO, EXEC_HI, VCCZ, EXECZ and SCC as SRC0. - for src0 in (240..=248).chain([107, 124, 125, 126, 127, 251, 252, 253]) { + // M0, NULL, EXEC_LO, EXEC_HI, VCCZ, EXECZ and SCC (outside the + // supported SRC0 subset), and the reserved selectors 209-232. + let special = [107, 124, 125, 126, 127, 251, 252, 253]; + for src0 in (240..=248).chain(special).chain(209..=232) { let code = program(&setup, &[vop2(op, 2, src0, 1)], &[], 2); all.push((format!("{name} src0 {src0}"), code, offset)); }