[AArch64][GlobalISel] Legalize arithmetic ops for <4 x s16>
authorAmara Emerson <amara@apple.com>
Fri, 18 Sep 2020 23:45:12 +0000 (16:45 -0700)
committerAmara Emerson <amara@apple.com>
Sat, 19 Sep 2020 00:13:55 +0000 (17:13 -0700)
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir
llvm/test/CodeGen/AArch64/arm64-vabs.ll

index a0af333..b69a70b 100644 (file)
@@ -90,7 +90,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
       .widenScalarToNextPow2(0);
 
   getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
-      .legalFor({s32, s64, v2s32, v4s32, v2s64, v8s16, v16s8})
+      .legalFor({s32, s64, v2s32, v4s32, v2s64, v4s16, v8s16, v16s8})
       .clampScalar(0, s32, s64)
       .widenScalarToNextPow2(0)
       .clampNumElements(0, v2s32, v4s32)
index a90d899..21ea67c 100644 (file)
@@ -161,14 +161,6 @@ entry:
   ret i32 0
 }
 
-; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: cannot select: %2:fpr(<4 x s16>) = G_ZEXT %0:fpr(<4 x s8>) (in function: zext_v4s8)
-; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for zext_v4s8
-; FALLBACK-WITH-REPORT-OUT-LABEL: zext_v4s8
-define <4 x i16> @zext_v4s8(<4 x i8> %in) {
-  %ext = zext <4 x i8> %in to <4 x i16>
-  ret <4 x i16> %ext
-}
-
 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: cannot select: RET_ReallyLR implicit $x0 (in function: strict_align_feature)
 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for strict_align_feature
 ; FALLBACK-WITH-REPORT-OUT-LABEL: strict_align_feature
index abab519..5e07558 100644 (file)
@@ -172,3 +172,25 @@ body:             |
     RET_ReallyLR implicit $q0
 
 ...
+---
+name:            add_v4i16
+alignment:       4
+tracksRegLiveness: true
+machineFunctionInfo: {}
+body:             |
+  bb.1:
+    liveins: $d0, $d1
+
+    ; CHECK-LABEL: name: add_v4i16
+    ; CHECK: liveins: $d0, $d1
+    ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s16>) = COPY $d0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s16>) = COPY $d1
+    ; CHECK: [[ADD:%[0-9]+]]:_(<4 x s16>) = G_ADD [[COPY]], [[COPY1]]
+    ; CHECK: $d0 = COPY [[ADD]](<4 x s16>)
+    ; CHECK: RET_ReallyLR implicit $d0
+    %0:_(<4 x s16>) = COPY $d0
+    %1:_(<4 x s16>) = COPY $d1
+    %2:_(<4 x s16>) = G_ADD %0, %1
+    $d0 = COPY %2(<4 x s16>)
+    RET_ReallyLR implicit $d0
+...
index a5b7def..354f13d 100644 (file)
@@ -968,8 +968,16 @@ define <2 x i32> @abspattern1(<2 x i32> %a) nounwind {
 
 define <4 x i16> @abspattern2(<4 x i16> %a) nounwind {
 ; CHECK-LABEL: abspattern2:
-; CHECK: abs.4h
-; CHECK-NEXT: ret
+; DAG: abs.4h
+; DAG-NEXT: ret
+
+; For GlobalISel, this generates terrible code until we can pattern match this to abs.
+; GISEL-DAG: sub.4h
+; GISEL-DAG: cmgt.4h
+; GISEL: csel
+; GISEL: csel
+; GISEL: csel
+; GISEL: csel
         %tmp1neg = sub <4 x i16> zeroinitializer, %a
         %b = icmp sgt <4 x i16> %a, zeroinitializer
         %abs = select <4 x i1> %b, <4 x i16> %a, <4 x i16> %tmp1neg