Closed cuviper closed 1 month ago
-Zmir-opt-level=2
without -Copt-level=1
reproduces this too. Looks like
v3 = icmp_imm eq v2, 0x8000_0000_0000_0000
gets legalized to
v12 = iconst.i64 0x8000_0000_0000_0000
v13 = sextend.i128 v12 ; v12 = 0x8000_0000_0000_0000
v3 = icmp eq v2, v13
which is to be expected as immediates in clif ir are signed. The problem is that cranelift_frontend::switch::icmp_imm_u128
uses icmp_imm
here despite the value to check against not fitting in an i64.
https://github.com/bytecodealliance/wasmtime/pull/8422 fixes this bug.
Fixed with the latest Cranelift release.
This little program is fine with opt 0, but fails with opt 1.
Note that this constant could fit in
u64
, but it looks like it's sign-extending that%r8
MSB into%rcx
:The closure properly zeros the top half instead: