From a0d08405e7a64625982eb9c0c69a81fec657cfc6 Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Wed, 10 Apr 2019 23:06:11 +0000 Subject: [PATCH] [AArch64][GlobalISel] Add legalizer support for <8 x s16> and <16 x s8> G_ADD. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358143 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64LegalizerInfo.cpp | 2 +- .../AArch64/GlobalISel/legalize-add.mir | 46 ++++++++++++++ .../AArch64/GlobalISel/select-binop.mir | 61 +++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/Target/AArch64/AArch64LegalizerInfo.cpp b/lib/Target/AArch64/AArch64LegalizerInfo.cpp index 3b4a1a90fb5..0c1e4b00fa0 100644 --- a/lib/Target/AArch64/AArch64LegalizerInfo.cpp +++ b/lib/Target/AArch64/AArch64LegalizerInfo.cpp @@ -76,7 +76,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}) + .legalFor({s32, s64, v2s32, v4s32, v2s64, v8s16, v16s8}) .clampScalar(0, s32, s64) .widenScalarToNextPow2(0) .clampNumElements(0, v2s32, v4s32) diff --git a/test/CodeGen/AArch64/GlobalISel/legalize-add.mir b/test/CodeGen/AArch64/GlobalISel/legalize-add.mir index c3773f50cb0..3c2a52b7f0a 100644 --- a/test/CodeGen/AArch64/GlobalISel/legalize-add.mir +++ b/test/CodeGen/AArch64/GlobalISel/legalize-add.mir @@ -130,3 +130,49 @@ body: | $q1 = COPY %8(<2 x s64>) $q2 = COPY %9(<2 x s64>) ... +--- +name: add_v8i16 +alignment: 2 +tracksRegLiveness: true +machineFunctionInfo: {} +body: | + bb.1: + liveins: $q0, $q1 + + ; CHECK-LABEL: name: add_v8i16 + ; CHECK: liveins: $q0, $q1 + ; CHECK: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q0 + ; CHECK: [[COPY1:%[0-9]+]]:_(<8 x s16>) = COPY $q1 + ; CHECK: [[ADD:%[0-9]+]]:_(<8 x s16>) = G_ADD [[COPY]], [[COPY1]] + ; CHECK: $q0 = COPY [[ADD]](<8 x s16>) + ; CHECK: RET_ReallyLR implicit $q0 + %0:_(<8 x s16>) = COPY $q0 + %1:_(<8 x s16>) = COPY $q1 + %2:_(<8 x s16>) = G_ADD %0, %1 + $q0 = COPY %2(<8 x s16>) + RET_ReallyLR implicit $q0 + +... +--- +name: add_v16i8 +alignment: 2 +tracksRegLiveness: true +machineFunctionInfo: {} +body: | + bb.1: + liveins: $q0, $q1 + + ; CHECK-LABEL: name: add_v16i8 + ; CHECK: liveins: $q0, $q1 + ; CHECK: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0 + ; CHECK: [[COPY1:%[0-9]+]]:_(<16 x s8>) = COPY $q1 + ; CHECK: [[ADD:%[0-9]+]]:_(<16 x s8>) = G_ADD [[COPY]], [[COPY1]] + ; CHECK: $q0 = COPY [[ADD]](<16 x s8>) + ; CHECK: RET_ReallyLR implicit $q0 + %0:_(<16 x s8>) = COPY $q0 + %1:_(<16 x s8>) = COPY $q1 + %2:_(<16 x s8>) = G_ADD %0, %1 + $q0 = COPY %2(<16 x s8>) + RET_ReallyLR implicit $q0 + +... diff --git a/test/CodeGen/AArch64/GlobalISel/select-binop.mir b/test/CodeGen/AArch64/GlobalISel/select-binop.mir index 8c858bcdb3e..9c4731e3b5d 100644 --- a/test/CodeGen/AArch64/GlobalISel/select-binop.mir +++ b/test/CodeGen/AArch64/GlobalISel/select-binop.mir @@ -54,6 +54,9 @@ define void @fdiv_s32_fpr() { ret void } define void @fdiv_s64_fpr() { ret void } + define void @add_v8i16() { ret void } + define void @add_v16i8() { ret void } + ... --- @@ -912,3 +915,61 @@ body: | %2(s64) = G_FDIV %0, %1 $d0 = COPY %2(s64) ... +--- +name: add_v8i16 +alignment: 2 +legalized: true +regBankSelected: true +tracksRegLiveness: true +registers: + - { id: 0, class: fpr } + - { id: 1, class: fpr } + - { id: 2, class: fpr } +machineFunctionInfo: {} +body: | + bb.1: + liveins: $q0, $q1 + + ; CHECK-LABEL: name: add_v8i16 + ; CHECK: liveins: $q0, $q1 + ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0 + ; CHECK: [[COPY1:%[0-9]+]]:fpr128 = COPY $q1 + ; CHECK: [[ADDv8i16_:%[0-9]+]]:fpr128 = ADDv8i16 [[COPY]], [[COPY1]] + ; CHECK: $q0 = COPY [[ADDv8i16_]] + ; CHECK: RET_ReallyLR implicit $q0 + %0:fpr(<8 x s16>) = COPY $q0 + %1:fpr(<8 x s16>) = COPY $q1 + %2:fpr(<8 x s16>) = G_ADD %0, %1 + $q0 = COPY %2(<8 x s16>) + RET_ReallyLR implicit $q0 + +... +--- +name: add_v16i8 +alignment: 2 +legalized: true +regBankSelected: true +tracksRegLiveness: true +registers: + - { id: 0, class: fpr } + - { id: 1, class: fpr } + - { id: 2, class: fpr } +machineFunctionInfo: {} +body: | + bb.1: + liveins: $q0, $q1 + + ; CHECK-LABEL: name: add_v16i8 + ; CHECK: liveins: $q0, $q1 + ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0 + ; CHECK: [[COPY1:%[0-9]+]]:fpr128 = COPY $q1 + ; CHECK: [[ADDv16i8_:%[0-9]+]]:fpr128 = ADDv16i8 [[COPY]], [[COPY1]] + ; CHECK: $q0 = COPY [[ADDv16i8_]] + ; CHECK: RET_ReallyLR implicit $q0 + %0:fpr(<16 x s8>) = COPY $q0 + %1:fpr(<16 x s8>) = COPY $q1 + %2:fpr(<16 x s8>) = G_ADD %0, %1 + $q0 = COPY %2(<16 x s8>) + RET_ReallyLR implicit $q0 + +... -- 2.50.1