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>
iximeow submitted PR Review.
iximeow submitted PR Review.
iximeow created PR Review Comment:
I think it's better off to have another case for
arg1_type == I64
. Ifarg0_type != I64
and it's not a vector type, it ought to be I32, I16, or I8. So it would be just fine toireduce
arg1 toI8
and put them through a typicalishl
orushr
.Unfortunately, for the same reason your third test cases blow up, I can't write a test to exercise this at the moment.
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>
iximeow submitted PR Review.
iximeow merged PR #1612.
Last updated: Dec 23 2024 at 13:07 UTC