dsecurity49 opened PR #14238 from dsecurity49:fix-aarch64-scalar-size-f16-f128 to bytecodealliance:main:
Summary
In
cranelift/codegen/src/isa/aarch64/inst.isle,scalar_sizeis declared as a total term:(decl scalar_size (Type) ScalarSize)It defined rules for integer types (
I8..I128) andF32/F64, but omittedF16andF128.When ISLE lowering rules (such as
fma.f16) passed anF16orF128type toscalar_size, the Cranelift compiler panicked with an internal ISLE error:thread 'worker' panicked at out/isle_aarch64.rs:3755:5: internal error: entered unreachable code: no rule matched for term scalar_size at src/isa/aarch64/inst.isle line 1587; should it be partial?Fix
Add the missing ISLE rules for
F16andF128:(rule (scalar_size $F16) (ScalarSize.Size16)) (rule (scalar_size $F128) (ScalarSize.Size128))Testing
Added
cranelift/filetests/filetests/isa/aarch64/fma-f16.clifand verified natively on AArch64 hardware:$ ./target/debug/clif-util test ./cranelift/filetests/filetests/isa/aarch64/fma-f16.clif 1 tests
dsecurity49 requested cfallin for a review on PR #14238.
dsecurity49 requested wasmtime-compiler-reviewers for a review on PR #14238.
dsecurity49 updated PR #14238.
dsecurity49 updated PR #14238.
github-actions[bot] added the label cranelift on PR #14238.
github-actions[bot] added the label cranelift:area:aarch64 on PR #14238.
dsecurity49 edited PR #14238:
Add missing
F16andF128rules toscalar_sizeininst.isle, as well as their corresponding models inprelude.isle.Without these, rules that pass
f16orf128types toscalar_size(likefma.f16) trigger an ISLE panic becausescalar_sizeis a total term.
:speech_balloon: cfallin created PR review comment:
We usually have compile-tests with the
precise-outputflag to show (and lock down) the actual compilation output. Could you include that here? And could you add something forf128as well if aarch64 has lowerings for it (I don't remember if it does)?
:memo: cfallin submitted PR review.
:memo: dsecurity49 submitted PR review.
:speech_balloon: dsecurity49 created PR review comment:
I've updated the AArch64 specific test to use test compile precise output to lock down the generated assembly sequence, and added target aarch64 to the existing runtests/i128-bitselect.clif runtest.
:speech_balloon: dsecurity49 deleted PR review comment.
dsecurity49 updated PR #14238.
:memo: dsecurity49 submitted PR review.
:speech_balloon: dsecurity49 created PR review comment:
Updated the f16 test to precise-output (emits fmadd h0, h0, h1, h2 as expected).
For f128: there are no native 128-bit float instructions on AArch64, so it would need softfloat libcalls (__addtf3, __fmatf3, etc.) which cranelift doesn't have on any backend yet, even x64 only handles f128const.For now I kept the scalar_size rule for F128 since it prevents a confusing panic, but happy to drop it if you'd prefer to keep this minimal.
dsecurity49 updated PR #14238.
:memo: dsecurity49 submitted PR review.
:speech_balloon: dsecurity49 created PR review comment:
After checking further, keeping the F128 rule would be misleading,f128 arithmetic hits unexpected scalar FP operand size (size128)deeper in the backend anyway, so the scalar_size rule for it is effectively dead code. I've removed it and the corresponding model from prelude.isle, keeping only the F16 fix.
:thumbs_up: cfallin submitted PR review.
cfallin added PR #14238 aarch64: add missing F16 and F128 rules for scalar_size in ISLE to the merge queue.
:check: cfallin merged PR #14238.
cfallin removed PR #14238 aarch64: add missing F16 and F128 rules for scalar_size in ISLE from the merge queue.
Last updated: Sep 20 2026 at 18:08 UTC