[llvm] [PowerPC] Fix vector_shuffle combines when inputs are scalar_to_vector of differing types. (PR #80784)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 13:12:15 PDT 2024
================
@@ -15771,33 +15808,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)
----------------
diggerlin wrote:
if (!IsLittleEndian && RHSScalarSize >= 64)
return Res;
the patch still generate LHS, which are not used actually.
can we change the code to
```
if (SToVLHS) {
LHSScalarSize = SToVLHS.getValueType().getScalarSizeInBits();
if (!IsLittleEndian && LHSScalarSize >= 64)
return Res;
}
if (SToVRHS) {
int RHSScalarSize = SToVRHS.getValueType().getScalarSizeInBits();
if (!IsLittleEndian && RHSScalarSize >= 64)
return Res;
}
if(LHSScalarSize != 0)
LHS = generateSToVPermutedForVecShuffle(
LHSScalarSize, ShuffleEltWidth, LHSNumValidElts, LHSFirstElt,
LHSLastElt, LHS, SToVLHS, DAG, Subtarget);
if (RHSScalarSize != 0 )
RHS = generateSToVPermutedForVecShuffle(
RHSScalarSize, ShuffleEltWidth, RHSNumValidElts, RHSFirstElt,
RHSLastElt, RHS, SToVRHS, DAG, Subtarget);
if (!isShuffleMaskInRange(ShuffV, HalfVec, LHSLastElt, RHSLastElt))
return Res;
```
https://github.com/llvm/llvm-project/pull/80784
More information about the llvm-commits
mailing list