[llvm] r369135 - [AArch64][GlobalISel] Lower G_SHUFFLE_VECTOR with 1 elt src and 1 elt mask.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 11:06:53 PDT 2019
Author: aemerson
Date: Fri Aug 16 11:06:53 2019
New Revision: 369135
URL: http://llvm.org/viewvc/llvm-project?rev=369135&view=rev
Log:
[AArch64][GlobalISel] Lower G_SHUFFLE_VECTOR with 1 elt src and 1 elt mask.
Again, it's weird that these are allowed. Since lowering support was added in
r368709 we started crashing on compiling the neon intrinsics test in the test
suite. This fixes the lowering to fold the 1 elt src/mask case into copies.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-shuffle-vector.mir
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=369135&r1=369134&r2=369135&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Fri Aug 16 11:06:53 2019
@@ -3823,7 +3823,6 @@ LegalizerHelper::lowerShuffleVector(Mach
Register Src1Reg = MI.getOperand(2).getReg();
LLT Src0Ty = MRI.getType(Src0Reg);
LLT DstTy = MRI.getType(DstReg);
- LLT EltTy = DstTy.getElementType();
LLT IdxTy = LLT::scalar(32);
const Constant *ShufMask = MI.getOperand(3).getShuffleMask();
@@ -3831,8 +3830,25 @@ LegalizerHelper::lowerShuffleVector(Mach
SmallVector<int, 32> Mask;
ShuffleVectorInst::getShuffleMask(ShufMask, Mask);
+ if (DstTy.isScalar()) {
+ if (Src0Ty.isVector())
+ return UnableToLegalize;
+
+ // This is just a SELECT.
+ assert(Mask.size() == 1 && "Expected a single mask element");
+ Register Val;
+ if (Mask[0] < 0 || Mask[0] > 1)
+ Val = MIRBuilder.buildUndef(DstTy).getReg(0);
+ else
+ Val = Mask[0] == 0 ? Src0Reg : Src1Reg;
+ MIRBuilder.buildCopy(DstReg, Val);
+ MI.eraseFromParent();
+ return Legalized;
+ }
+
Register Undef;
SmallVector<Register, 32> BuildVec;
+ LLT EltTy = DstTy.getElementType();
for (int Idx : Mask) {
if (Idx < 0) {
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-shuffle-vector.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-shuffle-vector.mir?rev=369135&r1=369134&r2=369135&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-shuffle-vector.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-shuffle-vector.mir Fri Aug 16 11:06:53 2019
@@ -44,3 +44,29 @@ body: |
RET_ReallyLR implicit $q0
...
+---
+name: shuffle_1elt_mask
+alignment: 2
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $d0, $d1
+
+ ; CHECK-LABEL: name: shuffle_1elt_mask
+ ; CHECK: liveins: $d0, $d1
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $d0
+ ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $d1
+ ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
+ ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY [[COPY1]](s64)
+ ; CHECK: $d0 = COPY [[COPY2]](s64)
+ ; CHECK: $d1 = COPY [[COPY3]](s64)
+ ; CHECK: RET_ReallyLR implicit $d0, implicit $d1
+ %0:_(s64) = COPY $d0
+ %1:_(s64) = COPY $d1
+ %3:_(s64) = G_SHUFFLE_VECTOR %0:_(s64), %1:_, shufflemask(0)
+ %4:_(s64) = G_SHUFFLE_VECTOR %0:_(s64), %1:_, shufflemask(1)
+ $d0 = COPY %3(s64)
+ $d1 = COPY %4(s64)
+ RET_ReallyLR implicit $d0, implicit $d1
+
+...
More information about the llvm-commits
mailing list