From 99e781483676c8e1cb4d056f9d1453159a0dc5c6 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sat, 2 May 2026 13:51:43 +0200 Subject: [PATCH] test(cpu): PPCBUG-022 verify mulld_ov INT_MIN*-1 + auto-resolved markers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 6 batch 4 — overflow/cleanup verification. - PPCBUG-022 mulld_ov INT_MIN * -1: the audit-claimed missing edge case is actually handled by `i64::checked_mul()` (returns None when the result would be -i64::MIN = i64::MAX+1, which doesn't fit). New regression tests in overflow.rs confirm: INT_MIN * -1 overflows; INT_MIN * 1 doesn't; (INT_MIN+1) * -1 = INT_MAX, no overflow. Audit's claim was incorrect; documented by the new tests. - PPCBUG-021 (overflow.rs OE checks at bit 63): largely auto-resolved by P4 batch 6 (16993bb), which switched all 32-bit ABI ops to inline `true_sum != (result32 as i32) as i128`. Helpers like add_ov_64 are now only called from 64-bit ABI ops where bit-63 is correct. - PPCBUG-027 (rlwimix upper-32 zeros): auto-resolved by P4 (rlwimix now writes via `as u32 as u64` truncation). - PPCBUG-039 (cntlzdx 32-bit-ABI): wontfix per audit — only matters if a 32-bit-ABI binary emits cntlzd, which compilers don't. Remaining low-impact items (PPCBUG-642 ISA-undefined fmt_bcctr decr, PPCBUG-643/644 SIMM/D-form hex display, PPCBUG-367/368 vupkhpx/vpkpx channel ordering, PPCBUG-487/495 vsum operand naming, PPCBUG-515/516 lvebx/lvsr documentation, PPCBUG-601 decode_op6 invariant doc) are left for a P9 or follow-up batch — they're cosmetic/test-coverage items rather than correctness bugs. Co-Authored-By: Claude Sonnet 4.6 --- crates/xenia-cpu/src/overflow.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/xenia-cpu/src/overflow.rs b/crates/xenia-cpu/src/overflow.rs index a55f505..79bba9c 100644 --- a/crates/xenia-cpu/src/overflow.rs +++ b/crates/xenia-cpu/src/overflow.rs @@ -162,6 +162,11 @@ mod tests { fn mulld_overflows() { assert!(mulld_ov(i64::MAX, 2)); assert!(!mulld_ov(i64::MAX, 1)); + // PPCBUG-022: INT_MIN * -1 overflows (=-INT_MIN > INT_MAX). + // checked_mul correctly returns None for this case. + assert!(mulld_ov(i64::MIN, -1), "INT_MIN * -1 overflows i64"); + assert!(!mulld_ov(i64::MIN, 1)); + assert!(!mulld_ov(i64::MIN + 1, -1), "INT_MIN+1 * -1 = INT_MAX, no overflow"); } #[test]