Stream: git-wasmtime

Topic: wasmtime / issue #6312 Cranelift: RISC-V Wrong result for...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 30 2023 at 09:17):

afonso360 opened issue #6312:

:wave: Hey,

Fuzzgen found this today.

.clif Test Case

;; Run test case

test interpret
test run
target riscv64gc

function %a(i64, i64, i128, i128) -> i64, i8 {
block0(v0: i64, v1: i64, v2: i128,  v3: i128):
    v4 = icmp.i128 sle v3, v2
    v6 = select.i64 v4, v1, v0
    return v6, v4
}

; run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0]

Steps to Reproduce

Expected Results

The test to pass

Actual Results

    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/afonso/git/qemu/build/qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 -cpu rv64,v=true,vlen=256,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true /home/afonso/git/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0], actual: [13724266, 0]
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: 8eccc63c46503adbc6ba91034324963b69a7523b (main)

Operating system: Linux

Architecture: RISC-V

Extra Info

<details>
<summary>Disassembly</summary>

Disassembly of 44 bytes:
   0:   93 e8 05 00             ori     a7, a1, 0
   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero
  1c:   63 54 e6 00             bge     a2, a4, 8
  20:   6f 00 80 00             j       8
  24:   13 e5 08 00             ori     a0, a7, 0
  28:   67 80 00 00             ret

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Apr 30 2023 at 09:17):

afonso360 labeled issue #6312:

:wave: Hey,

Fuzzgen found this today.

.clif Test Case

;; Run test case

test interpret
test run
target riscv64gc

function %a(i64, i64, i128, i128) -> i64, i8 {
block0(v0: i64, v1: i64, v2: i128,  v3: i128):
    v4 = icmp.i128 sle v3, v2
    v6 = select.i64 v4, v1, v0
    return v6, v4
}

; run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0]

Steps to Reproduce

Expected Results

The test to pass

Actual Results

    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/afonso/git/qemu/build/qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 -cpu rv64,v=true,vlen=256,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true /home/afonso/git/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0], actual: [13724266, 0]
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: 8eccc63c46503adbc6ba91034324963b69a7523b (main)

Operating system: Linux

Architecture: RISC-V

Extra Info

<details>
<summary>Disassembly</summary>

Disassembly of 44 bytes:
   0:   93 e8 05 00             ori     a7, a1, 0
   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero
  1c:   63 54 e6 00             bge     a2, a4, 8
  20:   6f 00 80 00             j       8
  24:   13 e5 08 00             ori     a0, a7, 0
  28:   67 80 00 00             ret

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Apr 30 2023 at 09:17):

afonso360 labeled issue #6312:

:wave: Hey,

Fuzzgen found this today.

.clif Test Case

;; Run test case

test interpret
test run
target riscv64gc

function %a(i64, i64, i128, i128) -> i64, i8 {
block0(v0: i64, v1: i64, v2: i128,  v3: i128):
    v4 = icmp.i128 sle v3, v2
    v6 = select.i64 v4, v1, v0
    return v6, v4
}

; run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0]

Steps to Reproduce

Expected Results

The test to pass

Actual Results

    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/afonso/git/qemu/build/qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 -cpu rv64,v=true,vlen=256,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true /home/afonso/git/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0], actual: [13724266, 0]
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: 8eccc63c46503adbc6ba91034324963b69a7523b (main)

Operating system: Linux

Architecture: RISC-V

Extra Info

<details>
<summary>Disassembly</summary>

Disassembly of 44 bytes:
   0:   93 e8 05 00             ori     a7, a1, 0
   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero
  1c:   63 54 e6 00             bge     a2, a4, 8
  20:   6f 00 80 00             j       8
  24:   13 e5 08 00             ori     a0, a7, 0
  28:   67 80 00 00             ret

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Apr 30 2023 at 09:17):

afonso360 labeled issue #6312:

:wave: Hey,

Fuzzgen found this today.

.clif Test Case

;; Run test case

test interpret
test run
target riscv64gc

function %a(i64, i64, i128, i128) -> i64, i8 {
block0(v0: i64, v1: i64, v2: i128,  v3: i128):
    v4 = icmp.i128 sle v3, v2
    v6 = select.i64 v4, v1, v0
    return v6, v4
}

; run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0]

Steps to Reproduce

Expected Results

The test to pass

Actual Results

    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/afonso/git/qemu/build/qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 -cpu rv64,v=true,vlen=256,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true /home/afonso/git/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0], actual: [13724266, 0]
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: 8eccc63c46503adbc6ba91034324963b69a7523b (main)

Operating system: Linux

Architecture: RISC-V

Extra Info

<details>
<summary>Disassembly</summary>

Disassembly of 44 bytes:
   0:   93 e8 05 00             ori     a7, a1, 0
   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero
  1c:   63 54 e6 00             bge     a2, a4, 8
  20:   6f 00 80 00             j       8
  24:   13 e5 08 00             ori     a0, a7, 0
  28:   67 80 00 00             ret

</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 01 2023 at 15:52):

jameysharp commented on issue #6312:

This part of the disassembly looks like a reasonable implementation of icmp.i128 sle v3, v2, leaving 0 or 1 in a1:

   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero

But then it branches again on a comparison of the lower half of the two 128-bit inputs. Is there a lowering for the select/icmp combination that needs to exclude icmp.i128?

view this post on Zulip Wasmtime GitHub notifications bot (May 01 2023 at 16:33):

afonso360 commented on issue #6312:

That looks like it, we have a special case for select+icmp if the select is <= 64bits, but it might not take into account the icmp being i128.

view this post on Zulip Wasmtime GitHub notifications bot (May 01 2023 at 18:10):

cfallin closed issue #6312:

:wave: Hey,

Fuzzgen found this today.

.clif Test Case

;; Run test case

test interpret
test run
target riscv64gc

function %a(i64, i64, i128, i128) -> i64, i8 {
block0(v0: i64, v1: i64, v2: i128,  v3: i128):
    v4 = icmp.i128 sle v3, v2
    v6 = select.i64 v4, v1, v0
    return v6, v4
}

; run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0]

Steps to Reproduce

Expected Results

The test to pass

Actual Results

    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/afonso/git/qemu/build/qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 -cpu rv64,v=true,vlen=256,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true /home/afonso/git/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0, 13724266, 0, 142088073609408121139349355241191013256) == [0, 0], actual: [13724266, 0]
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: 8eccc63c46503adbc6ba91034324963b69a7523b (main)

Operating system: Linux

Architecture: RISC-V

Extra Info

<details>
<summary>Disassembly</summary>

Disassembly of 44 bytes:
   0:   93 e8 05 00             ori     a7, a1, 0
   4:   63 c6 d7 00             blt     a5, a3, 0xc
   8:   63 98 d7 00             bne     a5, a3, 0x10
   c:   63 66 e6 00             bltu    a2, a4, 0xc
  10:   93 05 10 00             addi    a1, zero, 1
  14:   6f 00 80 00             j       8
  18:   93 05 00 00             mv      a1, zero
  1c:   63 54 e6 00             bge     a2, a4, 8
  20:   6f 00 80 00             j       8
  24:   13 e5 08 00             ori     a0, a7, 0
  28:   67 80 00 00             ret

</details>


Last updated: Dec 23 2024 at 12:05 UTC