[CodeGen][AArch64] Bail out in performConcatVectorsCombine for scalable vectors
authorDavid Sherwood <david.sherwood@arm.com>
Thu, 25 Nov 2021 15:39:18 +0000 (15:39 +0000)
committerDavid Sherwood <david.sherwood@arm.com>
Mon, 29 Nov 2021 14:26:14 +0000 (14:26 +0000)
I tried to exercise the existing combine patterns in performConcatVectorsCombine
for scalable vectors and at the moment it doesn't seem possible. Parts of
the code currently assume we're dealing with fixed-width vectors with calls
to getVectorNumElements(), therefore I've decided to simply bail out early
for scalable vectors.

Added a test here to show that we don't crash when attempting to combine
truncate + concat:

  CodeGen/AArch64/concat_vector-truncate-combine.ll

Differential Revision: https://reviews.llvm.org/D114600

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/concat_vector-truncate-combine.ll

index d1c58086161ed0f7a9f1921540e5f5eadc5212f9..48b50db51988b881e6683556b0eb41f468568b81 100644 (file)
@@ -14109,6 +14109,9 @@ static SDValue performConcatVectorsCombine(SDNode *N,
   SDValue N0 = N->getOperand(0), N1 = N->getOperand(1);
   unsigned N0Opc = N0->getOpcode(), N1Opc = N1->getOpcode();
 
+  if (VT.isScalableVector())
+    return SDValue();
+
   // Optimize concat_vectors of truncated vectors, where the intermediate
   // type is illegal, to avoid said illegality,  e.g.,
   //   (v4i16 (concat_vectors (v2i16 (truncate (v2i64))),
index ee5278600422fc0cc75be61e88b334a93902f122..b478b54f10b24fec01fdc42d82495416404d4578 100644 (file)
@@ -40,4 +40,24 @@ entry:
   ret <8 x i16> %shuffle
 }
 
+
+; The concat_vectors operation in this test is introduced when splitting
+; the fptrunc operation due to the split <vscale x 4 x double> input operand.
+define void @test_concat_fptrunc_v4f64_to_v4f32(<vscale x 4 x float>* %ptr) #1 {
+entry:
+; CHECK-LABEL: test_concat_fptrunc_v4f64_to_v4f32:
+; CHECK:       fmov    z0.d, #1.00000000
+; CHECK-NEXT:  ptrue   p0.d
+; CHECK-NEXT:  fcvt    z0.s, p0/m, z0.d
+; CHECK-NEXT:  ptrue   p0.s
+; CHECK-NEXT:  uzp1    z0.s, z0.s, z0.s
+; CHECK-NEXT:  st1w    { z0.s }, p0, [x0]
+; CHECK-NEXT:  ret
+  %0 = shufflevector <vscale x 4 x double> insertelement (<vscale x 4 x double> poison, double 1.000000e+00, i32 0), <vscale x 4 x double> poison, <vscale x 4 x i32> zeroinitializer
+  %1 = fptrunc <vscale x 4 x double> %0 to <vscale x 4 x float>
+  store <vscale x 4 x float> %1, <vscale x 4 x float>* %ptr, align 4
+  ret void
+}
+
 attributes #0 = { nounwind }
+attributes #1 = { "target-features"="+sve" }