Skip to content

Commit 0a2704e

Browse files
committed
fixup! [AArch64][GlobalISel] Legalize G_ABS for Larger/Smaller Vectors
1 parent fc45fe0 commit 0a2704e

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
993993
.clampNumElements(0, v4s16, v8s16)
994994
.clampNumElements(0, v2s32, v4s32)
995995
.clampNumElements(0, v2s64, v2s64)
996-
.lowerIf(isScalar(0));
996+
.lower();
997997

998998
// For fadd reductions we have pairwise operations available. We treat the
999999
// usual legal types as legal and handle the lowering to pairwise instructions

llvm/test/CodeGen/AArch64/abs.ll

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
; CHECK-GI: warning: Instruction selection used fallback path for abs_v4i8
66
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v2i16
7-
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v7i16
8-
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v3i32
97

108
; ===== Legal Scalars =====
119

@@ -352,21 +350,52 @@ entry:
352350
declare <3 x i16> @llvm.abs.v3i16(<3 x i16>, i1)
353351

354352
define <7 x i16> @abs_v7i16(<7 x i16> %a){
355-
; CHECK-LABEL: abs_v7i16:
356-
; CHECK: // %bb.0: // %entry
357-
; CHECK-NEXT: abs v0.8h, v0.8h
358-
; CHECK-NEXT: ret
353+
; CHECK-SD-LABEL: abs_v7i16:
354+
; CHECK-SD: // %bb.0: // %entry
355+
; CHECK-SD-NEXT: abs v0.8h, v0.8h
356+
; CHECK-SD-NEXT: ret
357+
;
358+
; CHECK-GI-LABEL: abs_v7i16:
359+
; CHECK-GI: // %bb.0: // %entry
360+
; CHECK-GI-NEXT: mov w8, #15 // =0xf
361+
; CHECK-GI-NEXT: fmov s1, w8
362+
; CHECK-GI-NEXT: mov v2.16b, v1.16b
363+
; CHECK-GI-NEXT: mov v2.h[1], v1.h[0]
364+
; CHECK-GI-NEXT: mov v2.h[2], v1.h[0]
365+
; CHECK-GI-NEXT: mov v2.h[3], v1.h[0]
366+
; CHECK-GI-NEXT: mov v2.h[4], v1.h[0]
367+
; CHECK-GI-NEXT: mov v2.h[5], v1.h[0]
368+
; CHECK-GI-NEXT: mov v2.h[6], v1.h[0]
369+
; CHECK-GI-NEXT: mov v2.h[7], v0.h[0]
370+
; CHECK-GI-NEXT: neg v1.8h, v2.8h
371+
; CHECK-GI-NEXT: sshl v1.8h, v0.8h, v1.8h
372+
; CHECK-GI-NEXT: add v0.8h, v0.8h, v1.8h
373+
; CHECK-GI-NEXT: eor v0.16b, v0.16b, v1.16b
374+
; CHECK-GI-NEXT: ret
359375
entry:
360376
%res = call <7 x i16> @llvm.abs.v7i16(<7 x i16> %a, i1 0)
361377
ret <7 x i16> %res
362378
}
363379
declare <7 x i16> @llvm.abs.v7i16(<7 x i16>, i1)
364380

365381
define <3 x i32> @abs_v3i32(<3 x i32> %a){
366-
; CHECK-LABEL: abs_v3i32:
367-
; CHECK: // %bb.0: // %entry
368-
; CHECK-NEXT: abs v0.4s, v0.4s
369-
; CHECK-NEXT: ret
382+
; CHECK-SD-LABEL: abs_v3i32:
383+
; CHECK-SD: // %bb.0: // %entry
384+
; CHECK-SD-NEXT: abs v0.4s, v0.4s
385+
; CHECK-SD-NEXT: ret
386+
;
387+
; CHECK-GI-LABEL: abs_v3i32:
388+
; CHECK-GI: // %bb.0: // %entry
389+
; CHECK-GI-NEXT: mov w8, #31 // =0x1f
390+
; CHECK-GI-NEXT: fmov s1, w8
391+
; CHECK-GI-NEXT: mov v1.s[1], w8
392+
; CHECK-GI-NEXT: mov v1.s[2], w8
393+
; CHECK-GI-NEXT: mov v1.s[3], w8
394+
; CHECK-GI-NEXT: neg v1.4s, v1.4s
395+
; CHECK-GI-NEXT: sshl v1.4s, v0.4s, v1.4s
396+
; CHECK-GI-NEXT: add v0.4s, v0.4s, v1.4s
397+
; CHECK-GI-NEXT: eor v0.16b, v0.16b, v1.16b
398+
; CHECK-GI-NEXT: ret
370399
entry:
371400
%res = call <3 x i32> @llvm.abs.v3i32(<3 x i32> %a, i1 0)
372401
ret <3 x i32> %res

0 commit comments

Comments
 (0)