zzjas opened issue #12336:
.clifTest Casetest compile set enable_nan_canonicalization=true target s390x function %fadd_f128(i64, f128, f128) { block0(v0: i64, v1: f128, v2: f128): v3 = fadd v1, v2 store v3, v0 return }Steps to Reproduce
RUST_BACKTRACE=1 cargo run -p cranelift-tools -- test test.clifExpected Results
No crash
Actual Results
thread 'worker #0' (2560515) panicked at cranelift/codegen/src/nan_canonicalization.rs:121:13: Could not canonicalize NaN: Unexpected result type found.Versions and Environment
Cranelift version or commit: e82a7abfd3e88145450a5465def20f6781e0eb65
Extra Info
F16 (on RISC-V with zfh) and F128 (on s390x) are valid floating-point types that pass the
is_fp_arith()check innan_canonicalization.rsbut fall through to the panic inadd_nan_canon_seq():Adding the following arm will fix the F128 for s390x:
types::F128 => { let nan_const = pos.func.dfg.constants.insert(Ieee128::NAN.into()); let canon_nan = pos.ins().f128const(nan_const); scalar_select(pos, canon_nan); }I'm not sure if F16 needs to be fixed because of #7322.
Thanks for looking into this and I'm happy to submit a PR if the fix to F128 looks ok.
zzjas added the bug label to Issue #12336.
zzjas added the cranelift label to Issue #12336.
alexcrichton commented on issue #12336:
I think it'd be reasonable to add support to the
nan_canonicalization.rspass for this yeah, and if you're willing to make a PR that'd be much appreciated!
zzjas commented on issue #12336:
Happy to make a PR! Just to confirm, do you think just fixing for F128 is enough or would it better to fix for both F128 and F16? Thanks!
alexcrichton commented on issue #12336:
I'd personally leave that call to you as a subjective balance between implementation complexity and how motivated you are. Cranelift is probably going to have somewhat patchy support for f16/f128 for awhile unless a particularly motivated contributor comes by, so the exact state of support to me I think is fine with whatever so long as it's incrementally moving forward
cfallin closed issue #12336:
.clifTest Casetest compile set enable_nan_canonicalization=true target s390x function %fadd_f128(i64, f128, f128) { block0(v0: i64, v1: f128, v2: f128): v3 = fadd v1, v2 store v3, v0 return }Steps to Reproduce
RUST_BACKTRACE=1 cargo run -p cranelift-tools -- test test.clifExpected Results
No crash
Actual Results
thread 'worker #0' (2560515) panicked at cranelift/codegen/src/nan_canonicalization.rs:121:13: Could not canonicalize NaN: Unexpected result type found.Versions and Environment
Cranelift version or commit: e82a7abfd3e88145450a5465def20f6781e0eb65
Extra Info
F16 (on RISC-V with zfh) and F128 (on s390x) are valid floating-point types that pass the
is_fp_arith()check innan_canonicalization.rsbut fall through to the panic inadd_nan_canon_seq():Adding the following arm will fix the F128 for s390x:
types::F128 => { let nan_const = pos.func.dfg.constants.insert(Ieee128::NAN.into()); let canon_nan = pos.ins().f128const(nan_const); scalar_select(pos, canon_nan); }I'm not sure if F16 needs to be fixed because of #7322.
Thanks for looking into this and I'm happy to submit a PR if the fix to F128 looks ok.
Last updated: Jan 29 2026 at 13:25 UTC