[llvm] [PowerPC] Fix vector_shuffle combines when inputs are scalar_to_vector of differing types. (PR #80784)
Maryam Moghadas via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 07:51:48 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,
+ LHSLastElt, LHS, SToVLHS, DAG, Subtarget);
}
if (SToVRHS) {
- if (!IsLittleEndian && SToVRHS.getValueType().getScalarSizeInBits() >= 64)
+ int RHSScalarSize = SToVRHS.getValueType().getScalarSizeInBits();
+ if (!IsLittleEndian && RHSScalarSize >= 64)
return Res;
- RHSMinIdx = NumEltsOut;
- RHSMaxIdx = NumEltsOut / NumEltsIn + RHSMinIdx;
- SToVRHS = getSToVPermuted(SToVRHS, DAG, Subtarget);
- if (SToVRHS.getValueType() != RHS.getValueType())
- SToVRHS = DAG.getBitcast(RHS.getValueType(), SToVRHS);
- RHS = SToVRHS;
+ RHS = generateSToVPermutedForVecShuffle(
+ RHSScalarSize, ShuffleEltWidth, RHSNumValidElts, RHSFirstElt,
+ RHSLastElt, RHS, SToVRHS, DAG, Subtarget);
}
+ if (!isShuffleMaskInRange(ShuffV, HalfVec, LHSLastElt, RHSLastElt))
+ return Res;
+
// Fix up the shuffle mask to reflect where the desired element actually is.
// The minimum and maximum indices that correspond to element zero for both
// the LHS and RHS are computed and will control which shuffle mask entries
// are to be changed. For example, if the RHS is permuted, any shuffle mask
- // entries in the range [RHSMinIdx,RHSMaxIdx) will be adjusted.
- fixupShuffleMaskForPermutedSToV(ShuffV, LHSMaxIdx, RHSMinIdx, RHSMaxIdx,
- HalfVec, ValidLaneWidth, Subtarget);
+ // entries in the range [RHSFirstElt,RHSLastElt] will be adjusted.
+ fixupShuffleMaskForPermutedSToV(
+ ShuffV, LHSFirstElt, LHSLastElt, RHSFirstElt, RHSLastElt, HalfVec,
----------------
maryammo wrote:
same question about LHSFirstElt?
https://github.com/llvm/llvm-project/pull/80784
More information about the llvm-commits
mailing list