Skip to content

Commit 6c39fa9

Browse files
authored
[AArch64][GlobalISel] Expand abs.v4i8 to v4i16 and abs.v2s16 to v2s32 (#81231)
GISel was currently falling back to SDAG for these functions, and this matches the way SDAG currently generates code for these functions.
1 parent 43bcedd commit 6c39fa9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,12 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
10091009
ABSActions
10101010
.legalFor({s32, s64});
10111011
ABSActions.legalFor(PackedVectorAllTypeList)
1012+
.widenScalarIf(
1013+
[=](const LegalityQuery &Query) { return Query.Types[0] == v4s8; },
1014+
[=](const LegalityQuery &Query) { return std::make_pair(0, v4s16); })
1015+
.widenScalarIf(
1016+
[=](const LegalityQuery &Query) { return Query.Types[0] == v2s16; },
1017+
[=](const LegalityQuery &Query) { return std::make_pair(0, v2s32); })
10121018
.clampNumElements(0, v8s8, v16s8)
10131019
.clampNumElements(0, v4s16, v8s16)
10141020
.clampNumElements(0, v2s32, v4s32)

llvm/test/CodeGen/AArch64/abs.ll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
33
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
44

5-
; CHECK-GI: warning: Instruction selection used fallback path for abs_v4i8
6-
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v2i16
7-
85
; ===== Legal Scalars =====
96

107
define i8 @abs_i8(i8 %a){

0 commit comments

Comments
 (0)