Closed candymate closed 7 months ago
I'm not sure which side contains the problem. (RISC-V vs. all the other architectures). According to the WebAssembly specifications, both results look fine. However, I expected cranelift_nan_canonicalization
flag to canonicalize the NaN value computed from f32.demote_f64
.
Specifications:
Thanks, as always, for the report!
The NaN canonicalization pass in cranelift has an allow-listed set of opcodes which get a canonicalization sequence inserted and demotion is not one of those. I believe the correct answer pops out on risc-v because risc-v doesn't need nan canonicalization as it natively does it, but that explains why the other platforms are in error here.
Looks like we need to add another opcode to that list...
Test Case
Steps to reproduce
Compare the following executions:
QEMU run options I'm currently using are the following:
Expected Results
Results from x64, aarch64, and s390x should be the value
0x7fc00000
(or0xffc00000
) due to NaN canonicalizationActual Results
Execution results in a wrong value
-528410
, which is0xfff7efe6
However, RISC-V64 shows the correct result
0x7fc00000
, which is a canonicalized NaN value:Versions and Environment
version 8.2.1 (v8.2.1)
Extra Info
f32.demote_f64
is enough to expose the semantic differencecranelift_nan_canonicalization
option doesn't change the resultcranelift_nan_canonicalization
flag, which isfalse
by default.