Skip to content

Commit e07f093

Browse files
davemgreenlravenclaw
authored andcommitted
[AArch64][GlobalISel] Create copy rather than single-element concat
The verifier does not accept single-element G_CONCAT_VECTORS, so if there is a single Op generate a COPY instead.
1 parent 089cde2 commit e07f093

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ void CombinerHelper::applyCombineShuffleConcat(MachineInstr &MI,
446446
}
447447
}
448448

449-
Builder.buildConcatVectors(MI.getOperand(0).getReg(), Ops);
449+
if (Ops.size() > 1)
450+
Builder.buildConcatVectors(MI.getOperand(0).getReg(), Ops);
451+
else
452+
Builder.buildCopy(MI.getOperand(0).getReg(), Ops[0]);
450453
MI.eraseFromParent();
451454
}
452455

llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,31 @@ body: |
200200
$q0 = COPY %z(<16 x s8>)
201201
RET_ReallyLR implicit $q0
202202
...
203+
204+
---
205+
name: single_vector_to_copy
206+
tracksRegLiveness: true
207+
body: |
208+
bb.0:
209+
liveins: $q0, $q1
210+
211+
; CHECK-LABEL: name: single_vector_to_copy
212+
; CHECK: liveins: $q0, $q1
213+
; CHECK-NEXT: {{ $}}
214+
; CHECK-NEXT: %p1:_(<4 x s32>) = COPY $q0
215+
; CHECK-NEXT: %p2:_(<4 x s32>) = COPY $q1
216+
; CHECK-NEXT: $q0 = COPY %p1(<4 x s32>)
217+
; CHECK-NEXT: $q1 = COPY %p2(<4 x s32>)
218+
; CHECK-NEXT: RET_ReallyLR implicit $q0
219+
%p1:_(<4 x s32>) = COPY $q0
220+
%p2:_(<4 x s32>) = COPY $q1
221+
222+
%a:_(<8 x s32>) = G_CONCAT_VECTORS %p1:_(<4 x s32>), %p2:_(<4 x s32>)
223+
224+
%x:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(0, 1, 2, 3)
225+
%y:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(4, 5, 6, 7)
226+
227+
$q0 = COPY %x(<4 x s32>)
228+
$q1 = COPY %y(<4 x s32>)
229+
RET_ReallyLR implicit $q0
230+
...

0 commit comments

Comments
 (0)