agourakis82 opened PR #14374 from agourakis82:users/agourakis/cranelift-x64-umin-i128 to bytecodealliance:main:
Summary
The mid-end rewrites
select(icmp ugt/ult/..., a, b)into integer min/max. On x86_64 those forms were only lowered forfits_in_64, so optimized i128 code hit:Unsupported feature: should be implemented in ISLE: inst = umin.i128 ...Fix
Lower
umin/umax/smin/smaxfor$I128through the existing i128emit_cmp+lower_selectpath (same shape as AArch64's scalar-int lowering).Test plan
- New compile coverage:
isa/x64/iminmax-i128.clif(includes the #13790 select→umin case)- New runtest:
runtests/issue-13790-umin-i128.clif- Extended:
runtests/i128-min-max.clifnow includestarget x86_64Fixes #13790
AI assistance
Developed with AI tool assistance (Claude Code) under human direction and review. I am the author of record, reviewed the generated diffs before opening the PR, and can answer questions about the change during review.
agourakis82 requested fitzgen for a review on PR #14374.
agourakis82 requested wasmtime-compiler-reviewers for a review on PR #14374.
github-actions[bot] added the label cranelift on PR #14374.
github-actions[bot] added the label cranelift:area:x64 on PR #14374.
agourakis82 commented on PR #14374:
Ready for review — this one is independent of the #14323 region semantics debate.
x64 was missing i128
umin/umax/smin/smaxlowering that the mid-end select→minmax rewrite can produce. Mirrors the AArch64 scalar-int approach via existingemit_cmp+lower_select.
agourakis82 commented on PR #14374:
@fitzgen gentle bump — this one’s unrelated to the region discussion on #14323. Happy to tweak if you’d rather expand mid-end-side instead of adding the i128 lowerings.
agourakis82 edited a comment on PR #14374:
Independent of #14323.
x64 didn’t lower i128 umin/umax/smin/smax; mid-end select→minmax can produce them. Patch adds those lowerings via the existing i128 cmp/select path.
agourakis82 edited PR #14374:
Mid-end select→minmax can produce
umin/umax/smin/smaxon i128. x64 only lowered those forfits_in_64, so optimized code hit an unsupported-ISLE trap (#13790).Adds i128 lowerings through the existing
emit_cmp+lower_selectpath.Tests:
isa/x64/iminmax-i128.clifruntests/issue-13790-umin-i128.clifruntests/i128-min-max.clifnow includes x86_64Fixes #13790
Assisted-by: Claude
alexcrichton commented on PR #14374:
@agourakis82 please turn down the frequency to which you post and comment on things. It's been 13 hours since this PR was posted and for most of that we were asleep. This is an open source project and we can't respond to PRs immediately, so we ask for patience on your end while time is found to review things.
agourakis82 commented on PR #14374:
Sorry about the noise — I’ll leave it alone and wait for review.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
This comment is not really useful for code readers. The first part is a historical tidbit that is ultimately incidental, and the second is obvious for ISLE code.
:speech_balloon: fitzgen created PR review comment:
Let's make this
test compile precise-outputand re-bless. As currently written this is doing nothing other than ensuring that the programs compile successfully. It is not actually checking that the relevant lowerings or rewrites happen and are reflected in the output.
:speech_balloon: fitzgen created PR review comment:
Can you enable all runtest ISAs for this, since the test is not x86-64 specific? And maybe test it for a handful of different inputs (as function parameters) instead of hard-coding constants in the function body.
Also this comment is not really useful. It needs to be lowerable everywhere, not just x64, where there happened to be a bug. Please do a better job of cleaning up LLM comments, here and elsewhere, and now and in the future. Making maintainers do that for you is not a good use of maintainer time.
agourakis82 commented on PR #14374:
Addressed the review notes: removed the incidental comments, blessed
precise-outputon the x64 compile test, and broadened the runtest to the other ISAs with parameterized inputs.
agourakis82 updated PR #14374.
:memo: agourakis82 submitted PR review.
:speech_balloon: agourakis82 created PR review comment:
Sorry...doing my best!
dustinCodes84600 commented on PR #14374:
I hit this same unsupported-ISLE path in a Cranelift embedding that emits i128 compare/select pairs on x86_64 with
speed_and_size. Mid-end conversion touminmade it behave differently from aarch64, so direct lowering plus shared runtime coverage matters for that setup.also made a visual walkthrough while reading through the diff: https://flyovers.dev/flyover/6e577e4e-f061-4bf8-a95b-ad4a68c3eadc
:thumbs_up: fitzgen submitted PR review:
Thanks!
fitzgen added PR #14374 cranelift: lower i128 umin/umax/smin/smax on x86_64 to the merge queue.
:check: fitzgen merged PR #14374.
fitzgen removed PR #14374 cranelift: lower i128 umin/umax/smin/smax on x86_64 from the merge queue.
Last updated: Oct 11 2026 at 04:10 UTC