Skip to content

Commit fc03fad

Browse files
aemersontstellar
authored andcommitted
[AArch64][GlobalISel] Lower vector G_CTTZ.
Fixes issue 56398 (cherry picked from commit 9cc1dd2)
1 parent c74059c commit fc03fad

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
662662

663663
getActionDefinitionsBuilder(G_CTTZ_ZERO_UNDEF).lower();
664664

665-
// TODO: Handle vector types.
666665
getActionDefinitionsBuilder(G_CTTZ)
666+
.lowerIf(isVector(0))
667667
.clampScalar(0, s32, s64)
668668
.scalarSameSizeAs(1, 0)
669669
.customFor({s32, s64});

llvm/test/CodeGen/AArch64/GlobalISel/legalize-cttz.mir

+26
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,29 @@ body: |
8888
%1:_(s64) = G_CTTZ %val(s64)
8989
$x0 = COPY %1(s64)
9090
RET_ReallyLR implicit $x0
91+
...
92+
---
93+
name: v4s32
94+
alignment: 4
95+
tracksRegLiveness: true
96+
body: |
97+
bb.0:
98+
liveins: $q0
99+
100+
; CHECK-LABEL: name: v4s32
101+
; CHECK: liveins: $q0
102+
; CHECK-NEXT: {{ $}}
103+
; CHECK-NEXT: %val:_(<4 x s32>) = COPY $q0
104+
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
105+
; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
106+
; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<4 x s32>) = G_XOR %val, [[BUILD_VECTOR]]
107+
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(<4 x s32>) = G_ADD %val, [[BUILD_VECTOR]]
108+
; CHECK-NEXT: [[AND:%[0-9]+]]:_(<4 x s32>) = G_AND [[XOR]], [[ADD]]
109+
; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(<4 x s32>) = G_CTPOP [[AND]](<4 x s32>)
110+
; CHECK-NEXT: $q0 = COPY [[CTPOP]](<4 x s32>)
111+
; CHECK-NEXT: RET_ReallyLR implicit $q0
112+
%val:_(<4 x s32>) = COPY $q0
113+
%1:_(<4 x s32>) = G_CTTZ %val(<4 x s32>)
114+
$q0 = COPY %1(<4 x s32>)
115+
RET_ReallyLR implicit $q0
116+
...

0 commit comments

Comments
 (0)