Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

riscv64: Fix `replicated_imm5` lowering rule (#12956)

Alex Crichton3c714e360379
diff --git a/cranelift/codegen/src/isa/aarch64/inst.isle b/cranelift/codegen/src/isa/aarch64/inst.isle
index 3be84db617..0ec5902780 100644
--- a/cranelift/codegen/src/isa/aarch64/inst.isle
+++ b/cranelift/codegen/src/isa/aarch64/inst.isle
@@ -4112,13 +4112,13 @@
;; as it will make it easier to create the immediates in the instructions below.
(rule 5 (splat_const (u64_replicated_u32 n) (VectorSize.Size64x2))
(splat_const n (VectorSize.Size32x4)))
-(rule 5 (splat_const (u32_replicated_u16 n) (VectorSize.Size32x4))
+(rule 5 (splat_const (u32_from_u64 (u32_replicated_u16 n)) (VectorSize.Size32x4))
(splat_const n (VectorSize.Size16x8)))
-(rule 5 (splat_const (u32_replicated_u16 n) (VectorSize.Size32x2))
+(rule 5 (splat_const (u32_from_u64 (u32_replicated_u16 n)) (VectorSize.Size32x2))
(splat_const n (VectorSize.Size16x4)))
-(rule 5 (splat_const (u16_replicated_u8 n) (VectorSize.Size16x8))
+(rule 5 (splat_const (u16_from_u64 (u16_replicated_u8 n)) (VectorSize.Size16x8))
(splat_const n (VectorSize.Size8x16)))
-(rule 5 (splat_const (u16_replicated_u8 n) (VectorSize.Size16x4))
+(rule 5 (splat_const (u16_from_u64 (u16_replicated_u8 n)) (VectorSize.Size16x4))
(splat_const n (VectorSize.Size8x8)))
;; Special cases for `vec_dup_imm` instructions where the input is either
diff --git a/cranelift/codegen/src/isa/riscv64/inst.isle b/cranelift/codegen/src/isa/riscv64/inst.isle
index 80521217ed..94e408d655 100644
--- a/cranelift/codegen/src/isa/riscv64/inst.isle
+++ b/cranelift/codegen/src/isa/riscv64/inst.isle
@@ -2020,9 +2020,15 @@
(decl imm5_from_i64 (Imm5) i64)
(extern extractor imm5_from_i64 imm5_from_i64)
-;; Construct a Imm5 from an i8
+;; Construct a Imm5 from an iNN
(decl pure partial i8_to_imm5 (i8) Imm5)
(extern constructor i8_to_imm5 i8_to_imm5)
+(decl pure partial i16_to_imm5 (i16) Imm5)
+(rule (i16_to_imm5 (i8_from_i16 n)) (i8_to_imm5 n))
+(decl pure partial i32_to_imm5 (i32) Imm5)
+(rule (i32_to_imm5 (i8_from_i32 n)) (i8_to_imm5 n))
+(decl pure partial i64_to_imm5 (i64) Imm5)
+(rule (i64_to_imm5 (i8_from_i64 n)) (i8_to_imm5 n))
;; Helper to go directly from a `Value` to an `Imm5`.
(decl imm5_from_value (Imm5) Value)
@@ -2037,11 +2043,20 @@
;; Constructor that matches a `Value` equivalent to a replicated Imm5 on all lanes.
(decl pure partial replicated_imm5 (Value) Imm5)
(rule (replicated_imm5 (splat _ (imm5_from_value n))) n)
-(rule (replicated_imm5 (vconst _ (u128_from_constant n128)))
+(rule (replicated_imm5 (vconst (multi_lane 64 _) (u128_from_constant n128)))
(if-let (u128_replicated_u64 n64) n128)
- (if-let (u64_replicated_u32 n32) n64)
- (if-let (u32_replicated_u16 n16) n32)
- (if-let (u16_replicated_u8 n8) n16)
+ (if-let n (i64_to_imm5 (u64_cast_signed n64)))
+ n)
+(rule (replicated_imm5 (vconst (multi_lane 32 _) (u128_from_constant n128)))
+ (if-let (u128_replicated_u32 n32) n128)
+ (if-let n (i32_to_imm5 (u32_cast_signed n32)))
+ n)
+(rule (replicated_imm5 (vconst (multi_lane 16 _) (u128_from_constant n128)))
+ (if-let (u128_replicated_u16 n16) n128)
+ (if-let n (i16_to_imm5 (u16_cast_signed n16)))
+ n)
+(rule (replicated_imm5 (vconst (multi_lane 8 _) (u128_from_constant n128)))
+ (if-let (u128_replicated_u8 n8) n128)
(if-let n (i8_to_imm5 (u8_cast_signed n8)))
n)
diff --git a/cranelift/codegen/src/isle_prelude.rs b/cranelift/codegen/src/isle_prelude.rs
index c63309fbd3..a5dfce0ad4 100644
--- a/cranelift/codegen/src/isle_prelude.rs
+++ b/cranelift/codegen/src/isle_prelude.rs
@@ -792,27 +792,25 @@ macro_rules! isle_common_prelude_methods {
}
}
- fn u64_replicated_u32(&mut self, val: u64) -> Option<u64> {
+ fn u64_replicated_u32(&mut self, val: u64) -> Option<u32> {
let low32 = val as u32 as u64;
if (low32 | (low32 << 32)) == val {
- Some(low32)
+ Some(val as u32)
} else {
None
}
}
- fn u32_replicated_u16(&mut self, val: u64) -> Option<u64> {
- let val = val as u32;
+ fn u32_replicated_u16(&mut self, val: u32) -> Option<u16> {
let low16 = val as u16 as u32;
if (low16 | (low16 << 16)) == val {
- Some(low16.into())
+ Some(low16 as u16)
} else {
None
}
}
- fn u16_replicated_u8(&mut self, val: u64) -> Option<u8> {
- let val = val as u16;
+ fn u16_replicated_u8(&mut self, val: u16) -> Option<u8> {
let low8 = val as u8 as u16;
if (low8 | (low8 << 8)) == val {
Some(low8 as u8)
diff --git a/cranelift/codegen/src/prelude.isle b/cranelift/codegen/src/prelude.isle
index 76a9773f42..8beecf6cd2 100644
--- a/cranelift/codegen/src/prelude.isle
+++ b/cranelift/codegen/src/prelude.isle
@@ -115,13 +115,21 @@
;; lower half of the input
(decl u128_replicated_u64 (u64) u128)
(extern extractor u128_replicated_u64 u128_replicated_u64)
-(decl u64_replicated_u32 (u64) u64)
+(decl u64_replicated_u32 (u32) u64)
(extern extractor u64_replicated_u32 u64_replicated_u32)
-(decl u32_replicated_u16 (u64) u64)
+(decl u32_replicated_u16 (u16) u32)
(extern extractor u32_replicated_u16 u32_replicated_u16)
-(decl u16_replicated_u8 (u8) u64)
+(decl u16_replicated_u8 (u8) u16)
(extern extractor u16_replicated_u8 u16_replicated_u8)
+;; Convenience extractors to go directly from u128 to something smaller
+(decl u128_replicated_u32 (u32) u128)
+(extractor (u128_replicated_u32 n) (u128_replicated_u64 (u64_replicated_u32 n)))
+(decl u128_replicated_u16 (u16) u128)
+(extractor (u128_replicated_u16 n) (u128_replicated_u32 (u32_replicated_u16 n)))
+(decl u128_replicated_u8 (u8) u128)
+(extractor (u128_replicated_u8 n) (u128_replicated_u16 (u16_replicated_u8 n)))
+
;; Get the low and high bits of a `u128` as `u64`s.
(decl u128_low_bits (u128) u64)
(extern constructor u128_low_bits u128_low_bits)
diff --git a/cranelift/filetests/filetests/isa/riscv64/simd-iadd-opt.clif b/cranelift/filetests/filetests/isa/riscv64/simd-iadd-opt.clif
new file mode 100644
index 0000000000..28c29d74a2
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/riscv64/simd-iadd-opt.clif
@@ -0,0 +1,330 @@
+test compile precise-output
+set enable_multi_ret_implicit_sret
+set unwind_info=false
+target riscv64 has_v
+
+
+function %iadd_const_i8x16(i8x16) -> i8x16 {
+block0(v0: i8x16):
+ v2 = vconst.i8x16 0x01010101_01010101_01010101_01010101
+ v3 = iadd v0, v2
+
+ v4 = vconst.i8x16 0x00010001_00010001_00010001_00010001
+ v5 = iadd v3, v4
+
+ v6 = vconst.i8x16 0x00000001_00000001_00000001_00000001
+ v7 = iadd v5, v6
+
+ v8 = vconst.i8x16 0x00000000_00000001_00000000_00000001
+ v9 = iadd v7, v8
+
+ return v9
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; block0:
+; vle8.v v8,-16(incoming_arg) #avl=16, #vtype=(e8, m1, ta, ma)
+; vadd.vi v10,v8,1 #avl=16, #vtype=(e8, m1, ta, ma)
+; vle8.v v11,[const(2)] #avl=16, #vtype=(e8, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=16, #vtype=(e8, m1, ta, ma)
+; vle8.v v11,[const(1)] #avl=16, #vtype=(e8, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=16, #vtype=(e8, m1, ta, ma)
+; vle8.v v11,[const(0)] #avl=16, #vtype=(e8, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=16, #vtype=(e8, m1, ta, ma)
+; vse8.v v10,0(a0) #avl=16, #vtype=(e8, m1, ta, ma)
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; block1: ; offset 0x10
+; .byte 0x57, 0x70, 0x08, 0xcc
+; addi t6, sp, 0x10
+; .byte 0x07, 0x84, 0x0f, 0x02
+; .byte 0x57, 0xb5, 0x80, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0x85, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0x85, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0x85, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; .byte 0x27, 0x05, 0x05, 0x02
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+
+function %iadd_const_i16x8(i16x8) -> i16x8 {
+block0(v0: i16x8):
+ v2 = vconst.i16x8 0x01010101_01010101_01010101_01010101
+ v3 = iadd v0, v2
+
+ v4 = vconst.i16x8 0x00010001_00010001_00010001_00010001
+ v5 = iadd v3, v4
+
+ v6 = vconst.i16x8 0x00000001_00000001_00000001_00000001
+ v7 = iadd v5, v6
+
+ v8 = vconst.i16x8 0x00000000_00000001_00000000_00000001
+ v9 = iadd v7, v8
+
+ return v9
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; block0:
+; vle8.v v8,-16(incoming_arg) #avl=16, #vtype=(e8, m1, ta, ma)
+; vle16.v v10,[const(2)] #avl=8, #vtype=(e16, m1, ta, ma)
+; vadd.vv v10,v8,v10 #avl=8, #vtype=(e16, m1, ta, ma)
+; vadd.vi v10,v10,1 #avl=8, #vtype=(e16, m1, ta, ma)
+; vle16.v v11,[const(1)] #avl=8, #vtype=(e16, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=8, #vtype=(e16, m1, ta, ma)
+; vle16.v v11,[const(0)] #avl=8, #vtype=(e16, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=8, #vtype=(e16, m1, ta, ma)
+; vse8.v v10,0(a0) #avl=16, #vtype=(e8, m1, ta, ma)
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; block1: ; offset 0x10
+; .byte 0x57, 0x70, 0x08, 0xcc
+; addi t6, sp, 0x10
+; .byte 0x07, 0x84, 0x0f, 0x02
+; .byte 0x57, 0x70, 0x84, 0xcc
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x07, 0xd5, 0x0f, 0x02
+; .byte 0x57, 0x05, 0x85, 0x02
+; .byte 0x57, 0xb5, 0xa0, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x4c
+; .byte 0x87, 0xd5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x4c
+; .byte 0x87, 0xd5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; .byte 0x57, 0x70, 0x08, 0xcc
+; .byte 0x27, 0x05, 0x05, 0x02
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+
+function %iadd_const_i32x4(i32x4) -> i32x4 {
+block0(v0: i32x4):
+ v2 = vconst.i32x4 0x01010101_01010101_01010101_01010101
+ v3 = iadd v0, v2
+
+ v4 = vconst.i32x4 0x00010001_00010001_00010001_00010001
+ v5 = iadd v3, v4
+
+ v6 = vconst.i32x4 0x00000001_00000001_00000001_00000001
+ v7 = iadd v5, v6
+
+ v8 = vconst.i32x4 0x00000000_00000001_00000000_00000001
+ v9 = iadd v7, v8
+
+ return v9
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; block0:
+; vle8.v v8,-16(incoming_arg) #avl=16, #vtype=(e8, m1, ta, ma)
+; vle32.v v10,[const(2)] #avl=4, #vtype=(e32, m1, ta, ma)
+; vadd.vv v10,v8,v10 #avl=4, #vtype=(e32, m1, ta, ma)
+; vle32.v v11,[const(1)] #avl=4, #vtype=(e32, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=4, #vtype=(e32, m1, ta, ma)
+; vadd.vi v10,v10,1 #avl=4, #vtype=(e32, m1, ta, ma)
+; vle32.v v11,[const(0)] #avl=4, #vtype=(e32, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=4, #vtype=(e32, m1, ta, ma)
+; vse8.v v10,0(a0) #avl=16, #vtype=(e8, m1, ta, ma)
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; block1: ; offset 0x10
+; .byte 0x57, 0x70, 0x08, 0xcc
+; addi t6, sp, 0x10
+; .byte 0x07, 0x84, 0x0f, 0x02
+; .byte 0x57, 0x70, 0x02, 0xcd
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x07, 0xe5, 0x0f, 0x02
+; .byte 0x57, 0x05, 0x85, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0xe5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; .byte 0x57, 0xb5, 0xa0, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x4c
+; .byte 0x87, 0xe5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; .byte 0x57, 0x70, 0x08, 0xcc
+; .byte 0x27, 0x05, 0x05, 0x02
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x00, 0x00, 0x00, 0x00
+
+function %iadd_const_i64x2(i64x2) -> i64x2 {
+block0(v0: i64x2):
+ v2 = vconst.i64x2 0x01010101_01010101_01010101_01010101
+ v3 = iadd v0, v2
+
+ v4 = vconst.i64x2 0x00010001_00010001_00010001_00010001
+ v5 = iadd v3, v4
+
+ v6 = vconst.i64x2 0x00000001_00000001_00000001_00000001
+ v7 = iadd v5, v6
+
+ v8 = vconst.i64x2 0x00000000_00000001_00000000_00000001
+ v9 = iadd v7, v8
+
+ return v9
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; block0:
+; vle8.v v8,-16(incoming_arg) #avl=16, #vtype=(e8, m1, ta, ma)
+; vle64.v v10,[const(2)] #avl=2, #vtype=(e64, m1, ta, ma)
+; vadd.vv v10,v8,v10 #avl=2, #vtype=(e64, m1, ta, ma)
+; vle64.v v11,[const(1)] #avl=2, #vtype=(e64, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=2, #vtype=(e64, m1, ta, ma)
+; vle64.v v11,[const(0)] #avl=2, #vtype=(e64, m1, ta, ma)
+; vadd.vv v10,v10,v11 #avl=2, #vtype=(e64, m1, ta, ma)
+; vadd.vi v10,v10,1 #avl=2, #vtype=(e64, m1, ta, ma)
+; vse8.v v10,0(a0) #avl=16, #vtype=(e8, m1, ta, ma)
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; block1: ; offset 0x10
+; .byte 0x57, 0x70, 0x08, 0xcc
+; addi t6, sp, 0x10
+; .byte 0x07, 0x84, 0x0f, 0x02
+; .byte 0x57, 0x70, 0x81, 0xcd
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x07, 0xf5, 0x0f, 0x02
+; .byte 0x57, 0x05, 0x85, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0xf5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; auipc t6, 0
+; addi t6, t6, 0x50
+; .byte 0x87, 0xf5, 0x0f, 0x02
+; .byte 0x57, 0x85, 0xa5, 0x02
+; .byte 0x57, 0xb5, 0xa0, 0x02
+; .byte 0x57, 0x70, 0x08, 0xcc
+; .byte 0x27, 0x05, 0x05, 0x02
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+; .byte 0x00, 0x00, 0x00, 0x00
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x01, 0x01, 0x01
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x01, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+; .byte 0x01, 0x00, 0x00, 0x00
+
diff --git a/crates/test-util/src/wast.rs b/crates/test-util/src/wast.rs
index dc570ce435..6992ecccbb 100644
--- a/crates/test-util/src/wast.rs
+++ b/crates/test-util/src/wast.rs
@@ -637,6 +637,7 @@ impl WastTest {
"misc_testsuite/simd/sse-cannot-fold-unaligned-loads.wast",
"misc_testsuite/winch/issue-10331.wast",
"misc_testsuite/winch/replace_lane.wast",
+ "misc_testsuite/simd/riscv64-replicated-imm5-works.wast",
"spec_testsuite/simd_align.wast",
"spec_testsuite/simd_boolean.wast",
"spec_testsuite/simd_conversions.wast",
diff --git a/tests/misc_testsuite/simd/riscv64-replicated-imm5-works.wast b/tests/misc_testsuite/simd/riscv64-replicated-imm5-works.wast
new file mode 100644
index 0000000000..bed4ea723e
--- /dev/null
+++ b/tests/misc_testsuite/simd/riscv64-replicated-imm5-works.wast
@@ -0,0 +1,12 @@
+;;! simd = true
+
+(module
+ (memory (export "mem") 1)
+ (func (export "add_and_extract") (param v128) (result i32)
+ (i32x4.extract_lane 0
+ (i32x4.add
+ (local.get 0)
+ (i32x4.splat (i32.const 0x01010101))))))
+
+(assert_return (invoke "add_and_extract" (v128.const i32x4 0 0 0 0))
+ (i32.const 0x01010101))