Stream: git-wasmtime

Topic: wasmtime / PR #1612 Legalize 64 bit shifts on x86_32 usin...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2020 at 01:54):

whitequark opened PR #1612 from x86_32-legalize-i64-shift to master:

I tried to run some WASI binary with wasmtime targeting i686-unknown-linux-gnu (as part of #1089) and immediately ran into a codegen crash. I believe the cause of the crash is the fact that something is emitting shifts with 64-bit value and amount (both 64-bit, in the testcase I reduced), which are not legal on x86_32.

I think I managed to fix 2/3 of the problematic cases, although not in an elegant way. Let me know what you think.

<details>
<summary>Testcase</summary>

test compile
set enable_simd
target i686 haswell

function u0:1(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i32 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

function u0:2(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i64 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

; this doesn't work
;function u0:3(i32) -> i32 system_v {
;    block1(v0: i32):
;        v1 = load.i32 notrap aligned v0+0
;        v2 = load.i64 notrap aligned v0+16
;        v3 = ishl v1, v2
;        return v3
;}

function u0:4(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i32 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

function u0:5(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i64 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

; this doesn't work
;function u0:6(i32) -> i32 system_v {
;    block1(v0: i32):
;        v1 = load.i32 notrap aligned v0+0
;        v2 = load.i64 notrap aligned v0+16
;        v3 = ishl v1, v2
;        return v3
;}

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2020 at 08:34):

iximeow submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2020 at 08:34):

iximeow submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2020 at 08:34):

iximeow created PR Review Comment:

I think it's better off to have another case for arg1_type == I64. If arg0_type != I64 and it's not a vector type, it ought to be I32, I16, or I8. So it would be just fine to ireduce arg1 to I8 and put them through a typical ishl or ushr.

Unfortunately, for the same reason your third test cases blow up, I can't write a test to exercise this at the moment.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2020 at 09:37):

whitequark updated PR #1612 from x86_32-legalize-i64-shift to master:

I tried to run some WASI binary with wasmtime targeting i686-unknown-linux-gnu (as part of #1089) and immediately ran into a codegen crash. I believe the cause of the crash is the fact that something is emitting shifts with 64-bit value and amount (both 64-bit, in the testcase I reduced), which are not legal on x86_32.

I think I managed to fix 2/3 of the problematic cases, although not in an elegant way. Let me know what you think.

<details>
<summary>Testcase</summary>

test compile
set enable_simd
target i686 haswell

function u0:1(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i32 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

function u0:2(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i64 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

; this doesn't work
;function u0:3(i32) -> i32 system_v {
;    block1(v0: i32):
;        v1 = load.i32 notrap aligned v0+0
;        v2 = load.i64 notrap aligned v0+16
;        v3 = ishl v1, v2
;        return v3
;}

function u0:4(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i32 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

function u0:5(i32) -> i64 system_v {
    block1(v0: i32):
        v1 = load.i64 notrap aligned v0+0
        v2 = load.i64 notrap aligned v0+16
        v3 = ishl v1, v2
        return v3
}

; this doesn't work
;function u0:6(i32) -> i32 system_v {
;    block1(v0: i32):
;        v1 = load.i32 notrap aligned v0+0
;        v2 = load.i64 notrap aligned v0+16
;        v3 = ishl v1, v2
;        return v3
;}

</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2020 at 10:02):

iximeow submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2020 at 10:28):

iximeow merged PR #1612.


Last updated: Nov 22 2024 at 17:03 UTC