[llvm] [PowerPC] Fix vector_shuffle combines when inputs are scalar_to_vector of differing types. (PR #80784)

Amy Kwan via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 17:06:39 PDT 2024


================
@@ -15519,33 +15556,33 @@ SDValue PPCTargetLowering::combineVectorShuffle(ShuffleVectorSDNode *SVN,
     // the value into element zero. Since scalar size of LHS and RHS may differ
     // after isScalarToVec, this should be checked using their own sizes.
     if (SToVLHS) {
-      if (!IsLittleEndian && SToVLHS.getValueType().getScalarSizeInBits() >= 64)
+      int LHSScalarSize = SToVLHS.getValueType().getScalarSizeInBits();
+      if (!IsLittleEndian && LHSScalarSize >= 64)
         return Res;
-      // Set up the values for the shuffle vector fixup.
-      LHSMaxIdx = NumEltsOut / NumEltsIn;
-      SToVLHS = getSToVPermuted(SToVLHS, DAG, Subtarget);
-      if (SToVLHS.getValueType() != LHS.getValueType())
-        SToVLHS = DAG.getBitcast(LHS.getValueType(), SToVLHS);
-      LHS = SToVLHS;
+      LHS = generateSToVPermutedForVecShuffle(
+          LHSScalarSize, ShuffleEltWidth, LHSNumValidElts, LHSFirstElt,
----------------
amy-kwan wrote:

Yeah, the first element of LHS will always be zero. Originally, I didn't have the `generateSToVPermutedForVecShuffle()` function, but I added it due to the comment I received in  https://github.com/llvm/llvm-project/pull/80784/commits/606ea91671401b0fbdd4a2e183587852a777a0b9#r1560041740 in attempts to common up some code.

The first element of the LHS actually doesn't matter when I'm generating the `SCALAR_TO_VECTOR_PERMUTED` within `generateSToVPermutedForVecShuffle()`, so I could just pass in zero, but where it matters is at the RHS.

I chose to still pass in `LHSFirstElt` here just to be explicit in the code that we're dealing with the first element of the LHS.

https://github.com/llvm/llvm-project/pull/80784


More information about the llvm-commits mailing list