afonso360 opened issue #6725:
:wave: Hey,
I ran fuzzgen on AArch64 today and it found an issue.
.clif
Test Casetest compile set opt_level=speed_and_size target aarch64 function %a() -> i32x4 { const7 = 0x00000000000000000000000000000000 block0: v52 = vconst.i32x4 const7 v53 = icmp eq v52, v52 v63 = icmp ne v52, v52 v64 = bor v53, v63 return v64 }
This is what the function looks after egraphs:
function %a() -> i32x4 fast { block0: v65 = iconst.i32x4 1 return v65 ; v65 = 1 }
Steps to Reproduce
clif-util test ./the-above
Expected Results
The function to compile
Actual Results
Running `/home/afonso/git/wasmtime/target/debug/clif-util compile --target aarch64 --set opt_level=speed_and_size ./lmao.clif` thread 'main' panicked at 'internal error: entered unreachable code: no rule matched for term imm at src/isa/aarch64/inst.isle line 2883; should it be partial?', /home/afonso/git/wasmtime/target/debug/build/cranelift-codegen-7af9571f8465fadc/out/isle_aarch64.rs:5554:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Versions and Environment
Cranelift version or commit: main (04b8edd2f538286d91c167d231628874c5bc29b7)
Operating system: Linux
Architecture: AArch64
Extra Info
Bisect points to dcf0ea9ff367034a43e65552e2a30d0ba8cbd95e which is so long ago that I'm really surprised we haven't caught this earlier.
afonso360 added the bug label to Issue #6725.
afonso360 added the cranelift:area:aarch64 label to Issue #6725.
afonso360 added the cranelift label to Issue #6725.
jameysharp commented on issue #6725:
Huh. I believe this is because we're missing the
ty_int
/fits_in_64
constraints for these two rules:(rule (compose_icmp ty 0 _ _ _) (subsume (iconst ty (imm64 0)))) (rule (compose_icmp ty 7 _ _ _) (subsume (iconst ty (imm64 1))))
However the surrounding rules are not written to handle
compose_icmp
failing to match, so fixing this isn't super trivial.In all the other
compose_icmp
cases, it still generates anicmp
instruction and so the rules should be valid even for vector types.I guess the easiest fix is to refuse to apply any of these optimizations on vectors.
We could also solve this as part of fixing #6038.
alexcrichton commented on issue #6725:
I'll note that this is reachable from wasm:
(module (func (param v128) (result v128) (i8x16.eq (local.get 0) (local.get 0)) (i8x16.ne (local.get 0) (local.get 0)) v128.or) )
and it fails not only for AArch64:
$ wasmtime compile foo.wat --emit-clif clif --target x86_64 thread '<unnamed>' panicked at 'should be implemented in ISLE: inst = `v7 = iconst.i8x16 1`, type = `Some(types::I8X16)`', /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-codegen-0.97.1/src/machinst/lower.rs:749:21 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace $ wasmtime compile foo.wat --emit-clif clif --target aarch64 thread '<unnamed>' panicked at 'internal error: entered unreachable code: no rule matched for term imm at src/isa/aarch64/inst.isle line 2883; should it be partial?', /var/folders/70/cx6_8hz93jz7kj_km0_5c9_40000gn/T/cargo-install26VIDu/release/build/cranelift-codegen-e94e1c35edbd285d/out/isle_aarch64.rs:5536:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
alexcrichton edited a comment on issue #6725:
I'll note that this is reachable from wasm:
(module (func (param v128) (result v128) (i8x16.eq (local.get 0) (local.get 0)) (i8x16.ne (local.get 0) (local.get 0)) v128.or) )
and it fails not only for AArch64:
$ wasmtime compile foo.wat --target x86_64 thread '<unnamed>' panicked at 'should be implemented in ISLE: inst = `v7 = iconst.i8x16 1`, type = `Some(types::I8X16)`', /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-codegen-0.97.1/src/machinst/lower.rs:749:21 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace $ wasmtime compile foo.wat --target aarch64 thread '<unnamed>' panicked at 'internal error: entered unreachable code: no rule matched for term imm at src/isa/aarch64/inst.isle line 2883; should it be partial?', /var/folders/70/cx6_8hz93jz7kj_km0_5c9_40000gn/T/cargo-install26VIDu/release/build/cranelift-codegen-e94e1c35edbd285d/out/isle_aarch64.rs:5536:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
alexcrichton commented on issue #6725:
Fixed in https://github.com/bytecodealliance/wasmtime/pull/6728#event-9824618437
alexcrichton closed issue #6725:
:wave: Hey,
I ran fuzzgen on AArch64 today and it found an issue.
.clif
Test Casetest compile set opt_level=speed_and_size target aarch64 function %a() -> i32x4 { const7 = 0x00000000000000000000000000000000 block0: v52 = vconst.i32x4 const7 v53 = icmp eq v52, v52 v63 = icmp ne v52, v52 v64 = bor v53, v63 return v64 }
This is what the function looks after egraphs:
function %a() -> i32x4 fast { block0: v65 = iconst.i32x4 1 return v65 ; v65 = 1 }
Steps to Reproduce
clif-util test ./the-above
Expected Results
The function to compile
Actual Results
Running `/home/afonso/git/wasmtime/target/debug/clif-util compile --target aarch64 --set opt_level=speed_and_size ./lmao.clif` thread 'main' panicked at 'internal error: entered unreachable code: no rule matched for term imm at src/isa/aarch64/inst.isle line 2883; should it be partial?', /home/afonso/git/wasmtime/target/debug/build/cranelift-codegen-7af9571f8465fadc/out/isle_aarch64.rs:5554:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Versions and Environment
Cranelift version or commit: main (04b8edd2f538286d91c167d231628874c5bc29b7)
Operating system: Linux
Architecture: AArch64
Extra Info
Bisect points to dcf0ea9ff367034a43e65552e2a30d0ba8cbd95e which is so long ago that I'm really surprised we haven't caught this earlier.
Last updated: Dec 23 2024 at 12:05 UTC