Skip to content

Commit cd67a60

Browse files
authored
Winch: extract_lane instructions (#10042)
1 parent 2eb6513 commit cd67a60

File tree

18 files changed

+832
-192
lines changed

18 files changed

+832
-192
lines changed

crates/wast-util/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ impl WastTest {
430430
"misc_testsuite/simd/issue_3327_bnot_lowering.wast",
431431
"misc_testsuite/simd/load_splat_out_of_bounds.wast",
432432
"misc_testsuite/simd/replace-lane-preserve.wast",
433-
"misc_testsuite/simd/spillslot-size-fuzzbug.wast",
434433
"misc_testsuite/simd/unaligned-load.wast",
435434
"multi-memory/simd_memory-multi.wast",
436435
"spec_testsuite/simd_bit_shift.wast",
@@ -478,8 +477,6 @@ impl WastTest {
478477
"spec_testsuite/simd_load32_lane.wast",
479478
"spec_testsuite/simd_load64_lane.wast",
480479
"spec_testsuite/simd_load8_lane.wast",
481-
"spec_testsuite/simd_load_extend.wast",
482-
"spec_testsuite/simd_load_splat.wast",
483480
"spec_testsuite/simd_load_zero.wast",
484481
"spec_testsuite/simd_splat.wast",
485482
"spec_testsuite/simd_store16_lane.wast",
@@ -501,9 +498,12 @@ impl WastTest {
501498
#[cfg(target_arch = "x86_64")]
502499
if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("avx2")) {
503500
let unsupported = [
501+
"misc_testsuite/simd/spillslot-size-fuzzbug.wast",
504502
"misc_testsuite/winch/_simd_lane.wast",
505503
"misc_testsuite/winch/_simd_splat.wast",
506504
"spec_testsuite/simd_align.wast",
505+
"spec_testsuite/simd_load_extend.wast",
506+
"spec_testsuite/simd_load_splat.wast",
507507
];
508508

509509
if unsupported.iter().any(|part| self.path.ends_with(part)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result f32)
7+
(f32x4.extract_lane 0 (v128.const i32x4 0 1 2 3))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x3a
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0xc(%rip), %xmm0
23+
;; addq $0x10, %rsp
24+
;; popq %rbp
25+
;; retq
26+
;; 3a: ud2
27+
;; 3c: addb %al, (%rax)
28+
;; 3e: addb %al, (%rax)
29+
;; 40: addb %al, (%rax)
30+
;; 42: addb %al, (%rax)
31+
;; 44: addl %eax, (%rax)
32+
;; 46: addb %al, (%rax)
33+
;; 48: addb (%rax), %al
34+
;; 4a: addb %al, (%rax)
35+
;; 4c: addl (%rax), %eax
36+
;; 4e: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result f32)
7+
(f32x4.extract_lane 1 (v128.const i32x4 0 1 2 3))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x3f
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpshufd $1, %xmm0, %xmm0
24+
;; addq $0x10, %rsp
25+
;; popq %rbp
26+
;; retq
27+
;; 3f: ud2
28+
;; 41: addb %al, (%rax)
29+
;; 43: addb %al, (%rax)
30+
;; 45: addb %al, (%rax)
31+
;; 47: addb %al, (%rax)
32+
;; 49: addb %al, (%rax)
33+
;; 4b: addb %al, (%rax)
34+
;; 4d: addb %al, (%rax)
35+
;; 4f: addb %al, (%rax)
36+
;; 51: addb %al, (%rax)
37+
;; 53: addb %al, (%rcx)
38+
;; 55: addb %al, (%rax)
39+
;; 57: addb %al, (%rdx)
40+
;; 59: addb %al, (%rax)
41+
;; 5b: addb %al, (%rbx)
42+
;; 5d: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result f64)
7+
(f64x2.extract_lane 0 (v128.const i64x2 0 1))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x3a
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0xc(%rip), %xmm0
23+
;; addq $0x10, %rsp
24+
;; popq %rbp
25+
;; retq
26+
;; 3a: ud2
27+
;; 3c: addb %al, (%rax)
28+
;; 3e: addb %al, (%rax)
29+
;; 40: addb %al, (%rax)
30+
;; 42: addb %al, (%rax)
31+
;; 44: addb %al, (%rax)
32+
;; 46: addb %al, (%rax)
33+
;; 48: addl %eax, (%rax)
34+
;; 4a: addb %al, (%rax)
35+
;; 4c: addb %al, (%rax)
36+
;; 4e: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result f64)
7+
(f64x2.extract_lane 1 (v128.const i64x2 0 1))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x3f
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpshufd $0xee, %xmm0, %xmm0
24+
;; addq $0x10, %rsp
25+
;; popq %rbp
26+
;; retq
27+
;; 3f: ud2
28+
;; 41: addb %al, (%rax)
29+
;; 43: addb %al, (%rax)
30+
;; 45: addb %al, (%rax)
31+
;; 47: addb %al, (%rax)
32+
;; 49: addb %al, (%rax)
33+
;; 4b: addb %al, (%rax)
34+
;; 4d: addb %al, (%rax)
35+
;; 4f: addb %al, (%rax)
36+
;; 51: addb %al, (%rax)
37+
;; 53: addb %al, (%rax)
38+
;; 55: addb %al, (%rax)
39+
;; 57: addb %al, (%rcx)
40+
;; 59: addb %al, (%rax)
41+
;; 5b: addb %al, (%rax)
42+
;; 5d: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result i32)
7+
(i16x8.extract_lane_s 1 (v128.const i16x8 0 1 2 3 4 5 6 7))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x43
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpextrw $1, %xmm0, %eax
24+
;; movswl %ax, %eax
25+
;; addq $0x10, %rsp
26+
;; popq %rbp
27+
;; retq
28+
;; 43: ud2
29+
;; 45: addb %al, (%rax)
30+
;; 47: addb %al, (%rax)
31+
;; 49: addb %al, (%rax)
32+
;; 4b: addb %al, (%rax)
33+
;; 4d: addb %al, (%rax)
34+
;; 4f: addb %al, (%rax)
35+
;; 51: addb %al, (%rcx)
36+
;; 53: addb %al, (%rdx)
37+
;; 55: addb %al, (%rbx)
38+
;; 57: addb %al, (%rax, %rax)
39+
;; 5a: addl $0x7000600, %eax
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result i32)
7+
(i16x8.extract_lane_u 1 (v128.const i16x8 0 1 2 3 4 5 6 7))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x40
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpextrw $1, %xmm0, %eax
24+
;; addq $0x10, %rsp
25+
;; popq %rbp
26+
;; retq
27+
;; 40: ud2
28+
;; 42: addb %al, (%rax)
29+
;; 44: addb %al, (%rax)
30+
;; 46: addb %al, (%rax)
31+
;; 48: addb %al, (%rax)
32+
;; 4a: addb %al, (%rax)
33+
;; 4c: addb %al, (%rax)
34+
;; 4e: addb %al, (%rax)
35+
;; 50: addb %al, (%rax)
36+
;; 52: addl %eax, (%rax)
37+
;; 54: addb (%rax), %al
38+
;; 56: addl (%rax), %eax
39+
;; 58: addb $0, %al
40+
;; 5a: addl $0x7000600, %eax
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result i32)
7+
(i32x4.extract_lane 1 (v128.const i32x4 0 1 2 3))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x40
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpextrd $1, %xmm0, %eax
24+
;; addq $0x10, %rsp
25+
;; popq %rbp
26+
;; retq
27+
;; 40: ud2
28+
;; 42: addb %al, (%rax)
29+
;; 44: addb %al, (%rax)
30+
;; 46: addb %al, (%rax)
31+
;; 48: addb %al, (%rax)
32+
;; 4a: addb %al, (%rax)
33+
;; 4c: addb %al, (%rax)
34+
;; 4e: addb %al, (%rax)
35+
;; 50: addb %al, (%rax)
36+
;; 52: addb %al, (%rax)
37+
;; 54: addl %eax, (%rax)
38+
;; 56: addb %al, (%rax)
39+
;; 58: addb (%rax), %al
40+
;; 5a: addb %al, (%rax)
41+
;; 5c: addl (%rax), %eax
42+
;; 5e: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result i64)
7+
(i64x2.extract_lane 1 (v128.const i64x2 0 1))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x40
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpextrq $1, %xmm0, %rax
24+
;; addq $0x10, %rsp
25+
;; popq %rbp
26+
;; retq
27+
;; 40: ud2
28+
;; 42: addb %al, (%rax)
29+
;; 44: addb %al, (%rax)
30+
;; 46: addb %al, (%rax)
31+
;; 48: addb %al, (%rax)
32+
;; 4a: addb %al, (%rax)
33+
;; 4c: addb %al, (%rax)
34+
;; 4e: addb %al, (%rax)
35+
;; 50: addb %al, (%rax)
36+
;; 52: addb %al, (%rax)
37+
;; 54: addb %al, (%rax)
38+
;; 56: addb %al, (%rax)
39+
;; 58: addl %eax, (%rax)
40+
;; 5a: addb %al, (%rax)
41+
;; 5c: addb %al, (%rax)
42+
;; 5e: addb %al, (%rax)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;;! target = "x86_64"
2+
;;! test = "winch"
3+
;;! flags = [ "-Ccranelift-has-avx" ]
4+
5+
(module
6+
(func (result i32)
7+
(i8x16.extract_lane_s 1 (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
8+
)
9+
)
10+
;; wasm[0]::function[0]:
11+
;; pushq %rbp
12+
;; movq %rsp, %rbp
13+
;; movq 8(%rdi), %r11
14+
;; movq 0x10(%r11), %r11
15+
;; addq $0x10, %r11
16+
;; cmpq %rsp, %r11
17+
;; ja 0x43
18+
;; 1c: movq %rdi, %r14
19+
;; subq $0x10, %rsp
20+
;; movq %rdi, 8(%rsp)
21+
;; movq %rsi, (%rsp)
22+
;; movdqu 0x1c(%rip), %xmm0
23+
;; vpextrb $1, %xmm0, %eax
24+
;; movsbl %al, %eax
25+
;; addq $0x10, %rsp
26+
;; popq %rbp
27+
;; retq
28+
;; 43: ud2
29+
;; 45: addb %al, (%rax)
30+
;; 47: addb %al, (%rax)
31+
;; 49: addb %al, (%rax)
32+
;; 4b: addb %al, (%rax)
33+
;; 4d: addb %al, (%rax)
34+
;; 4f: addb %al, (%rax)
35+
;; 51: addl %eax, (%rdx)
36+
;; 53: addl 0x9080706(, %rax), %eax
37+
;; 5a: orb (%rbx), %cl
38+
;; 5c: orb $0xd, %al

0 commit comments

Comments
 (0)