Skip to content

test(relinker): execute the moved scalar compare - #9184

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
javierUDP:test/scalar-compare-execution
Oct 25, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
javierUDP:test/scalar-compare-execution

Conversation

@javierUDP

Copy link
Copy Markdown
Contributor

What

--to-rosetta moves a hazard scalar compare out of line, because of the Rosetta 2 bug in #5642 where a later scalar read sees the compare mask instead of a 128-bit load that followed it. The stub is checked through its bytes, but it is never executed, so nothing confirms that the compare still produces the mask it would produce inline once it sits in a stub.

The execution section now calls the stub for cmpss $5, %xmm1, %xmm0 (NLT, one of the predicates the split covers) with both outcomes, 309 against 309 and 309 against 310, and checks the destination's low lane and that the upper three lanes are untouched.

Tested

Apple M5, macOS 26.4, AppleClang 21.0.0, relinker-only build of current main.

  • -DCMAKE_OSX_ARCHITECTURES=x86_64, executed under Rosetta: 229/229.
  • Native arm64: 229/229; the section is x86-64 only and stays out of the build.
  • Control: inverting the mask comparison fails the run with that assertion's message, so the stub really executes. Reverting restores the pass.
  • python3 tools/check_conventions.py --base origin/main passes.

One thing I could not establish: I wrote the #5642 repro as a small C program with inline asm and it printed the loaded value on this host, so the hazard did not show. That is not evidence the bug is gone — the shape depends on what lands in one translated block, and a hand-written repro may simply not reproduce it — so I am not drawing a conclusion from it. This test checks the stub's result, not the hazard.

No Linux or Windows host was available; the section also builds there.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file: n/a, test-only change
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: n/a
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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 8042 core/relinker/codegen/tests/Amd64OnlyConverterTests.cpp

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent run on Apple silicon under Rosetta 2, not covered in the thread yet.

Apple M2 Max, macOS 27.2 (26B5091g), Apple clang, CMake 4.4.4, Ninja, relinker-only Release build. Head cdd79f9c6 merged onto current main 0c6a5bd59 (clean). Built arm64 and x86-64 (-DCMAKE_OSX_ARCHITECTURES=x86_64 -DPython3_EXECUTABLE=/usr/bin/python3, Python 3.9.6).

  • x86-64 under Rosetta: amd64_only_converter passes. scalarCompareExecution runs the converted CMPSS trampoline as real code and gets the expected mask for both cases (309 vs 309 -> 0, 309 vs 310 -> 0xFFFFFFFF), with the upper three lanes of the destination preserved.
  • arm64: compiles (the execution is an __x86_64__-only no-op) and amd64_only_converter passes.
  • Pure test addition, so it also passes on main; the value here is the Rosetta execution on an Apple host.

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

@MarcZX10 MarcZX10 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a focused test-only follow-up to the already-merged #5683 fix. The new test executes the generated trampoline for both outcomes and verifies the upper XMM lanes remain unchanged. The PR reports successful Linux, Windows, macOS native and macOS x86-64-under-Rosetta CI; the hosted Rosetta run is the key platform-specific check, and an independent M2 Max reviewer also confirmed it. I could not run Rosetta locally in this Linux environment. I manually inspected the shared-file overlap warnings: #7918 adds XSAVEOPT cases in separate test functions/registration points, and #8042 adds scanner-resynchronization cases. Neither duplicates or edits this PR's scalar-compare test. Their branches currently conflict with main, so refresh the generated overlap report after the required base update. The branch is 633 commits behind current upstream main (1 ahead); CONTRIBUTING requires keeping PR branches current. Please rebase/update, rerun the relinker checks, and regenerate the overlap report against current main. The hosted conventions, eligibility, intake, labels, Linux/Windows/macOS relinker and ASan checks all pass. The merge-tree is clean, and my local current-main convention/diff checks pass. I found no correctness problem in the test itself; I’m requesting changes for the stale base and overlap validation.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

@MarcZX10

Copy link
Copy Markdown
Contributor

I’ve noticed that my earlier request to hold this PR based on #5239 was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. Please disregard that request.

The stub that moves a hazard scalar compare out of line is checked
through its bytes but never run, so nothing confirms that the compare
still produces the mask it would inline. The x86-64 execution section
now calls the stub for both outcomes of a CMPSS with an unsafe predicate
and checks the destination's lanes.
@adriadam10
adriadam10 force-pushed the test/scalar-compare-execution branch from cdd79f9 to 65a98e7 Compare October 25, 2026 10:30
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 15:18

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit 6bc1139 into boykopovar:main Oct 25, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the CMPSS NLT expectations (309 vs 309 -> all ones, 309 vs 310 -> 0, upper lanes untouched) on the head rebased onto main; relinker CI green including macOS x86_64 under Rosetta, and the earlier hold request was withdrawn; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants