Skip to content

Commit 1baf789

Browse files
committed
[x86] simplify code in combineExtractSubvector; NFC
Only the 1st fold is attempted pre-legalization, but it requires legal (simple) types too, so we don't need an EVT in any of the code. llvm-svn: 354674
1 parent 65b4ab9 commit 1baf789

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41960,7 +41960,10 @@ static SDValue combineExtractSubvector(SDNode *N, SelectionDAG &DAG,
4196041960

4196141961
// Capture the original wide type in the likely case that we need to bitcast
4196241962
// back to this type.
41963-
EVT VT = N->getValueType(0);
41963+
if (!N->getValueType(0).isSimple())
41964+
return SDValue();
41965+
41966+
MVT VT = N->getSimpleValueType(0);
4196441967
EVT WideVecVT = N->getOperand(0).getValueType();
4196541968
SDValue WideVec = peekThroughBitcasts(N->getOperand(0));
4196641969
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
@@ -41986,64 +41989,63 @@ static SDValue combineExtractSubvector(SDNode *N, SelectionDAG &DAG,
4198641989
if (DCI.isBeforeLegalizeOps())
4198741990
return SDValue();
4198841991

41989-
MVT OpVT = N->getSimpleValueType(0);
4199041992
SDValue InVec = N->getOperand(0);
4199141993
unsigned IdxVal = cast<ConstantSDNode>(N->getOperand(1))->getZExtValue();
4199241994

4199341995
if (ISD::isBuildVectorAllZeros(InVec.getNode()))
41994-
return getZeroVector(OpVT, Subtarget, DAG, SDLoc(N));
41996+
return getZeroVector(VT, Subtarget, DAG, SDLoc(N));
4199541997

4199641998
if (ISD::isBuildVectorAllOnes(InVec.getNode())) {
41997-
if (OpVT.getScalarType() == MVT::i1)
41998-
return DAG.getConstant(1, SDLoc(N), OpVT);
41999-
return getOnesVector(OpVT, DAG, SDLoc(N));
41999+
if (VT.getScalarType() == MVT::i1)
42000+
return DAG.getConstant(1, SDLoc(N), VT);
42001+
return getOnesVector(VT, DAG, SDLoc(N));
4200042002
}
4200142003

4200242004
if (InVec.getOpcode() == ISD::BUILD_VECTOR)
4200342005
return DAG.getBuildVector(
42004-
OpVT, SDLoc(N),
42005-
InVec.getNode()->ops().slice(IdxVal, OpVT.getVectorNumElements()));
42006+
VT, SDLoc(N),
42007+
InVec.getNode()->ops().slice(IdxVal, VT.getVectorNumElements()));
4200642008

4200742009
// If we're extracting the lowest subvector and we're the only user,
4200842010
// we may be able to perform this with a smaller vector width.
4200942011
if (IdxVal == 0 && InVec.hasOneUse()) {
4201042012
unsigned InOpcode = InVec.getOpcode();
42011-
if (OpVT == MVT::v2f64 && InVec.getValueType() == MVT::v4f64) {
42013+
if (VT == MVT::v2f64 && InVec.getValueType() == MVT::v4f64) {
4201242014
// v2f64 CVTDQ2PD(v4i32).
4201342015
if (InOpcode == ISD::SINT_TO_FP &&
4201442016
InVec.getOperand(0).getValueType() == MVT::v4i32) {
42015-
return DAG.getNode(X86ISD::CVTSI2P, SDLoc(N), OpVT, InVec.getOperand(0));
42017+
return DAG.getNode(X86ISD::CVTSI2P, SDLoc(N), VT, InVec.getOperand(0));
4201642018
}
4201742019
// v2f64 CVTPS2PD(v4f32).
4201842020
if (InOpcode == ISD::FP_EXTEND &&
4201942021
InVec.getOperand(0).getValueType() == MVT::v4f32) {
42020-
return DAG.getNode(X86ISD::VFPEXT, SDLoc(N), OpVT, InVec.getOperand(0));
42022+
return DAG.getNode(X86ISD::VFPEXT, SDLoc(N), VT, InVec.getOperand(0));
4202142023
}
4202242024
}
4202342025
if ((InOpcode == ISD::ZERO_EXTEND || InOpcode == ISD::SIGN_EXTEND) &&
42024-
OpVT.is128BitVector() &&
42026+
VT.is128BitVector() &&
4202542027
InVec.getOperand(0).getSimpleValueType().is128BitVector()) {
4202642028
unsigned ExtOp =
42027-
InOpcode == ISD::ZERO_EXTEND ? ISD::ZERO_EXTEND_VECTOR_INREG
42028-
: ISD::SIGN_EXTEND_VECTOR_INREG;
42029-
return DAG.getNode(ExtOp, SDLoc(N), OpVT, InVec.getOperand(0));
42029+
InOpcode == ISD::ZERO_EXTEND ? ISD::ZERO_EXTEND_VECTOR_INREG
42030+
: ISD::SIGN_EXTEND_VECTOR_INREG;
42031+
return DAG.getNode(ExtOp, SDLoc(N), VT, InVec.getOperand(0));
4203042032
}
4203142033
if ((InOpcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
4203242034
InOpcode == ISD::SIGN_EXTEND_VECTOR_INREG) &&
42033-
OpVT.is128BitVector() &&
42035+
VT.is128BitVector() &&
4203442036
InVec.getOperand(0).getSimpleValueType().is128BitVector()) {
42035-
return DAG.getNode(InOpcode, SDLoc(N), OpVT, InVec.getOperand(0));
42037+
return DAG.getNode(InOpcode, SDLoc(N), VT, InVec.getOperand(0));
4203642038
}
4203742039
if (InOpcode == ISD::BITCAST) {
4203842040
// TODO - do this for target shuffles in general.
4203942041
SDValue InVecBC = peekThroughOneUseBitcasts(InVec);
42040-
if (InVecBC.getOpcode() == X86ISD::PSHUFB && OpVT.is128BitVector()) {
42042+
if (InVecBC.getOpcode() == X86ISD::PSHUFB && VT.is128BitVector()) {
4204142043
SDLoc DL(N);
4204242044
SDValue SubPSHUFB =
4204342045
DAG.getNode(X86ISD::PSHUFB, DL, MVT::v16i8,
4204442046
extract128BitVector(InVecBC.getOperand(0), 0, DAG, DL),
4204542047
extract128BitVector(InVecBC.getOperand(1), 0, DAG, DL));
42046-
return DAG.getBitcast(OpVT, SubPSHUFB);
42048+
return DAG.getBitcast(VT, SubPSHUFB);
4204742049
}
4204842050
}
4204942051
}

0 commit comments

Comments
 (0)