Skip to content

Commit

Permalink
[AArch64][GlobalISel] Lower vector G_CTTZ.
Browse files Browse the repository at this point in the history
Fixes issue 56398
  • Loading branch information
aemerson committed Jul 27, 2022
1 parent afc4958 commit 9cc1dd2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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 @@ -662,8 +662,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)

getActionDefinitionsBuilder(G_CTTZ_ZERO_UNDEF).lower();

// TODO: Handle vector types.
getActionDefinitionsBuilder(G_CTTZ)
.lowerIf(isVector(0))
.clampScalar(0, s32, s64)
.scalarSameSizeAs(1, 0)
.customFor({s32, s64});
Expand Down
26 changes: 26 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/legalize-cttz.mir
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,29 @@ body: |
%1:_(s64) = G_CTTZ %val(s64)
$x0 = COPY %1(s64)
RET_ReallyLR implicit $x0
...
---
name: v4s32
alignment: 4
tracksRegLiveness: true
body: |
bb.0:
liveins: $q0
; CHECK-LABEL: name: v4s32
; CHECK: liveins: $q0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %val:_(<4 x s32>) = COPY $q0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<4 x s32>) = G_XOR %val, [[BUILD_VECTOR]]
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(<4 x s32>) = G_ADD %val, [[BUILD_VECTOR]]
; CHECK-NEXT: [[AND:%[0-9]+]]:_(<4 x s32>) = G_AND [[XOR]], [[ADD]]
; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(<4 x s32>) = G_CTPOP [[AND]](<4 x s32>)
; CHECK-NEXT: $q0 = COPY [[CTPOP]](<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%val:_(<4 x s32>) = COPY $q0
%1:_(<4 x s32>) = G_CTTZ %val(<4 x s32>)
$q0 = COPY %1(<4 x s32>)
RET_ReallyLR implicit $q0
...

0 comments on commit 9cc1dd2

Please sign in to comment.