@@ -1059,6 +1059,19 @@ define <vscale x 16 x i8> @sqadd_b_lowimm(<vscale x 16 x i8> %a) {
10591059 ret <vscale x 16 x i8 > %out
10601060}
10611061
1062+ ; Immediate instruction form only supports positive values.
1063+ define <vscale x 16 x i8 > @sqadd_b_negimm (<vscale x 16 x i8 > %a ) {
1064+ ; CHECK-LABEL: sqadd_b_negimm:
1065+ ; CHECK: // %bb.0:
1066+ ; CHECK-NEXT: sqsub z0.b, z0.b, #128 // =0x80
1067+ ; CHECK-NEXT: ret
1068+ %elt = insertelement <vscale x 16 x i8 > undef , i8 -128 , i32 0
1069+ %splat = shufflevector <vscale x 16 x i8 > %elt , <vscale x 16 x i8 > undef , <vscale x 16 x i32 > zeroinitializer
1070+ %out = call <vscale x 16 x i8 > @llvm.aarch64.sve.sqadd.x.nxv16i8 (<vscale x 16 x i8 > %a ,
1071+ <vscale x 16 x i8 > %splat )
1072+ ret <vscale x 16 x i8 > %out
1073+ }
1074+
10621075define <vscale x 8 x i16 > @sqadd_h_lowimm (<vscale x 8 x i16 > %a ) {
10631076; CHECK-LABEL: sqadd_h_lowimm:
10641077; CHECK: // %bb.0:
@@ -1083,6 +1096,19 @@ define <vscale x 8 x i16> @sqadd_h_highimm(<vscale x 8 x i16> %a) {
10831096 ret <vscale x 8 x i16 > %out
10841097}
10851098
1099+ ; Immediate instruction form only supports positive values.
1100+ define <vscale x 8 x i16 > @sqadd_h_negimm (<vscale x 8 x i16 > %a ) {
1101+ ; CHECK-LABEL: sqadd_h_negimm:
1102+ ; CHECK: // %bb.0:
1103+ ; CHECK-NEXT: sqsub z0.h, z0.h, #1 // =0x1
1104+ ; CHECK-NEXT: ret
1105+ %elt = insertelement <vscale x 8 x i16 > undef , i16 -1 , i32 0
1106+ %splat = shufflevector <vscale x 8 x i16 > %elt , <vscale x 8 x i16 > undef , <vscale x 8 x i32 > zeroinitializer
1107+ %out = call <vscale x 8 x i16 > @llvm.aarch64.sve.sqadd.x.nxv8i16 (<vscale x 8 x i16 > %a ,
1108+ <vscale x 8 x i16 > %splat )
1109+ ret <vscale x 8 x i16 > %out
1110+ }
1111+
10861112define <vscale x 4 x i32 > @sqadd_s_lowimm (<vscale x 4 x i32 > %a ) {
10871113; CHECK-LABEL: sqadd_s_lowimm:
10881114; CHECK: // %bb.0:
@@ -1107,6 +1133,19 @@ define <vscale x 4 x i32> @sqadd_s_highimm(<vscale x 4 x i32> %a) {
11071133 ret <vscale x 4 x i32 > %out
11081134}
11091135
1136+ ; Immediate instruction form only supports positive values.
1137+ define <vscale x 4 x i32 > @sqadd_s_negimm (<vscale x 4 x i32 > %a ) {
1138+ ; CHECK-LABEL: sqadd_s_negimm:
1139+ ; CHECK: // %bb.0:
1140+ ; CHECK-NEXT: sqsub z0.s, z0.s, #65280 // =0xff00
1141+ ; CHECK-NEXT: ret
1142+ %elt = insertelement <vscale x 4 x i32 > undef , i32 -65280 , i32 0
1143+ %splat = shufflevector <vscale x 4 x i32 > %elt , <vscale x 4 x i32 > undef , <vscale x 4 x i32 > zeroinitializer
1144+ %out = call <vscale x 4 x i32 > @llvm.aarch64.sve.sqadd.x.nxv4i32 (<vscale x 4 x i32 > %a ,
1145+ <vscale x 4 x i32 > %splat )
1146+ ret <vscale x 4 x i32 > %out
1147+ }
1148+
11101149define <vscale x 2 x i64 > @sqadd_d_lowimm (<vscale x 2 x i64 > %a ) {
11111150; CHECK-LABEL: sqadd_d_lowimm:
11121151; CHECK: // %bb.0:
@@ -1131,6 +1170,19 @@ define <vscale x 2 x i64> @sqadd_d_highimm(<vscale x 2 x i64> %a) {
11311170 ret <vscale x 2 x i64 > %out
11321171}
11331172
1173+ ; Immediate instruction form only supports positive values.
1174+ define <vscale x 2 x i64 > @sqadd_d_negimm (<vscale x 2 x i64 > %a ) {
1175+ ; CHECK-LABEL: sqadd_d_negimm:
1176+ ; CHECK: // %bb.0:
1177+ ; CHECK-NEXT: sqsub z0.d, z0.d, #3840 // =0xf00
1178+ ; CHECK-NEXT: ret
1179+ %elt = insertelement <vscale x 2 x i64 > undef , i64 -3840 , i32 0
1180+ %splat = shufflevector <vscale x 2 x i64 > %elt , <vscale x 2 x i64 > undef , <vscale x 2 x i32 > zeroinitializer
1181+ %out = call <vscale x 2 x i64 > @llvm.aarch64.sve.sqadd.x.nxv2i64 (<vscale x 2 x i64 > %a ,
1182+ <vscale x 2 x i64 > %splat )
1183+ ret <vscale x 2 x i64 > %out
1184+ }
1185+
11341186; SQSUB
11351187
11361188define <vscale x 16 x i8 > @sqsub_b_lowimm (<vscale x 16 x i8 > %a ) {
@@ -1145,6 +1197,19 @@ define <vscale x 16 x i8> @sqsub_b_lowimm(<vscale x 16 x i8> %a) {
11451197 ret <vscale x 16 x i8 > %out
11461198}
11471199
1200+ ; Immediate instruction form only supports positive values.
1201+ define <vscale x 16 x i8 > @sqsub_b_negimm (<vscale x 16 x i8 > %a ) {
1202+ ; CHECK-LABEL: sqsub_b_negimm:
1203+ ; CHECK: // %bb.0:
1204+ ; CHECK-NEXT: sqadd z0.b, z0.b, #1 // =0x1
1205+ ; CHECK-NEXT: ret
1206+ %elt = insertelement <vscale x 16 x i8 > undef , i8 -1 , i32 0
1207+ %splat = shufflevector <vscale x 16 x i8 > %elt , <vscale x 16 x i8 > undef , <vscale x 16 x i32 > zeroinitializer
1208+ %out = call <vscale x 16 x i8 > @llvm.aarch64.sve.sqsub.x.nxv16i8 (<vscale x 16 x i8 > %a ,
1209+ <vscale x 16 x i8 > %splat )
1210+ ret <vscale x 16 x i8 > %out
1211+ }
1212+
11481213define <vscale x 8 x i16 > @sqsub_h_lowimm (<vscale x 8 x i16 > %a ) {
11491214; CHECK-LABEL: sqsub_h_lowimm:
11501215; CHECK: // %bb.0:
@@ -1169,6 +1234,19 @@ define <vscale x 8 x i16> @sqsub_h_highimm(<vscale x 8 x i16> %a) {
11691234 ret <vscale x 8 x i16 > %out
11701235}
11711236
1237+ ; Immediate instruction form only supports positive values.
1238+ define <vscale x 8 x i16 > @sqsub_h_negimm (<vscale x 8 x i16 > %a ) {
1239+ ; CHECK-LABEL: sqsub_h_negimm:
1240+ ; CHECK: // %bb.0:
1241+ ; CHECK-NEXT: sqadd z0.h, z0.h, #128 // =0x80
1242+ ; CHECK-NEXT: ret
1243+ %elt = insertelement <vscale x 8 x i16 > undef , i16 -128 , i32 0
1244+ %splat = shufflevector <vscale x 8 x i16 > %elt , <vscale x 8 x i16 > undef , <vscale x 8 x i32 > zeroinitializer
1245+ %out = call <vscale x 8 x i16 > @llvm.aarch64.sve.sqsub.x.nxv8i16 (<vscale x 8 x i16 > %a ,
1246+ <vscale x 8 x i16 > %splat )
1247+ ret <vscale x 8 x i16 > %out
1248+ }
1249+
11721250define <vscale x 4 x i32 > @sqsub_s_lowimm (<vscale x 4 x i32 > %a ) {
11731251; CHECK-LABEL: sqsub_s_lowimm:
11741252; CHECK: // %bb.0:
@@ -1193,6 +1271,19 @@ define <vscale x 4 x i32> @sqsub_s_highimm(<vscale x 4 x i32> %a) {
11931271 ret <vscale x 4 x i32 > %out
11941272}
11951273
1274+ ; Immediate instruction form only supports positive values.
1275+ define <vscale x 4 x i32 > @sqsub_s_negimm (<vscale x 4 x i32 > %a ) {
1276+ ; CHECK-LABEL: sqsub_s_negimm:
1277+ ; CHECK: // %bb.0:
1278+ ; CHECK-NEXT: sqadd z0.s, z0.s, #32768 // =0x8000
1279+ ; CHECK-NEXT: ret
1280+ %elt = insertelement <vscale x 4 x i32 > undef , i32 -32768 , i32 0
1281+ %splat = shufflevector <vscale x 4 x i32 > %elt , <vscale x 4 x i32 > undef , <vscale x 4 x i32 > zeroinitializer
1282+ %out = call <vscale x 4 x i32 > @llvm.aarch64.sve.sqsub.x.nxv4i32 (<vscale x 4 x i32 > %a ,
1283+ <vscale x 4 x i32 > %splat )
1284+ ret <vscale x 4 x i32 > %out
1285+ }
1286+
11961287define <vscale x 2 x i64 > @sqsub_d_lowimm (<vscale x 2 x i64 > %a ) {
11971288; CHECK-LABEL: sqsub_d_lowimm:
11981289; CHECK: // %bb.0:
@@ -1217,6 +1308,19 @@ define <vscale x 2 x i64> @sqsub_d_highimm(<vscale x 2 x i64> %a) {
12171308 ret <vscale x 2 x i64 > %out
12181309}
12191310
1311+ ; Immediate instruction form only supports positive values.
1312+ define <vscale x 2 x i64 > @sqsub_d_negimm (<vscale x 2 x i64 > %a ) {
1313+ ; CHECK-LABEL: sqsub_d_negimm:
1314+ ; CHECK: // %bb.0:
1315+ ; CHECK-NEXT: sqadd z0.d, z0.d, #57344 // =0xe000
1316+ ; CHECK-NEXT: ret
1317+ %elt = insertelement <vscale x 2 x i64 > undef , i64 -57344 , i32 0
1318+ %splat = shufflevector <vscale x 2 x i64 > %elt , <vscale x 2 x i64 > undef , <vscale x 2 x i32 > zeroinitializer
1319+ %out = call <vscale x 2 x i64 > @llvm.aarch64.sve.sqsub.x.nxv2i64 (<vscale x 2 x i64 > %a ,
1320+ <vscale x 2 x i64 > %splat )
1321+ ret <vscale x 2 x i64 > %out
1322+ }
1323+
12201324; UQADD
12211325
12221326define <vscale x 16 x i8 > @uqadd_b_lowimm (<vscale x 16 x i8 > %a ) {
0 commit comments