Skip to content

Commit

Permalink
[AArch64][GlobalISel] Create copy rather than single-element concat
Browse files Browse the repository at this point in the history
The verifier does not accept single-element G_CONCAT_VECTORS, so if there is a
single Op generate a COPY instead.
  • Loading branch information
davemgreen authored and lravenclaw committed Jul 3, 2024
1 parent 089cde2 commit e07f093
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,10 @@ void CombinerHelper::applyCombineShuffleConcat(MachineInstr &MI,
}
}

Builder.buildConcatVectors(MI.getOperand(0).getReg(), Ops);
if (Ops.size() > 1)
Builder.buildConcatVectors(MI.getOperand(0).getReg(), Ops);
else
Builder.buildCopy(MI.getOperand(0).getReg(), Ops[0]);
MI.eraseFromParent();
}

Expand Down
28 changes: 28 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,31 @@ body: |
$q0 = COPY %z(<16 x s8>)
RET_ReallyLR implicit $q0
...

---
name: single_vector_to_copy
tracksRegLiveness: true
body: |
bb.0:
liveins: $q0, $q1
; CHECK-LABEL: name: single_vector_to_copy
; CHECK: liveins: $q0, $q1
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %p1:_(<4 x s32>) = COPY $q0
; CHECK-NEXT: %p2:_(<4 x s32>) = COPY $q1
; CHECK-NEXT: $q0 = COPY %p1(<4 x s32>)
; CHECK-NEXT: $q1 = COPY %p2(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%p1:_(<4 x s32>) = COPY $q0
%p2:_(<4 x s32>) = COPY $q1
%a:_(<8 x s32>) = G_CONCAT_VECTORS %p1:_(<4 x s32>), %p2:_(<4 x s32>)
%x:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(0, 1, 2, 3)
%y:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(4, 5, 6, 7)
$q0 = COPY %x(<4 x s32>)
$q1 = COPY %y(<4 x s32>)
RET_ReallyLR implicit $q0
...

0 comments on commit e07f093

Please sign in to comment.