[AArch64] Port SIMD narrowing to ISLE (#4478)

* [AArch64] Port SIMD narrowing to ISLE

Fvdemote, snarrow, unarrow and uunarrow.

Also refactor the aarch64 instructions descriptions to parameterize
on ScalarSize instead of using different opcodes.

The zero_value pure constructor has been introduced and used by the
integer narrow operations and it replaces, and extends, the compare
zero patterns.

Copright (c) 2022, Arm Limited.

* use short 'if' patterns
This commit is contained in:
Sam Parker
2022-07-25 20:40:36 +01:00
committed by GitHub
parent dd40bf075a
commit c5ddb4b803
15 changed files with 1340 additions and 337 deletions

View File

@@ -14,6 +14,17 @@ block0(v0: i8x16):
; cmeq v0.16b, v0.16b, #0
; ret
function %f0_vconst(i8x16) -> b8x16 {
block0(v0: i8x16):
v1 = vconst.i8x16 0x00
v2 = icmp eq v0, v1
return v2
}
; block0:
; cmeq v0.16b, v0.16b, #0
; ret
function %f1(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = iconst.i16 0
@@ -26,6 +37,17 @@ block0(v0: i16x8):
; cmeq v0.8h, v0.8h, #0
; ret
function %f1_vconst(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = icmp eq v1, v0
return v2
}
; block0:
; cmeq v0.8h, v0.8h, #0
; ret
function %f2(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = iconst.i32 0
@@ -39,6 +61,18 @@ block0(v0: i32x4):
; mvn v0.16b, v3.16b
; ret
function %f2_vconst(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = icmp ne v0, v1
return v2
}
; block0:
; cmeq v3.4s, v0.4s, #0
; mvn v0.16b, v3.16b
; ret
function %f3(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = iconst.i64 0
@@ -52,6 +86,18 @@ block0(v0: i64x2):
; mvn v0.16b, v3.16b
; ret
function %f3_vconst(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = icmp ne v1, v0
return v2
}
; block0:
; cmeq v3.2d, v0.2d, #0
; mvn v0.16b, v3.16b
; ret
function %f4(i8x16) -> b8x16 {
block0(v0: i8x16):
v1 = iconst.i8 0
@@ -64,6 +110,17 @@ block0(v0: i8x16):
; cmle v0.16b, v0.16b, #0
; ret
function %f4_vconst(i8x16) -> b8x16 {
block0(v0: i8x16):
v1 = vconst.i8x16 0x00
v2 = icmp sle v0, v1
return v2
}
; block0:
; cmle v0.16b, v0.16b, #0
; ret
function %f5(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = iconst.i16 0
@@ -76,6 +133,17 @@ block0(v0: i16x8):
; cmge v0.8h, v0.8h, #0
; ret
function %f5_vconst(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = icmp sle v1, v0
return v2
}
; block0:
; cmge v0.8h, v0.8h, #0
; ret
function %f6(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = iconst.i32 0
@@ -88,6 +156,17 @@ block0(v0: i32x4):
; cmge v0.4s, v0.4s, #0
; ret
function %f6_vconst(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = icmp sge v0, v1
return v2
}
; block0:
; cmge v0.4s, v0.4s, #0
; ret
function %f7(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = iconst.i64 0
@@ -100,6 +179,17 @@ block0(v0: i64x2):
; cmle v0.2d, v0.2d, #0
; ret
function %f7_vconst(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = icmp sge v1, v0
return v2
}
; block0:
; cmle v0.2d, v0.2d, #0
; ret
function %f8(i8x16) -> b8x16 {
block0(v0: i8x16):
v1 = iconst.i8 0
@@ -112,6 +202,17 @@ block0(v0: i8x16):
; cmlt v0.16b, v0.16b, #0
; ret
function %f8_vconst(i8x16) -> b8x16 {
block0(v0: i8x16):
v1 = vconst.i8x16 0x00
v2 = icmp slt v0, v1
return v2
}
; block0:
; cmlt v0.16b, v0.16b, #0
; ret
function %f9(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = iconst.i16 0
@@ -124,6 +225,17 @@ block0(v0: i16x8):
; cmgt v0.8h, v0.8h, #0
; ret
function %f9_vconst(i16x8) -> b16x8 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = icmp slt v1, v0
return v2
}
; block0:
; cmgt v0.8h, v0.8h, #0
; ret
function %f10(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = iconst.i32 0
@@ -136,6 +248,17 @@ block0(v0: i32x4):
; cmgt v0.4s, v0.4s, #0
; ret
function %f10_vconst(i32x4) -> b32x4 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = icmp sgt v0, v1
return v2
}
; block0:
; cmgt v0.4s, v0.4s, #0
; ret
function %f11(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = iconst.i64 0
@@ -148,6 +271,17 @@ block0(v0: i64x2):
; cmlt v0.2d, v0.2d, #0
; ret
function %f11_vconst(i64x2) -> b64x2 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = icmp sgt v1, v0
return v2
}
; block0:
; cmlt v0.2d, v0.2d, #0
; ret
function %f12(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -160,6 +294,17 @@ block0(v0: f32x4):
; fcmeq v0.4s, v0.4s, #0.0
; ret
function %f12_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp eq v0, v1
return v2
}
; block0:
; fcmeq v0.4s, v0.4s, #0.0
; ret
function %f13(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -172,6 +317,17 @@ block0(v0: f64x2):
; fcmeq v0.2d, v0.2d, #0.0
; ret
function %f13_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp eq v1, v0
return v2
}
; block0:
; fcmeq v0.2d, v0.2d, #0.0
; ret
function %f14(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -185,6 +341,18 @@ block0(v0: f64x2):
; mvn v0.16b, v3.16b
; ret
function %f14_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp ne v0, v1
return v2
}
; block0:
; fcmeq v3.2d, v0.2d, #0.0
; mvn v0.16b, v3.16b
; ret
function %f15(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -198,6 +366,18 @@ block0(v0: f32x4):
; mvn v0.16b, v3.16b
; ret
function %f15_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp ne v1, v0
return v2
}
; block0:
; fcmeq v3.4s, v0.4s, #0.0
; mvn v0.16b, v3.16b
; ret
function %f16(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -210,6 +390,17 @@ block0(v0: f32x4):
; fcmle v0.4s, v0.4s, #0.0
; ret
function %f16_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp le v0, v1
return v2
}
; block0:
; fcmle v0.4s, v0.4s, #0.0
; ret
function %f17(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -222,6 +413,17 @@ block0(v0: f64x2):
; fcmge v0.2d, v0.2d, #0.0
; ret
function %f17_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp le v1, v0
return v2
}
; block0:
; fcmge v0.2d, v0.2d, #0.0
; ret
function %f18(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -234,6 +436,17 @@ block0(v0: f64x2):
; fcmge v0.2d, v0.2d, #0.0
; ret
function %f18_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp ge v0, v1
return v2
}
; block0:
; fcmge v0.2d, v0.2d, #0.0
; ret
function %f19(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -246,6 +459,17 @@ block0(v0: f32x4):
; fcmle v0.4s, v0.4s, #0.0
; ret
function %f19_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp ge v1, v0
return v2
}
; block0:
; fcmle v0.4s, v0.4s, #0.0
; ret
function %f20(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -258,6 +482,17 @@ block0(v0: f32x4):
; fcmlt v0.4s, v0.4s, #0.0
; ret
function %f20_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp lt v0, v1
return v2
}
; block0:
; fcmlt v0.4s, v0.4s, #0.0
; ret
function %f21(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -270,6 +505,17 @@ block0(v0: f64x2):
; fcmgt v0.2d, v0.2d, #0.0
; ret
function %f21_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp lt v1, v0
return v2
}
; block0:
; fcmgt v0.2d, v0.2d, #0.0
; ret
function %f22(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = f64const 0.0
@@ -282,6 +528,17 @@ block0(v0: f64x2):
; fcmgt v0.2d, v0.2d, #0.0
; ret
function %f22_vconst(f64x2) -> b64x2 {
block0(v0: f64x2):
v1 = vconst.f64x2 [0.0 0.0]
v2 = fcmp gt v0, v1
return v2
}
; block0:
; fcmgt v0.2d, v0.2d, #0.0
; ret
function %f23(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = f32const 0.0
@@ -294,3 +551,13 @@ block0(v0: f32x4):
; fcmlt v0.4s, v0.4s, #0.0
; ret
function %f23_vconst(f32x4) -> b32x4 {
block0(v0: f32x4):
v1 = vconst.f32x4 [0.0 0.0 0.0 0.0]
v2 = fcmp gt v1, v0
return v2
}
; block0:
; fcmlt v0.4s, v0.4s, #0.0
; ret

View File

@@ -1,6 +1,26 @@
test compile
test compile precise-output
target aarch64
function %snarrow_i16x4(i16) -> i8x8 {
gv0 = dyn_scale_target_const.i16x4
gv1 = dyn_scale_target_const.i8x8
dt0 = i16x4*gv0
dt1 = i8x8*gv0
block0(v0: i16):
v1 = splat.dt0 v0
v2 = snarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.4h, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; sqxtn v0.8b, v7.8h
; ret
function %snarrow_i16x8(i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
@@ -14,10 +34,31 @@ block0(v0: i16):
return v3
}
; check: dup v2.8h, w0
; nextln: sqxtn v0.8b, v2.8h
; nextln: sqxtn2 v0.16b, v2.8h
; nextln: ret
; block0:
; dup v2.8h, w0
; sqxtn v0.8b, v2.8h
; sqxtn2 v0.16b, v2.8h
; ret
function %snarrow_i32x2(i32) -> i16x4 {
gv0 = dyn_scale_target_const.i32x2
gv1 = dyn_scale_target_const.i16x4
dt0 = i32x2*gv0
dt1 = i16x4*gv0
block0(v0: i32):
v1 = splat.dt0 v0
v2 = snarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.2s, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; sqxtn v0.4h, v7.4s
; ret
function %snarrow_i32x4(i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
@@ -32,10 +73,11 @@ block0(v0: i32):
return v3
}
; check: dup v2.4s, w0
; nextln: sqxtn v0.4h, v2.4s
; nextln: sqxtn2 v0.8h, v2.4s
; nextln: ret
; block0:
; dup v2.4s, w0
; sqxtn v0.4h, v2.4s
; sqxtn2 v0.8h, v2.4s
; ret
function %snarrow_i64x2(i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
@@ -50,10 +92,31 @@ block0(v0: i64):
return v3
}
; check: dup v2.2d, x0
; nextln: sqxtn v0.2s, v2.2d
; nextln: sqxtn2 v0.4s, v2.2d
; nextln: ret
; block0:
; dup v2.2d, x0
; sqxtn v0.2s, v2.2d
; sqxtn2 v0.4s, v2.2d
; ret
function %unarrow_i16x4(i16) -> i8x8 {
gv0 = dyn_scale_target_const.i16x4
gv1 = dyn_scale_target_const.i8x8
dt0 = i16x4*gv0
dt1 = i8x8*gv0
block0(v0: i16):
v1 = splat.dt0 v0
v2 = unarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.4h, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; sqxtun v0.8b, v7.8h
; ret
function %unarrow_i16x8(i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
@@ -68,10 +131,31 @@ block0(v0: i16):
return v3
}
; check: dup v2.8h, w0
; nextln: sqxtun v0.8b, v2.8h
; nextln: sqxtun2 v0.16b, v2.8h
; nextln: ret
; block0:
; dup v2.8h, w0
; sqxtun v0.8b, v2.8h
; sqxtun2 v0.16b, v2.8h
; ret
function %unarrow_i32x2(i32) -> i16x4 {
gv0 = dyn_scale_target_const.i32x2
gv1 = dyn_scale_target_const.i16x4
dt0 = i32x2*gv0
dt1 = i16x4*gv0
block0(v0: i32):
v1 = splat.dt0 v0
v2 = unarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.2s, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; sqxtun v0.4h, v7.4s
; ret
function %unarrow_i32x4(i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
@@ -86,10 +170,11 @@ block0(v0: i32):
return v3
}
; check: dup v2.4s, w0
; nextln: sqxtun v0.4h, v2.4s
; nextln: sqxtun2 v0.8h, v2.4s
; nextln: ret
; block0:
; dup v2.4s, w0
; sqxtun v0.4h, v2.4s
; sqxtun2 v0.8h, v2.4s
; ret
function %unarrow_i64x2(i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
@@ -104,10 +189,31 @@ block0(v0: i64):
return v3
}
; check: dup v2.2d, x0
; nextln: sqxtun v0.2s, v2.2d
; nextln: sqxtun2 v0.4s, v2.2d
; nextln: ret
; block0:
; dup v2.2d, x0
; sqxtun v0.2s, v2.2d
; sqxtun2 v0.4s, v2.2d
; ret
function %uunarrow_i16x4(i16) -> i8x8 {
gv0 = dyn_scale_target_const.i16x4
gv1 = dyn_scale_target_const.i8x8
dt0 = i16x4*gv0
dt1 = i8x8*gv0
block0(v0: i16):
v1 = splat.dt0 v0
v2 = uunarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.4h, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; uqxtn v0.8b, v7.8h
; ret
function %uunarrow_i16x8(i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
@@ -122,10 +228,31 @@ block0(v0: i16):
return v3
}
; check: dup v2.8h, w0
; nextln: uqxtn v0.8b, v2.8h
; nextln: uqxtn2 v0.16b, v2.8h
; nextln: ret
; block0:
; dup v2.8h, w0
; uqxtn v0.8b, v2.8h
; uqxtn2 v0.16b, v2.8h
; ret
function %uunarrow_i32x2(i32) -> i16x4 {
gv0 = dyn_scale_target_const.i32x2
gv1 = dyn_scale_target_const.i16x4
dt0 = i32x2*gv0
dt1 = i16x4*gv0
block0(v0: i32):
v1 = splat.dt0 v0
v2 = uunarrow.dt0 v1, v1
v3 = extract_vector v2, 0
return v3
}
; block0:
; dup v2.2s, w0
; mov v7.16b, v2.16b
; mov v7.d[1], v2.d[0]
; uqxtn v0.4h, v7.4s
; ret
function %uunarrow_i32x4(i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
@@ -140,10 +267,11 @@ block0(v0: i32):
return v3
}
; check: dup v2.4s, w0
; nextln: uqxtn v0.4h, v2.4s
; nextln: uqxtn2 v0.8h, v2.4s
; nextln: ret
; block0:
; dup v2.4s, w0
; uqxtn v0.4h, v2.4s
; uqxtn2 v0.8h, v2.4s
; ret
function %uunarrow_i64x2(i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
@@ -158,7 +286,9 @@ block0(v0: i64):
return v3
}
; check: dup v2.2d, x0
; nextln: uqxtn v0.2s, v2.2d
; nextln: uqxtn2 v0.4s, v2.2d
; nextln: ret
; block0:
; dup v2.2d, x0
; uqxtn v0.2s, v2.2d
; uqxtn2 v0.4s, v2.2d
; ret

View File

@@ -0,0 +1,268 @@
test compile precise-output
set unwind_info=false
target aarch64
function %snarrow_i16x4(i16x4, i16x4) -> i8x8 {
block0(v0: i16x4, v1: i16x4):
v2 = snarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; sqxtn v0.8b, v0.8h
; ret
function %snarrow_i16x8(i16x8, i16x8) -> i8x16 {
block0(v0: i16x8, v1: i16x8):
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.8b, v0.8h
; sqxtn2 v0.16b, v1.8h
; ret
function %snarrow_i32x2(i32x2, i32x2) -> i16x4 {
block0(v0: i32x2, v1: i32x2):
v2 = snarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; sqxtn v0.4h, v0.4s
; ret
function %snarrow_i32x4(i32x4, i32x4) -> i16x8 {
block0(v0: i32x4, v1: i32x4):
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.4h, v0.4s
; sqxtn2 v0.8h, v1.4s
; ret
function %snarrow_i64x2(i64x2, i64x2) -> i32x4 {
block0(v0: i64x2, v1: i64x2):
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.2s, v0.2d
; sqxtn2 v0.4s, v1.2d
; ret
function %unarrow_i16x4(i16x4, i16x4) -> i8x8 {
block0(v0: i16x4, v1: i16x4):
v2 = unarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; sqxtun v0.8b, v0.8h
; ret
function %unarrow_i16x8(i16x8, i16x8) -> i8x16 {
block0(v0: i16x8, v1: i16x8):
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.8b, v0.8h
; sqxtun2 v0.16b, v1.8h
; ret
function %unarrow_i32x2(i32x2, i32x2) -> i16x4 {
block0(v0: i32x2, v1: i32x2):
v2 = unarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; sqxtun v0.4h, v0.4s
; ret
function %unarrow_i32x4(i32x4, i32x4) -> i16x8 {
block0(v0: i32x4, v1: i32x4):
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.4h, v0.4s
; sqxtun2 v0.8h, v1.4s
; ret
function %unarrow_i64x2(i64x2, i64x2) -> i32x4 {
block0(v0: i64x2, v1: i64x2):
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.2s, v0.2d
; sqxtun2 v0.4s, v1.2d
; ret
function %uunarrow_i16x4(i16x4, i16x4) -> i8x8 {
block0(v0: i16x4, v1: i16x4):
v2 = uunarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; uqxtn v0.8b, v0.8h
; ret
function %uunarrow_i16x8(i16x8, i16x8) -> i8x16 {
block0(v0: i16x8, v1: i16x8):
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.8b, v0.8h
; uqxtn2 v0.16b, v1.8h
; ret
function %uunarrow_i32x2(i32x2, i32x2) -> i16x4 {
block0(v0: i32x2, v1: i32x2):
v2 = uunarrow v0, v1
return v2
}
; block0:
; mov v0.d[1], v1.d[0]
; uqxtn v0.4h, v0.4s
; ret
function %uunarrow_i32x4(i32x4, i32x4) -> i16x8 {
block0(v0: i32x4, v1: i32x4):
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.4h, v0.4s
; uqxtn2 v0.8h, v1.4s
; ret
function %uunarrow_i64x2(i64x2, i64x2) -> i32x4 {
block0(v0: i64x2, v1: i64x2):
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.2s, v0.2d
; uqxtn2 v0.4s, v1.2d
; ret
function %snarrow_i16x8_zero(i16x8) -> i8x16 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.8b, v0.8h
; ret
function %snarrow_i32x4_zero(i32x4) -> i16x8 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.4h, v0.4s
; ret
function %snarrow_i64x2_zero(i64x2) -> i32x4 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = snarrow v0, v1
return v2
}
; block0:
; sqxtn v0.2s, v0.2d
; ret
function %unarrow_i16x8_zero(i16x8) -> i8x16 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.8b, v0.8h
; ret
function %unarrow_i32x4_zero(i32x4) -> i16x8 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.4h, v0.4s
; ret
function %unarrow_i64x2_zero(i64x2) -> i32x4 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = unarrow v0, v1
return v2
}
; block0:
; sqxtun v0.2s, v0.2d
; ret
function %uunarrow_i16x8_zero(i16x8) -> i8x16 {
block0(v0: i16x8):
v1 = vconst.i16x8 0x00
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.8b, v0.8h
; ret
function %uunarrow_i32x4_zero(i32x4) -> i16x8 {
block0(v0: i32x4):
v1 = vconst.i32x4 0x00
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.4h, v0.4s
; ret
function %uunarrow_i64x2_zero(i64x2) -> i32x4 {
block0(v0: i64x2):
v1 = vconst.i64x2 0x00
v2 = uunarrow v0, v1
return v2
}
; block0:
; uqxtn v0.2s, v0.2d
; ret

View File

@@ -0,0 +1,230 @@
test run
target aarch64
function %snarrow_i16x8(i16, i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
dt0 = i16x8*gv0
dt1 = i8x16*gv0
block0(v0: i16, v1: i16):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = snarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %snarrow_i16x8(1, -1) == [1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1]
; run: %snarrow_i16x8(32767, -32768) == [127 127 127 127 127 127 127 127 -128 -128 -128 -128 -128 -128 -128 -128]
function %snarrow_i32x4(i32, i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i16x8
dt0 = i32x4*gv0
dt1 = i16x8*gv0
block0(v0: i32, v1: i32):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = snarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %snarrow_i32x4(1, -1) == [1 1 1 1 -1 -1 -1 -1]
; run: %snarrow_i32x4(-65536, 65535) == [-32768 -32768 -32768 -32768 32767 32767 32767 32767]
function %snarrow_i64x2(i64, i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
gv1 = dyn_scale_target_const.i32x4
dt0 = i64x2*gv0
dt1 = i32x4*gv0
block0(v0: i64, v1: i64):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = snarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %snarrow_i64x2(-65536, -5000000000) == [-65536 -65536 -2147483648 -2147483648]
; run: %snarrow_i64x2(65535, 5000000000) == [65535 65535 2147483647 2147483647]
function %unarrow_i16x8(i16, i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
dt0 = i16x8*gv0
dt1 = i8x16*gv0
block0(v0: i16, v1:i16):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = unarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %unarrow_i16x8(1, -1) == [1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0]
; run: %unarrow_i16x8(32767, -32768) == [255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0]
function %unarrow_i32x4(i32, i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i16x8
dt0 = i32x4*gv0
dt1 = i16x8*gv0
block0(v0: i32, v1: i32):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = unarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %unarrow_i32x4(1, -1) == [1 1 1 1 0 0 0 0]
; run: %unarrow_i32x4(65536, -65536) == [65535 65535 65535 65535 0 0 0 0]
function %unarrow_i64x2(i64, i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
gv1 = dyn_scale_target_const.i32x4
dt0 = i64x2*gv0
dt1 = i32x4*gv0
block0(v0: i64, v1: i64):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = unarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %unarrow_i64x2(1, -1) == [1 1 0 0]
; run: %unarrow_i64x2(4294967296, 1) == [4294967295 4294967295 1 1]
function %uunarrow_i16x8(i16, i16) -> i8x16 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
dt0 = i16x8*gv0
dt1 = i8x16*gv0
block0(v0: i16, v1:i16):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = uunarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %uunarrow_i16x8(1, -1) == [1 1 1 1 1 1 1 1 255 255 255 255 255 255 255 255]
; run: %uunarrow_i16x8(32767, -32768) == [255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255]
function %uunarrow_i32x4(i32, i32) -> i16x8 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i16x8
dt0 = i32x4*gv0
dt1 = i16x8*gv0
block0(v0: i32, v1: i32):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = uunarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %uunarrow_i32x4(1, -1) == [1 1 1 1 65535 65535 65535 65535]
; run: %uunarrow_i32x4(65536, -65536) == [65535 65535 65535 65535 65535 65535 65535 65535]
function %uunarrow_i64x2(i64, i64) -> i32x4 {
gv0 = dyn_scale_target_const.i64x2
gv1 = dyn_scale_target_const.i32x4
dt0 = i64x2*gv0
dt1 = i32x4*gv0
block0(v0: i64, v1: i64):
v2 = splat.dt0 v0
v3 = splat.dt0 v1
v4 = uunarrow.dt0 v2, v3
v5 = extract_vector v4, 0
return v5
}
; run: %uunarrow_i64x2(1, -1) == [1 1 4294967295 4294967295]
; run: %uunarrow_i64x2(4294967296, 1) == [4294967295 4294967295 1 1]
function %swidenhigh_i8x16(i8) -> i16x8 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
dt0 = i8x16*gv1
dt1 = i16x8*gv0
block0(v0: i8):
v1 = splat.dt0 v0
v2 = swiden_high v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i8x16(9) == [9 9 9 9 9 9 9 9]
function %swidenhigh_i16x8(i16) -> i32x4 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i16x8
dt0 = i16x8*gv1
dt1 = i32x4*gv0
block0(v0: i16):
v1 = splat.dt0 v0
v2 = swiden_high v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i16x8(-8) == [-8 -8 -8 -8]
function %swidenhigh_i32x4(i32) -> i64x2 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i64x2
dt0 = i64x2*gv1
dt1 = i32x4*gv0
block0(v0: i32):
v1 = splat.dt1 v0
v2 = swiden_high v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i32x4(-4) == [-4 -4]
function %swidenlow_i8x16(i8) -> i16x8 {
gv0 = dyn_scale_target_const.i16x8
gv1 = dyn_scale_target_const.i8x16
dt0 = i8x16*gv1
dt1 = i16x8*gv0
block0(v0: i8):
v1 = splat.dt0 v0
v2 = swiden_low v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i8x16(9) == [9 9 9 9 9 9 9 9]
function %swidenlow_i16x8(i16) -> i32x4 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i16x8
dt0 = i16x8*gv1
dt1 = i32x4*gv0
block0(v0: i16):
v1 = splat.dt0 v0
v2 = swiden_low v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i16x8(-8) == [-8 -8 -8 -8]
function %swidenlow_i32x4(i32) -> i64x2 {
gv0 = dyn_scale_target_const.i32x4
gv1 = dyn_scale_target_const.i64x2
dt0 = i64x2*gv1
dt1 = i32x4*gv0
block0(v0: i32):
v1 = splat.dt1 v0
v2 = swiden_low v1
v3 = extract_vector v2, 0
return v3
}
; run: %swidenhigh_i32x4(-4) == [-4 -4]