fix(relinker): lower ANDN in Rosetta conversion #5784

Merged
gguerra26 merged 1 commit from upstream-pr/5784 into main 2026-10-15 17:25:07 +00:00
gguerra26 commented 2026-10-14 10:43:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gguerra26 on 2026-10-14T10:43:26Z.


What

Balatro (PPSA21402, discussion #1142) stops in its bundled libc initializer on andnq %rsi, %rcx, %rax under Rosetta on an Apple M1 running macOS 15.3.1. A standalone x86-64 ANDN program reproduces SIGILL without game files. --to-rosetta previously left ANDN unchanged.

Lower 32- and 64-bit ANDN register and memory forms to scalar NOT/AND sequences. Preserve source and scratch registers, the caller's red zone, stack-relative addressing, RIP-relative operands, and the defined status flags. Plain conversion and --to-intel keep ANDN unchanged. Invalid VEX forms and a stack displacement that cannot accommodate the spill frame fail explicitly.

Semantics follow the ANDN entry in Intel SDM volume 2A. The documentation now distinguishes the earlier M5 Max observations from the instruction support observed on this M1.

Tested

  • Apple M1, macOS 15.3.1 (24D70), Apple clang 17: all 150 relinker-only tests pass, including ELF/Mach-O conversion coverage for ANDN.
  • A separate x86-64 build executes the generated lowering through Rosetta: 32/64-bit results, defined flags, register aliases, RSP source/destination, indirect/SIB/stack/RIP-relative memory, scratch registers and the red zone. Decoder coverage checks every destination/source register combination. Execution test completes in about 1.5 seconds.
  • Balatro 01.015.000 reconverts successfully and progresses past the original ANDN stop. Its next stop is shlxq %rax, %rdx, %r8, another unsupported instruction. This PR does not establish playability or FPS.
  • The game test used runtime libraries from mugurc/AnyPS5 macos-port at b7eb6b6b515c6163b6a0a6dd09b630a0414a0149, with the local Apple SDK input-number parsing build fix. The relinker is built from this upstream-based branch.
  • Repository conventions and git diff --check pass. Linux/Windows execution has not been run locally; their existing CI can exercise the portable conversion checks, and Linux x86-64 also executes the lowering test.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files, images, game files or logs added to the repository
  • No new third-party dependencies
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA21402 #1142 (the ANDN startup stop only)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4856664130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784). Originally posted by [gguerra26](https://github.com/gguerra26) on 2026-10-14T10:43:26Z. --- ### What Balatro (PPSA21402, discussion #1142) stops in its bundled libc initializer on `andnq %rsi, %rcx, %rax` under Rosetta on an Apple M1 running macOS 15.3.1. A standalone x86-64 ANDN program reproduces SIGILL without game files. `--to-rosetta` previously left ANDN unchanged. Lower 32- and 64-bit ANDN register and memory forms to scalar NOT/AND sequences. Preserve source and scratch registers, the caller's red zone, stack-relative addressing, RIP-relative operands, and the defined status flags. Plain conversion and `--to-intel` keep ANDN unchanged. Invalid VEX forms and a stack displacement that cannot accommodate the spill frame fail explicitly. Semantics follow the ANDN entry in [Intel SDM volume 2A](https://cdrdv2-public.intel.com/812383/253666-sdm-vol-2a.pdf). The documentation now distinguishes the earlier M5 Max observations from the instruction support observed on this M1. ### Tested - Apple M1, macOS 15.3.1 (24D70), Apple clang 17: all 150 relinker-only tests pass, including ELF/Mach-O conversion coverage for ANDN. - A separate x86-64 build executes the generated lowering through Rosetta: 32/64-bit results, defined flags, register aliases, RSP source/destination, indirect/SIB/stack/RIP-relative memory, scratch registers and the red zone. Decoder coverage checks every destination/source register combination. Execution test completes in about 1.5 seconds. - Balatro 01.015.000 reconverts successfully and progresses past the original ANDN stop. Its next stop is `shlxq %rax, %rdx, %r8`, another unsupported instruction. This PR does not establish playability or FPS. - The game test used runtime libraries from mugurc/AnyPS5 `macos-port` at `b7eb6b6b515c6163b6a0a6dd09b630a0414a0149`, with the local Apple SDK input-number parsing build fix. The relinker is built from this upstream-based branch. - Repository conventions and `git diff --check` pass. Linux/Windows execution has not been run locally; their existing CI can exercise the portable conversion checks, and Linux x86-64 also executes the lowering test. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation files, images, game files or logs added to the repository - [x] No new third-party dependencies - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA21402 #1142 (the ANDN startup stop only) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-14 10:52:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T10:52:26Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 5990 docs/dev/debt/relinker.md L22

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3891 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4156 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4396 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4397 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4422 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4423 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4424 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4520 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4521 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4522 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4523 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4566 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4599 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4718 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4740 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4749 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4760 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4813 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 4891 docs/user/USAGE.md
PR 5021 core/relinker/CMakeLists.txt
docs/dev/debt/libkernel.md
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 5835 docs/dev/debt/libkernel.md
docs/user/USAGE.md
PR 5925 docs/user/USAGE.md
PR 5993 docs/dev/debt/libkernel.md
PR 6044 core/relinker/CMakeLists.txt
PR 6111 core/relinker/codegen/src/x86/Amd64OnlyInstructionMatcher.cpp
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 6112 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
PR 6222 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6166702109 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6166702109). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T10:52:26Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 5990](https://www.github.com/boykopovar/AnyPS5/pull/5990) | `docs/dev/debt/relinker.md` [L22](https://github.com/boykopovar/AnyPS5/blob/0e6a5e7a5c0817fb0219d5d5c8707c25d915dbd5/docs/dev/debt/relinker.md#L22) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 3891](https://www.github.com/boykopovar/AnyPS5/pull/3891) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4156](https://www.github.com/boykopovar/AnyPS5/pull/4156) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4396](https://www.github.com/boykopovar/AnyPS5/pull/4396) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4397](https://www.github.com/boykopovar/AnyPS5/pull/4397) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4422](https://www.github.com/boykopovar/AnyPS5/pull/4422) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4423](https://www.github.com/boykopovar/AnyPS5/pull/4423) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4424](https://www.github.com/boykopovar/AnyPS5/pull/4424) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4520](https://www.github.com/boykopovar/AnyPS5/pull/4520) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4521](https://www.github.com/boykopovar/AnyPS5/pull/4521) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4522](https://www.github.com/boykopovar/AnyPS5/pull/4522) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4523](https://www.github.com/boykopovar/AnyPS5/pull/4523) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4566](https://www.github.com/boykopovar/AnyPS5/pull/4566) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4599](https://www.github.com/boykopovar/AnyPS5/pull/4599) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4718](https://www.github.com/boykopovar/AnyPS5/pull/4718) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4740](https://www.github.com/boykopovar/AnyPS5/pull/4740) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4749](https://www.github.com/boykopovar/AnyPS5/pull/4749) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4760](https://www.github.com/boykopovar/AnyPS5/pull/4760) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4813](https://www.github.com/boykopovar/AnyPS5/pull/4813) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `docs/user/USAGE.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 5835](https://www.github.com/boykopovar/AnyPS5/pull/5835) | `docs/dev/debt/libkernel.md`<br>`docs/user/USAGE.md` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `docs/user/USAGE.md` | | [PR 5993](https://www.github.com/boykopovar/AnyPS5/pull/5993) | `docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/relinker/CMakeLists.txt` | | [PR 6111](https://www.github.com/boykopovar/AnyPS5/pull/6111) | `core/relinker/codegen/src/x86/Amd64OnlyInstructionMatcher.cpp`<br>`docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 6112](https://www.github.com/boykopovar/AnyPS5/pull/6112) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/relinker.md` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `docs/dev/debt/libkernel.md` |
jotitadev commented 2026-10-14 14:54:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T14:54:11Z.


Measured on a different Apple silicon machine: M2 Max, macOS 27.2 (26B5091g).

Relinker-only build of this branch (9acd5dcc0)

  • arm64 build: 150/150 tests pass.
  • x86_64 build (-DCMAKE_OSX_ARCHITECTURES=x86_64) under Rosetta: 150/150 tests pass with --timeout 30, including andn_lowering.

ANDN and the next stop (shlxq) on this machine

Neither stop reproduces here. A standalone x86-64 program runs each instruction in a child process and compares the result with a reference computed natively on arm64. The following run without SIGILL and return the reference result, with and without ROSETTA_ADVERTISE_AVX=1:

  • BMI1: ANDN, BEXTR, BLSI, BLSR, BLSMSK, TZCNT
  • BMI2: SHLX, SHRX, SARX (32/64-bit, register and memory sources), RORX, BZHI, PDEP, PEXT, MULX
  • LZCNT, POPCNT, MOVBE, FMA3, F16C

On this machine ADCX/ADOX, RDSEED, RDPID, CLWB, SHA, SSE4a, XSAVEOPT and XSAVEC raise SIGILL.

CPUID leaf 7 under Rosetta reports BMI1=0, BMI2=0 and AVX2=0 by default, and all three as 1 with ROSETTA_ADVERTISE_AVX=1. Whether these instructions execute therefore seems to depend on the macOS / Rosetta version rather than on what CPUID advertises: ANDN faults on M1 with macOS 15.3.1 and runs on M2 Max with macOS 27.2. The lowering stays correct on hosts that do execute ANDN.

Written with AI assistance (Claude Code). I ran the builds, tests and measurements above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6171241899 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6171241899). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-14T14:54:11Z. --- Measured on a different Apple silicon machine: M2 Max, macOS 27.2 (26B5091g). ### Relinker-only build of this branch (`9acd5dcc0`) - arm64 build: 150/150 tests pass. - x86_64 build (`-DCMAKE_OSX_ARCHITECTURES=x86_64`) under Rosetta: 150/150 tests pass with `--timeout 30`, including `andn_lowering`. ### ANDN and the next stop (`shlxq`) on this machine Neither stop reproduces here. A standalone x86-64 program runs each instruction in a child process and compares the result with a reference computed natively on arm64. The following run without SIGILL and return the reference result, with and without `ROSETTA_ADVERTISE_AVX=1`: - BMI1: ANDN, BEXTR, BLSI, BLSR, BLSMSK, TZCNT - BMI2: SHLX, SHRX, SARX (32/64-bit, register and memory sources), RORX, BZHI, PDEP, PEXT, MULX - LZCNT, POPCNT, MOVBE, FMA3, F16C On this machine ADCX/ADOX, RDSEED, RDPID, CLWB, SHA, SSE4a, XSAVEOPT and XSAVEC raise SIGILL. CPUID leaf 7 under Rosetta reports `BMI1=0`, `BMI2=0` and `AVX2=0` by default, and all three as `1` with `ROSETTA_ADVERTISE_AVX=1`. Whether these instructions execute therefore seems to depend on the macOS / Rosetta version rather than on what CPUID advertises: ANDN faults on M1 with macOS 15.3.1 and runs on M2 Max with macOS 27.2. The lowering stays correct on hosts that do execute ANDN. Written with AI assistance (Claude Code). I ran the builds, tests and measurements above on my machine.
011010 commented 2026-10-14 18:31:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-14T18:31:33Z.


Verified on macOS 27.0.1 (26A434), Apple M4, x86-64 under Rosetta 2, Apple clang 21: the relinker-only build passes ctest 150/150, including andn_lowering, which mmaps and executes the lowered sequences. The ANDN lowering holds on macOS 27 as well as the 15.3.1 you reported.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175483441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6175483441). Originally posted by [011010](https://github.com/011010) on 2026-10-14T18:31:33Z. --- Verified on macOS 27.0.1 (26A434), Apple M4, x86-64 under Rosetta 2, Apple clang 21: the relinker-only build passes `ctest` 150/150, including `andn_lowering`, which mmaps and executes the lowered sequences. The ANDN lowering holds on macOS 27 as well as the 15.3.1 you reported.
simonbbby commented 2026-10-14 22:24:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-14T22:24:15Z.


Independent Linux x86-64 execution coverage at exact head 9acd5dcc07d8149020bf50fbd5e09f7633a2613f, standalone on its recorded parent, no other PRs merged.

Ubuntu 24.04, Ryzen 9 9950X, GCC 13.3, Ninja Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON:

  • All 159/159 CTests pass (25.19 s), with no skips reported. andn_lowering, amd64_only_converter and relinker_conversion also pass 3/3 each.
  • The stock ANDN fixture really executes its generated sequences on this Linux x86-64 build; it does not take the non-x86 execution fallback.
  • I extended the fixture locally from its six selected register-pair patterns to all 16 destinations × 16 inverted sources × 16 second sources, both widths, three input patterns: 24,576 register execution cases, plus the existing 12 memory cases (indirect, displacement, stack, SIB and RIP-relative). All pass the existing result, defined-flags, source/scratch preservation and red-zone assertions.
  • HAL supports native ANDN, so I also ran that same expanded fixture with the original ANDN bytes in place of the generated lowering, relocating the RIP-relative instruction to its actual test site. Native ANDN passes the same assertions for all 24,576 register and 12 memory cases. The extended test, exercising both modes, passes three CTest repetitions (0.05–0.06 s each), plus one direct run. These are checks against the fixture's expected semantics in each mode, not a comparison of undefined flags.
  • Matched negative control: restoring only Amd64OnlyInstructionMatcher.cpp from this head's parent, retaining the PR fixture and lowering implementation, makes andn_lowering_tests exit 1 with Rosetta mode did not require an ANDN trampoline. Restoring the PR matcher and the unmodified stock test, rebuilding, then rerunning all three focused fixtures passes; the checkout is clean.

This fills Linux host execution/conversion coverage. No new title run or Rosetta execution claim; the reported title's SIGILL is not reproduced on this AMD host.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179847188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6179847188). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-14T22:24:15Z. --- Independent Linux x86-64 execution coverage at exact head **`9acd5dcc07d8149020bf50fbd5e09f7633a2613f`**, standalone on its recorded parent, no other PRs merged. Ubuntu 24.04, Ryzen 9 9950X, GCC 13.3, Ninja Release, `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`: - All **159/159 CTests pass** (25.19 s), with no skips reported. `andn_lowering`, `amd64_only_converter` and `relinker_conversion` also pass **3/3 each**. - The stock ANDN fixture really executes its generated sequences on this Linux x86-64 build; it does not take the non-x86 execution fallback. - I extended the fixture locally from its six selected register-pair patterns to **all 16 destinations × 16 inverted sources × 16 second sources, both widths, three input patterns**: **24,576 register execution cases**, plus the existing **12 memory cases** (indirect, displacement, stack, SIB and RIP-relative). All pass the existing result, defined-flags, source/scratch preservation and red-zone assertions. - HAL supports native ANDN, so I also ran that same expanded fixture with the original ANDN bytes in place of the generated lowering, relocating the RIP-relative instruction to its actual test site. Native ANDN passes the same assertions for all 24,576 register and 12 memory cases. The extended test, exercising both modes, passes three CTest repetitions (0.05–0.06 s each), plus one direct run. These are checks against the fixture's expected semantics in each mode, not a comparison of undefined flags. - **Matched negative control:** restoring only `Amd64OnlyInstructionMatcher.cpp` from this head's parent, retaining the PR fixture and lowering implementation, makes `andn_lowering_tests` exit 1 with `Rosetta mode did not require an ANDN trampoline`. Restoring the PR matcher and the unmodified stock test, rebuilding, then rerunning all three focused fixtures passes; the checkout is clean. This fills Linux host execution/conversion coverage. No new title run or Rosetta execution claim; the reported title's SIGILL is not reproduced on this AMD host.
JoaoPauloCMarra commented 2026-10-15 10:05:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JoaoPauloCMarra on 2026-10-15T10:05:37Z.


M4 Pro, macOS 27.0.1 (26A434), Apple clang 21, PR head 9acd5dcc0, relinker-only build
ctest 150/150 on arm64 and on an x86_64 build under Rosetta (--timeout 30), including andn_lowering

like the M2 Max run, plain ANDN doesnt fault here. a small x86_64 program that runs the 32 and 64-bit register forms gets the right result under Rosetta, no SIGILL (memory forms not tested)
so far only the M1 on macOS 15.3.1 faults. not sure if its the chip or the OS version, so it might be worth saying in the debt entry that macOS 27 doesnt need the lowering

AI-assisted (Claude Code), I ran all of the above on my machine

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6189553543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6189553543). Originally posted by [JoaoPauloCMarra](https://github.com/JoaoPauloCMarra) on 2026-10-15T10:05:37Z. --- M4 Pro, macOS 27.0.1 (26A434), Apple clang 21, PR head 9acd5dcc0, relinker-only build ctest 150/150 on arm64 and on an x86_64 build under Rosetta (--timeout 30), including andn_lowering like the M2 Max run, plain ANDN doesnt fault here. a small x86_64 program that runs the 32 and 64-bit register forms gets the right result under Rosetta, no SIGILL (memory forms not tested) so far only the M1 on macOS 15.3.1 faults. not sure if its the chip or the OS version, so it might be worth saying in the debt entry that macOS 27 doesnt need the lowering AI-assisted (Claude Code), I ran all of the above on my machine
adriadam10 commented 2026-10-15 13:03:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:03:32Z.


Rebased onto current main (conflict in the core/relinker/CMakeLists.txt source lists with ScalarCompareOperands.cpp; kept both entries, no other change). Relinker scope builds and passes 135/135 ctest, including andn_lowering and to_rosetta. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192720300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5784#issuecomment-6192720300). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T13:03:32Z. --- Rebased onto current `main` (conflict in the `core/relinker/CMakeLists.txt` source lists with `ScalarCompareOperands.cpp`; kept both entries, no other change). Relinker scope builds and passes 135/135 ctest, including `andn_lowering` and `to_rosetta`. Merging once the full Build is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5784
No description provided.