Stream: git-wasmtime

Topic: wasmtime / issue #5917 Cranelift: `vselect.i16x8` wrong r...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:28):

afonso360 opened issue #5917:

:wave: Hey,

Just to doublecheck this one, I ran it on AArch64 and S390X and both agree with the interpreter.

.clif Test Case

test interpret
test run
target x86_64
target aarch64
target s390x

function %a(i16x8, i16x8) -> i16x8 {
block0(v1: i16x8, v3: i16x8):
    v19 = vselect v1, v1, v3
    return v19
}

; run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) ==  0x000000000000000000000000e62fffff

Steps to Reproduce

Expected Results

The test to pass.

Actual Results

     Running `/home/afonso/git/wasmtime/target/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) == 0x000000000000000000000000e62fffff, actual: 0x000000000000000000000000e600ffff
1 tests
Error: 1 failure

It passes on AArch64 and S390X.

Versions and Environment

Cranelift version or commit: main

Operating system: Linux

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:28):

afonso360 labeled issue #5917:

:wave: Hey,

Just to doublecheck this one, I ran it on AArch64 and S390X and both agree with the interpreter.

.clif Test Case

test interpret
test run
target x86_64
target aarch64
target s390x

function %a(i16x8, i16x8) -> i16x8 {
block0(v1: i16x8, v3: i16x8):
    v19 = vselect v1, v1, v3
    return v19
}

; run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) ==  0x000000000000000000000000e62fffff

Steps to Reproduce

Expected Results

The test to pass.

Actual Results

     Running `/home/afonso/git/wasmtime/target/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) == 0x000000000000000000000000e62fffff, actual: 0x000000000000000000000000e600ffff
1 tests
Error: 1 failure

It passes on AArch64 and S390X.

Versions and Environment

Cranelift version or commit: main

Operating system: Linux

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:28):

afonso360 labeled issue #5917:

:wave: Hey,

Just to doublecheck this one, I ran it on AArch64 and S390X and both agree with the interpreter.

.clif Test Case

test interpret
test run
target x86_64
target aarch64
target s390x

function %a(i16x8, i16x8) -> i16x8 {
block0(v1: i16x8, v3: i16x8):
    v19 = vselect v1, v1, v3
    return v19
}

; run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) ==  0x000000000000000000000000e62fffff

Steps to Reproduce

Expected Results

The test to pass.

Actual Results

     Running `/home/afonso/git/wasmtime/target/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) == 0x000000000000000000000000e62fffff, actual: 0x000000000000000000000000e600ffff
1 tests
Error: 1 failure

It passes on AArch64 and S390X.

Versions and Environment

Cranelift version or commit: main

Operating system: Linux

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:28):

afonso360 labeled issue #5917:

:wave: Hey,

Just to doublecheck this one, I ran it on AArch64 and S390X and both agree with the interpreter.

.clif Test Case

test interpret
test run
target x86_64
target aarch64
target s390x

function %a(i16x8, i16x8) -> i16x8 {
block0(v1: i16x8, v3: i16x8):
    v19 = vselect v1, v1, v3
    return v19
}

; run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) ==  0x000000000000000000000000e62fffff

Steps to Reproduce

Expected Results

The test to pass.

Actual Results

     Running `/home/afonso/git/wasmtime/target/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) == 0x000000000000000000000000e62fffff, actual: 0x000000000000000000000000e600ffff
1 tests
Error: 1 failure

It passes on AArch64 and S390X.

Versions and Environment

Cranelift version or commit: main

Operating system: Linux

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:39):

jameysharp commented on issue #5917:

I'm guessing that x86 is only looking at the most significant bit in each lane, so e2 is treated as "true" for the whole lane while 2f is treated as false. But I think we specified this instruction to select each bit independently, not each lane.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 02 2023 at 22:43):

alexcrichton commented on issue #5917:

It looks like this isn't used in wasm lowering today (which is good given it's broken!) but it is used when NaN canonicalization is enabled.

That being said though I suspect we may wish to remove this instruction from Cranelift. The implementation of vselect matches bitselect on AArch64 and s390x, neither of which matches the documentation of vselect selecting based on "truthy" values. I think this means that the interpreter also differs from AArch64 and s390x.

Given that the only current use of vselect is during NaN canonicalization, and that can use bitselect, perhaps the instruction should be removed?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 01:24):

alexcrichton closed issue #5917:

:wave: Hey,

Just to doublecheck this one, I ran it on AArch64 and S390X and both agree with the interpreter.

.clif Test Case

test interpret
test run
target x86_64
target aarch64
target s390x

function %a(i16x8, i16x8) -> i16x8 {
block0(v1: i16x8, v3: i16x8):
    v19 = vselect v1, v1, v3
    return v19
}

; run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) ==  0x000000000000000000000000e62fffff

Steps to Reproduce

Expected Results

The test to pass.

Actual Results

     Running `/home/afonso/git/wasmtime/target/debug/clif-util test ./lmao.clif`
 ERROR cranelift_filetests::concurrent > FAIL: run
FAIL ./lmao.clif: run

Caused by:
    Failed test: run: %a(0x000000000000000000000000e62fffff, 0x00000000000000000000000000000000) == 0x000000000000000000000000e62fffff, actual: 0x000000000000000000000000e600ffff
1 tests
Error: 1 failure

It passes on AArch64 and S390X.

Versions and Environment

Cranelift version or commit: main

Operating system: Linux

Architecture: x86_64


Last updated: Dec 23 2024 at 12:05 UTC