[llvm] 3b73cb3 - [AArch64][GlobalISel] Create copy rather than single-element concat
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 02:22:19 PDT 2024
Author: David Green
Date: 2024-07-03T10:22:15+01:00
New Revision: 3b73cb3bf138d2ad7f354c9d26037d769cfe9d53
URL: https://github.com/llvm/llvm-project/commit/3b73cb3bf138d2ad7f354c9d26037d769cfe9d53
DIFF: https://github.com/llvm/llvm-project/commit/3b73cb3bf138d2ad7f354c9d26037d769cfe9d53.diff
LOG: [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.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index ef2ef1e0ffb04..c27b882f17003 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -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();
}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir b/llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir
index 0de989f8be75d..fbcc87fc7012a 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir
@@ -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
+...
More information about the llvm-commits
mailing list