Skip to content

Commit

Permalink
[AArch64][GlobalISel] Legalize arithmetic ops for <4 x s16>
Browse files Browse the repository at this point in the history
  • Loading branch information
aemerson committed Sep 19, 2020
1 parent 97bfac0 commit 269bcc3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
12 changes: 10 additions & 2 deletions llvm/test/CodeGen/AArch64/arm64-vabs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 269bcc3

Please sign in to comment.