Stream: git-wasmtime

Topic: wasmtime / issue #9143 Cranelift: Lowering fails for `fma...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 19:55):

kcvlex added the bug label to Issue #9143.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 19:55):

kcvlex added the cranelift label to Issue #9143.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 19:55):

kcvlex opened issue #9143:

.clif Test Case

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmax v1, v2
    return v3
}

function %fmin(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmin v1, v2
    return v3
}

Steps to Reproduce

clif-util test ./the-above.clif

Expected Results

Successful

Actual Results

Assertion failure

thread 'worker #0' panicked at cranelift/codegen/src/machinst/lower.rs:1449:13:
assertion failed: !self.inst_sunk.contains(&inst)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 ERROR cranelift_filetests::concurrent > FAIL: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
FAIL ./fmax.clif: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: #2c3e64bc5de0a67963e0e34eabbb6de95ecda0ba

Operating system: Linux

Architecture: X86_64

Extra Info

I tried other similar cases and found that the test passes if there are no load instructions. Also, the problem doesn't occur when inserting a jump like the one below.

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    jump block1(v1, v2)

block1(v3: f32x4, v4: f32x4):
    v5 = fmax v3, v4
    return v5
}

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 20:00):

kcvlex edited issue #9143:

.clif Test Case

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmax v1, v2
    return v3
}

function %fmin(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmin v1, v2
    return v3
}

Steps to Reproduce

clif-util test ./the-above.clif

Expected Results

Successful

Actual Results

Assertion failure

thread 'worker #0' panicked at cranelift/codegen/src/machinst/lower.rs:1449:13:
assertion failed: !self.inst_sunk.contains(&inst)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 ERROR cranelift_filetests::concurrent > FAIL: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
FAIL ./fmax.clif: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: #2c3e64bc5de0a67963e0e34eabbb6de95ecda0ba

Operating system: Linux

Architecture: X86_64

Extra Info

I tried other similar cases and found that the test passes if there are no load instructions. Also, the problem doesn't occur when inserting a jump like the one below.

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    jump block1(v1, v2)

block1(v3: f32x4, v4: f32x4):
    v5 = fmax v3, v4
    return v5
}

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 20:02):

fitzgen commented on issue #9143:

Maybe a regression from https://github.com/bytecodealliance/wasmtime/pull/9137 ? cc @alexcrichton

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 21:27):

alexcrichton commented on issue #9143:

Bisection points to #5841, "very old" issue, continuing to investigate.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 21:33):

alexcrichton commented on issue #9143:

This appears to not affect wasm because wasm always loads/stores as i8x16 and the bitcast afterwards to go to f32x4 thwarts the load sinking here. Given that I think this is just a fix for clif/lowerings which makes it so this doesn't have quite as large of an impact. I'll work on fixing.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 21:42):

alexcrichton commented on issue #9143:

Thank you for the clear and concise bug report!

view this post on Zulip Wasmtime GitHub notifications bot (Aug 19 2024 at 22:06):

fitzgen closed issue #9143:

.clif Test Case

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmax v1, v2
    return v3
}

function %fmin(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    v3 = fmin v1, v2
    return v3
}

Steps to Reproduce

clif-util test ./the-above.clif

Expected Results

Successful

Actual Results

Assertion failure

thread 'worker #0' panicked at cranelift/codegen/src/machinst/lower.rs:1449:13:
assertion failed: !self.inst_sunk.contains(&inst)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 ERROR cranelift_filetests::concurrent > FAIL: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
FAIL ./fmax.clif: panicked in worker #0: assertion failed: !self.inst_sunk.contains(&inst)
1 tests
Error: 1 failure

Versions and Environment

Cranelift version or commit: #2c3e64bc5de0a67963e0e34eabbb6de95ecda0ba

Operating system: Linux

Architecture: X86_64

Extra Info

I tried other similar cases and found that the test passes if there are no load instructions. Also, the problem doesn't occur when inserting a jump like the one below.

test compile
target x86_64

function %fmax(i64, f32x4) -> f32x4 {
block0(v0: i64, v1: f32x4):
    v2 = load.f32x4 v0
    jump block1(v1, v2)

block1(v3: f32x4, v4: f32x4):
    v5 = fmax v3, v4
    return v5
}

view this post on Zulip Wasmtime GitHub notifications bot (Aug 20 2024 at 10:38):

kcvlex commented on issue #9143:

Thanks for your quick fix!


Last updated: Oct 23 2024 at 20:03 UTC