Stream: git-wasmtime

Topic: wasmtime / issue #2860 Cranelift: handle carry flags as b...


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

cfallin edited issue #2860:

Hi! While using Cranelift as a backend for a project, I ran into a panic compiling iadd_carry instructions on x86_64. Please let me know if there is any other information I can provide that would be helpful.

.clif Test Case

function u0:0() fast {
block0:
    v1465 = iconst.i32 0
    v1467 = bconst.b1 false
    v1468 = iconst.i32 0
    v1469, v1470 = iadd_carry v1465, v1468, v1467
    v1476 = bint.i8 v1470
    v1356 = iconst.i64 0
    v1391 -> v1356
    v1423 -> v1356
    v1447 -> v1356
    v1464 -> v1356
    v1494 -> v1356
    v1516 -> v1356
    v1544 -> v1356
    store notrap aligned v1476, v1356+274
    trap user0
}

Steps to Reproduce

cargo run -p cranelift-tools -- compile test.clif --target x86_64

Expected Results

Code successfully generates without a panic.

Actual Results

Panic: thread 'main' panicked at 'ALU+imm and ALU+carry ops should not appear here!', cranelift/codegen/src/isa/x64/lower.rs:5740:13

Versions and Environment

Cranelift version or commit: main HEAD (4a830b at time of writing)

Operating system: Linux

Architecture: x86_64

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

cfallin labeled issue #2860:

Hi! While using Cranelift as a backend for a project, I ran into a panic compiling iadd_carry instructions on x86_64. Please let me know if there is any other information I can provide that would be helpful.

.clif Test Case

function u0:0() fast {
block0:
    v1465 = iconst.i32 0
    v1467 = bconst.b1 false
    v1468 = iconst.i32 0
    v1469, v1470 = iadd_carry v1465, v1468, v1467
    v1476 = bint.i8 v1470
    v1356 = iconst.i64 0
    v1391 -> v1356
    v1423 -> v1356
    v1447 -> v1356
    v1464 -> v1356
    v1494 -> v1356
    v1516 -> v1356
    v1544 -> v1356
    store notrap aligned v1476, v1356+274
    trap user0
}

Steps to Reproduce

cargo run -p cranelift-tools -- compile test.clif --target x86_64

Expected Results

Code successfully generates without a panic.

Actual Results

Panic: thread 'main' panicked at 'ALU+imm and ALU+carry ops should not appear here!', cranelift/codegen/src/isa/x64/lower.rs:5740:13

Versions and Environment

Cranelift version or commit: main HEAD (4a830b at time of writing)

Operating system: Linux

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2023 at 19:19):

scottmcm commented on issue #2860:

Is part of this fixed with https://github.com/bytecodealliance/wasmtime/pull/5784 ?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2023 at 19:41):

jameysharp commented on issue #2860:

I'm not entirely sure what this issue is about at this point, so it's hard to say whether it's fixed. :sweat_smile:

If it's about addition with carry not having a usable lowering on x86, then I think that was fixed either by #5784 or earlier work. Cranelift has changed a lot since this issue was opened so it's hard to even compare.

If I consider only the issue title ("handle carry flags as bools in backends") then I think this was fixed by #5406 and earlier work.

For chc4's use case of encoding the behavior of x86 flags into CLIF, I think we've gone the opposite direction since we've removed the notion of flags from the IR entirely. (Again, in #5406 and earlier.) It's always possible to encode values equivalent to x86's flags in integer values and carry those around, though we may not generate particularly efficient code from that encoding.

Regardless of which interpretation we consider, I think this issue is no longer serving a useful purpose. So I'm going to close it.

I'd suggest that anyone who encounters issues which sound like this should open a new issue, explaining exactly what you're seeing. Anything that comes up now is probably not related to the difficulties described in this issue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2023 at 19:41):

jameysharp closed issue #2860:

Hi! While using Cranelift as a backend for a project, I ran into a panic compiling iadd_carry instructions on x86_64. Please let me know if there is any other information I can provide that would be helpful.

.clif Test Case

function u0:0() fast {
block0:
    v1465 = iconst.i32 0
    v1467 = bconst.b1 false
    v1468 = iconst.i32 0
    v1469, v1470 = iadd_carry v1465, v1468, v1467
    v1476 = bint.i8 v1470
    v1356 = iconst.i64 0
    v1391 -> v1356
    v1423 -> v1356
    v1447 -> v1356
    v1464 -> v1356
    v1494 -> v1356
    v1516 -> v1356
    v1544 -> v1356
    store notrap aligned v1476, v1356+274
    trap user0
}

Steps to Reproduce

cargo run -p cranelift-tools -- compile test.clif --target x86_64

Expected Results

Code successfully generates without a panic.

Actual Results

Panic: thread 'main' panicked at 'ALU+imm and ALU+carry ops should not appear here!', cranelift/codegen/src/isa/x64/lower.rs:5740:13

Versions and Environment

Cranelift version or commit: main HEAD (4a830b at time of writing)

Operating system: Linux

Architecture: x86_64


Last updated: Nov 22 2024 at 16:03 UTC