Stream: git-wasmtime

Topic: wasmtime / issue #1106 icmp_imm implemented incorrectly f...


view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 20:57):

cfallin commented on issue #1106:

@bjorn3 I suspect this may be fixed now with the new backend, can you verify?

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2022 at 10:47):

bjorn3 commented on issue #1106:

function %foo() -> b1 {
block0:
    v0 = iconst.i8 -128
    v1 = iconst.i8 -128
    v2 = icmp ne v0, v1
    return v2
}
; run: %foo() == false

now works on x86_64. It compiles to

   0:   55                      push    rbp
   1:   48 89 e5                mov     rbp, rsp
   4:   bf 80 ff ff ff          mov     edi, 0xffffff80
   9:   40 80 ff 80             cmp     dil, 0x80
   d:   40 0f 95 c0             setne   al
  11:   48 89 ec                mov     rsp, rbp
  14:   5d                      pop     rbp
  15:   c3                      ret

And so does

function %foo() -> b1 {
block0:
    v0 = iconst.i8 128
    v1 = iconst.i8 -128
    v2 = icmp ne v0, v1
    return v2
}
; run: %foo() == false

which compiles to

   0:   55                      push    rbp
   1:   48 89 e5                mov     rbp, rsp
   4:   bf 80 00 00 00          mov     edi, 0x80
   9:   40 80 ff 80             cmp     dil, 0x80
   d:   40 0f 95 c0             setne   al
  11:   48 89 ec                mov     rsp, rbp
  14:   5d                      pop     rbp
  15:   c3                      ret

Both are expected.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2022 at 10:47):

bjorn3 closed issue #1106:

https://github.com/CraneStation/cranelift/blob/57fa45c8520110ee7e9b216538f1990376aed0e9/cranelift-codegen/meta/src/shared/legalize.rs#L434-L435

For example

v0 = iconst.i8 -128
v1 = iconst.i8 -128
v2 = icmp ne v0, v1

gets turned into:

v7 = iconst.i32 -128
v0 = ireduce.i8 v7
v9 = uextend.i32 v0
v2 = icmp_imm ne v9, -128

Which is equal to:

v9 = iconst.i32 128
v2 = icmp_imm ne v9, -128

That is obviously false.


Last updated: Nov 22 2024 at 16:03 UTC