mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
TargetLowering: Add getVectorIdxTy() function v2
This virtual function can be implemented by targets to specify the type to use for the index operand of INSERT_VECTOR_ELT, EXTRACT_VECTOR_ELT, INSERT_SUBVECTOR, EXTRACT_SUBVECTOR. The default implementation returns the result from TargetLowering::getPointerTy() The previous code was using TargetLowering::getPointerTy() for vector indices, because this is guaranteed to be legal on all targets. However, using TargetLowering::getPointerTy() can be a problem for targets with pointer sizes that differ across address spaces. On such targets, when vectors need to be loaded or stored to an address space other than the default 'zero' address space (which is the address space assumed by TargetLowering::getPointerTy()), having an index that is a different size than the pointer can lead to inefficient pointer calculations, (e.g. 64-bit adds for a 32-bit address space). There is no intended functionality change with this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187748 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
de5cb6b249
commit
425b76c231
@ -156,6 +156,13 @@ public:
|
||||
|
||||
EVT getShiftAmountTy(EVT LHSTy) const;
|
||||
|
||||
/// Returns the type to be used for the index operand of:
|
||||
/// ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT,
|
||||
/// ISD::INSERT_SUBVECTOR, and ISD::EXTRACT_SUBVECTOR
|
||||
virtual MVT getVectorIdxTy() const {
|
||||
return getPointerTy();
|
||||
}
|
||||
|
||||
/// Return true if the select operation is expensive for this target.
|
||||
bool isSelectExpensive() const { return SelectIsExpensive; }
|
||||
|
||||
|
@ -5448,7 +5448,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
|
||||
SDValue EltNo = N0->getOperand(1);
|
||||
if (isa<ConstantSDNode>(EltNo) && isTypeLegal(NVT)) {
|
||||
int Elt = cast<ConstantSDNode>(EltNo)->getZExtValue();
|
||||
EVT IndexTy = N0->getOperand(1).getValueType();
|
||||
EVT IndexTy = TLI.getVectorIdxTy();
|
||||
int Index = isLE ? (Elt*SizeRatio) : (Elt*SizeRatio + (SizeRatio-1));
|
||||
|
||||
SDValue V = DAG.getNode(ISD::BITCAST, SDLoc(N),
|
||||
@ -8687,7 +8687,7 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
|
||||
OrigElt -= NumElem;
|
||||
}
|
||||
|
||||
EVT IndexTy = N->getOperand(1).getValueType();
|
||||
EVT IndexTy = TLI.getVectorIdxTy();
|
||||
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SDLoc(N), NVT,
|
||||
InVec, DAG.getConstant(OrigElt, IndexTy));
|
||||
}
|
||||
|
@ -3071,11 +3071,12 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node) {
|
||||
if (Idx < NumElems)
|
||||
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT,
|
||||
Op0,
|
||||
DAG.getIntPtrConstant(Idx)));
|
||||
DAG.getConstant(Idx, TLI.getVectorIdxTy())));
|
||||
else
|
||||
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT,
|
||||
Op1,
|
||||
DAG.getIntPtrConstant(Idx - NumElems)));
|
||||
DAG.getConstant(Idx - NumElems,
|
||||
TLI.getVectorIdxTy())));
|
||||
}
|
||||
|
||||
Tmp1 = DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], Ops.size());
|
||||
@ -3688,10 +3689,12 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node) {
|
||||
for (unsigned Idx = 0; Idx < NumElem; Idx++) {
|
||||
SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
VT.getScalarType(),
|
||||
Node->getOperand(0), DAG.getIntPtrConstant(Idx));
|
||||
Node->getOperand(0), DAG.getConstant(Idx,
|
||||
TLI.getVectorIdxTy()));
|
||||
SDValue Sh = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
VT.getScalarType(),
|
||||
Node->getOperand(1), DAG.getIntPtrConstant(Idx));
|
||||
Node->getOperand(1), DAG.getConstant(Idx,
|
||||
TLI.getVectorIdxTy()));
|
||||
Scalars.push_back(DAG.getNode(Node->getOpcode(), dl,
|
||||
VT.getScalarType(), Ex, Sh));
|
||||
}
|
||||
|
@ -966,7 +966,8 @@ SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(SDNode *N,
|
||||
assert(OpNo == 2 && "Different operand and result vector types?");
|
||||
|
||||
// Promote the index.
|
||||
SDValue Idx = ZExtPromotedInteger(N->getOperand(2));
|
||||
SDValue Idx = DAG.getZExtOrTrunc(N->getOperand(2), SDLoc(N),
|
||||
TLI.getVectorIdxTy());
|
||||
return SDValue(DAG.UpdateNodeOperands(N, N->getOperand(0),
|
||||
N->getOperand(1), Idx), 0);
|
||||
}
|
||||
@ -2886,7 +2887,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N) {
|
||||
|
||||
// Extract the element from the original vector.
|
||||
SDValue Index = DAG.getNode(ISD::ADD, dl, BaseIdx.getValueType(),
|
||||
BaseIdx, DAG.getIntPtrConstant(i));
|
||||
BaseIdx, DAG.getConstant(i, BaseIdx.getValueType()));
|
||||
SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
InVT.getVectorElementType(), N->getOperand(0), Index);
|
||||
|
||||
@ -2984,7 +2985,8 @@ SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(SDNode *N) {
|
||||
SDValue Op = N->getOperand(i);
|
||||
for (unsigned j = 0; j < NumElem; ++j) {
|
||||
SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
InElemTy, Op, DAG.getIntPtrConstant(j));
|
||||
InElemTy, Op, DAG.getConstant(j,
|
||||
TLI.getVectorIdxTy()));
|
||||
Ops[i * NumElem + j] = DAG.getNode(ISD::ANY_EXTEND, dl, OutElemTy, Ext);
|
||||
}
|
||||
}
|
||||
@ -3011,7 +3013,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N) {
|
||||
SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(SDNode *N) {
|
||||
SDLoc dl(N);
|
||||
SDValue V0 = GetPromotedInteger(N->getOperand(0));
|
||||
SDValue V1 = N->getOperand(1);
|
||||
SDValue V1 = DAG.getZExtOrTrunc(N->getOperand(1), dl, TLI.getVectorIdxTy());
|
||||
SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
V0->getValueType(0).getScalarType(), V0, V1);
|
||||
|
||||
@ -3039,7 +3041,7 @@ SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(SDNode *N) {
|
||||
for (unsigned i=0; i<NumElem; ++i) {
|
||||
// Extract element from incoming vector
|
||||
SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, SclrTy,
|
||||
Incoming, DAG.getIntPtrConstant(i));
|
||||
Incoming, DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
SDValue Tr = DAG.getNode(ISD::TRUNCATE, dl, RetSclrTy, Ex);
|
||||
NewOps.push_back(Tr);
|
||||
}
|
||||
|
@ -80,9 +80,10 @@ void DAGTypeLegalizer::ExpandRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi) {
|
||||
EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),
|
||||
InVT.getVectorNumElements()/2);
|
||||
Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, InOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, InOp,
|
||||
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
|
||||
DAG.getConstant(InNVT.getVectorNumElements(),
|
||||
TLI.getVectorIdxTy()));
|
||||
if (TLI.isBigEndian())
|
||||
std::swap(Lo, Hi);
|
||||
Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);
|
||||
@ -115,7 +116,8 @@ void DAGTypeLegalizer::ExpandRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi) {
|
||||
SmallVector<SDValue, 8> Vals;
|
||||
for (unsigned i = 0; i < NumElems; ++i)
|
||||
Vals.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ElemVT,
|
||||
CastInOp, DAG.getIntPtrConstant(i)));
|
||||
CastInOp, DAG.getConstant(i,
|
||||
TLI.getVectorIdxTy())));
|
||||
|
||||
// Build Lo, Hi pair by pairing extracted elements if needed.
|
||||
unsigned Slot = 0;
|
||||
@ -227,10 +229,6 @@ void DAGTypeLegalizer::ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDValue &Lo,
|
||||
// Extract the elements at 2 * Idx and 2 * Idx + 1 from the new vector.
|
||||
SDValue Idx = N->getOperand(1);
|
||||
|
||||
// Make sure the type of Idx is big enough to hold the new values.
|
||||
if (Idx.getValueType().bitsLT(TLI.getPointerTy()))
|
||||
Idx = DAG.getNode(ISD::ZERO_EXTEND, dl, TLI.getPointerTy(), Idx);
|
||||
|
||||
Idx = DAG.getNode(ISD::ADD, dl, Idx.getValueType(), Idx, Idx);
|
||||
Lo = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NewVT, NewVec, Idx);
|
||||
|
||||
@ -406,7 +404,8 @@ SDValue DAGTypeLegalizer::ExpandOp_INSERT_VECTOR_ELT(SDNode *N) {
|
||||
Idx = DAG.getNode(ISD::ADD, dl, Idx.getValueType(), Idx, Idx);
|
||||
NewVec = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NewVecVT, NewVec, Lo, Idx);
|
||||
Idx = DAG.getNode(ISD::ADD, dl,
|
||||
Idx.getValueType(), Idx, DAG.getIntPtrConstant(1));
|
||||
Idx.getValueType(), Idx,
|
||||
DAG.getConstant(1, Idx.getValueType()));
|
||||
NewVec = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NewVecVT, NewVec, Hi, Idx);
|
||||
|
||||
// Convert the new vector to the old vector type.
|
||||
@ -495,9 +494,9 @@ void DAGTypeLegalizer::SplitRes_SELECT(SDNode *N, SDValue &Lo,
|
||||
unsigned NumElements = Cond.getValueType().getVectorNumElements();
|
||||
EVT VCondTy = EVT::getVectorVT(*DAG.getContext(), MVT::i1, NumElements / 2);
|
||||
CL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VCondTy, Cond,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
CH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VCondTy, Cond,
|
||||
DAG.getIntPtrConstant(NumElements / 2));
|
||||
DAG.getConstant(NumElements / 2, TLI.getVectorIdxTy()));
|
||||
}
|
||||
|
||||
Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), CL, LL, RL);
|
||||
|
@ -551,7 +551,7 @@ SDValue VectorLegalizer::ExpandStore(SDValue Op) {
|
||||
SmallVector<SDValue, 8> Stores;
|
||||
for (unsigned Idx = 0; Idx < NumElem; Idx++) {
|
||||
SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
RegSclVT, Value, DAG.getIntPtrConstant(Idx));
|
||||
RegSclVT, Value, DAG.getConstant(Idx, TLI.getVectorIdxTy()));
|
||||
|
||||
// This scalar TruncStore may be illegal, but we legalize it later.
|
||||
SDValue Store = DAG.getTruncStore(Chain, dl, Ex, BasePTR,
|
||||
@ -755,9 +755,9 @@ SDValue VectorLegalizer::UnrollVSETCC(SDValue Op) {
|
||||
SmallVector<SDValue, 8> Ops(NumElems);
|
||||
for (unsigned i = 0; i < NumElems; ++i) {
|
||||
SDValue LHSElem = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, TmpEltVT, LHS,
|
||||
DAG.getIntPtrConstant(i));
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
SDValue RHSElem = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, TmpEltVT, RHS,
|
||||
DAG.getIntPtrConstant(i));
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
Ops[i] = DAG.getNode(ISD::SETCC, dl,
|
||||
TLI.getSetCCResultType(*DAG.getContext(), TmpEltVT),
|
||||
LHSElem, RHSElem, CC);
|
||||
|
@ -712,7 +712,8 @@ void DAGTypeLegalizer::SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo,
|
||||
Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, LoVT, Vec, Idx);
|
||||
uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HiVT, Vec,
|
||||
DAG.getIntPtrConstant(IdxVal + LoVT.getVectorNumElements()));
|
||||
DAG.getConstant(IdxVal + LoVT.getVectorNumElements(),
|
||||
TLI.getVectorIdxTy()));
|
||||
}
|
||||
|
||||
void DAGTypeLegalizer::SplitVecRes_FPOWI(SDNode *N, SDValue &Lo,
|
||||
@ -754,7 +755,8 @@ void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo,
|
||||
Lo.getValueType(), Lo, Elt, Idx);
|
||||
else
|
||||
Hi = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, Hi.getValueType(), Hi, Elt,
|
||||
DAG.getIntPtrConstant(IdxVal - LoNumElts));
|
||||
DAG.getConstant(IdxVal - LoNumElts,
|
||||
TLI.getVectorIdxTy()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -853,14 +855,16 @@ void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) {
|
||||
EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),
|
||||
LoVT.getVectorNumElements());
|
||||
LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
|
||||
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
|
||||
DAG.getConstant(InNVT.getVectorNumElements(),
|
||||
TLI.getVectorIdxTy()));
|
||||
|
||||
RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
|
||||
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
|
||||
DAG.getConstant(InNVT.getVectorNumElements(),
|
||||
TLI.getVectorIdxTy()));
|
||||
|
||||
Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2));
|
||||
Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2));
|
||||
@ -882,9 +886,10 @@ void DAGTypeLegalizer::SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo,
|
||||
EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),
|
||||
LoVT.getVectorNumElements());
|
||||
Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
|
||||
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
|
||||
DAG.getConstant(InNVT.getVectorNumElements(),
|
||||
TLI.getVectorIdxTy()));
|
||||
}
|
||||
|
||||
if (N->getOpcode() == ISD::FP_ROUND) {
|
||||
@ -995,7 +1000,8 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N,
|
||||
|
||||
// Extract the vector element by hand.
|
||||
SVOps.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT,
|
||||
Inputs[Input], DAG.getIntPtrConstant(Idx)));
|
||||
Inputs[Input], DAG.getConstant(Idx,
|
||||
TLI.getVectorIdxTy())));
|
||||
}
|
||||
|
||||
// Construct the Lo/Hi output using a BUILD_VECTOR.
|
||||
@ -1113,8 +1119,8 @@ SDValue DAGTypeLegalizer::SplitVecOp_VSELECT(SDNode *N, unsigned OpNo) {
|
||||
assert(LoNumElts == HiNumElts && "Asymmetric vector split?");
|
||||
|
||||
LLVMContext &Ctx = *DAG.getContext();
|
||||
SDValue Zero = DAG.getIntPtrConstant(0);
|
||||
SDValue LoElts = DAG.getIntPtrConstant(LoNumElts);
|
||||
SDValue Zero = DAG.getConstant(0, TLI.getVectorIdxTy());
|
||||
SDValue LoElts = DAG.getConstant(LoNumElts, TLI.getVectorIdxTy());
|
||||
EVT Src0VT = Src0.getValueType();
|
||||
EVT Src0EltTy = Src0VT.getVectorElementType();
|
||||
EVT MaskEltTy = MaskVT.getVectorElementType();
|
||||
@ -1289,7 +1295,7 @@ SDValue DAGTypeLegalizer::SplitVecOp_CONCAT_VECTORS(SDNode *N) {
|
||||
for (unsigned i = 0, e = Op.getValueType().getVectorNumElements();
|
||||
i != e; ++i) {
|
||||
Elts.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT,
|
||||
Op, DAG.getIntPtrConstant(i)));
|
||||
Op, DAG.getConstant(i, TLI.getVectorIdxTy())));
|
||||
|
||||
}
|
||||
}
|
||||
@ -1338,9 +1344,10 @@ SDValue DAGTypeLegalizer::SplitVecOp_TRUNCATE(SDNode *N) {
|
||||
EVT SplitVT = EVT::getVectorVT(*DAG.getContext(),
|
||||
InVT.getVectorElementType(), NumElements/2);
|
||||
SDValue InLoVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SplitVT, InVec,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
SDValue InHiVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SplitVT, InVec,
|
||||
DAG.getIntPtrConstant(NumElements/2));
|
||||
DAG.getConstant(NumElements/2,
|
||||
TLI.getVectorIdxTy()));
|
||||
// Truncate them to 1/2 the element size.
|
||||
EVT HalfElementVT = EVT::getIntegerVT(*DAG.getContext(), InElementSize/2);
|
||||
EVT HalfVT = EVT::getVectorVT(*DAG.getContext(), HalfElementVT,
|
||||
@ -1567,9 +1574,9 @@ SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
|
||||
while (CurNumElts != 0) {
|
||||
while (CurNumElts >= NumElts) {
|
||||
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp1,
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI.getVectorIdxTy()));
|
||||
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp2,
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI.getVectorIdxTy()));
|
||||
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, VT, EOp1, EOp2);
|
||||
Idx += NumElts;
|
||||
CurNumElts -= NumElts;
|
||||
@ -1582,9 +1589,11 @@ SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
|
||||
if (NumElts == 1) {
|
||||
for (unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
|
||||
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
||||
InOp1, DAG.getIntPtrConstant(Idx));
|
||||
InOp1, DAG.getConstant(Idx,
|
||||
TLI.getVectorIdxTy()));
|
||||
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
||||
InOp2, DAG.getIntPtrConstant(Idx));
|
||||
InOp2, DAG.getConstant(Idx,
|
||||
TLI.getVectorIdxTy()));
|
||||
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, WidenEltVT,
|
||||
EOp1, EOp2);
|
||||
}
|
||||
@ -1622,7 +1631,8 @@ SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
|
||||
unsigned NumToInsert = ConcatEnd - Idx - 1;
|
||||
for (unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
|
||||
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NextVT, VecOp,
|
||||
ConcatOps[OpIdx], DAG.getIntPtrConstant(i));
|
||||
ConcatOps[OpIdx], DAG.getConstant(i,
|
||||
TLI.getVectorIdxTy()));
|
||||
}
|
||||
ConcatOps[Idx+1] = VecOp;
|
||||
ConcatEnd = Idx + 2;
|
||||
@ -1710,7 +1720,8 @@ SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
|
||||
|
||||
if (InVTNumElts % WidenNumElts == 0) {
|
||||
SDValue InVal = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InWidenVT,
|
||||
InOp, DAG.getIntPtrConstant(0));
|
||||
InOp, DAG.getConstant(0,
|
||||
TLI.getVectorIdxTy()));
|
||||
// Extract the input and convert the shorten input vector.
|
||||
if (N->getNumOperands() == 1)
|
||||
return DAG.getNode(Opcode, DL, WidenVT, InVal);
|
||||
@ -1725,7 +1736,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
|
||||
unsigned i;
|
||||
for (i=0; i < MinElts; ++i) {
|
||||
SDValue Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, InEltVT, InOp,
|
||||
DAG.getIntPtrConstant(i));
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
if (N->getNumOperands() == 1)
|
||||
Ops[i] = DAG.getNode(Opcode, DL, EltVT, Val);
|
||||
else
|
||||
@ -1953,7 +1964,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONCAT_VECTORS(SDNode *N) {
|
||||
InOp = GetWidenedVector(InOp);
|
||||
for (unsigned j=0; j < NumInElts; ++j)
|
||||
Ops[Idx++] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
|
||||
DAG.getIntPtrConstant(j));
|
||||
DAG.getConstant(j, TLI.getVectorIdxTy()));
|
||||
}
|
||||
SDValue UndefVal = DAG.getUNDEF(EltVT);
|
||||
for (; Idx < WidenNumElts; ++Idx)
|
||||
@ -2011,7 +2022,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {
|
||||
if (InVTNumElts % WidenNumElts == 0) {
|
||||
// Extract the input and convert the shorten input vector.
|
||||
InOp = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InWidenVT, InOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
|
||||
SatOp, CvtCode);
|
||||
}
|
||||
@ -2027,7 +2038,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {
|
||||
unsigned i;
|
||||
for (i=0; i < MinElts; ++i) {
|
||||
SDValue ExtVal = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InEltVT, InOp,
|
||||
DAG.getIntPtrConstant(i));
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
Ops[i] = DAG.getConvertRndSat(WidenVT, dl, ExtVal, DTyOp, STyOp, RndOp,
|
||||
SatOp, CvtCode);
|
||||
}
|
||||
@ -2070,7 +2081,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) {
|
||||
unsigned i;
|
||||
for (i=0; i < NumElts; ++i)
|
||||
Ops[i] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
|
||||
DAG.getIntPtrConstant(IdxVal+i));
|
||||
DAG.getConstant(IdxVal+i, TLI.getVectorIdxTy()));
|
||||
|
||||
SDValue UndefVal = DAG.getUNDEF(EltVT);
|
||||
for (; i < WidenNumElts; ++i)
|
||||
@ -2297,7 +2308,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_Convert(SDNode *N) {
|
||||
for (unsigned i=0; i < NumElts; ++i)
|
||||
Ops[i] = DAG.getNode(Opcode, dl, EltVT,
|
||||
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InEltVT, InOp,
|
||||
DAG.getIntPtrConstant(i)));
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy())));
|
||||
|
||||
return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElts);
|
||||
}
|
||||
@ -2318,7 +2329,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_BITCAST(SDNode *N) {
|
||||
if (TLI.isTypeLegal(NewVT)) {
|
||||
SDValue BitOp = DAG.getNode(ISD::BITCAST, dl, NewVT, InOp);
|
||||
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, VT, BitOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2346,7 +2357,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS(SDNode *N) {
|
||||
InOp = GetWidenedVector(InOp);
|
||||
for (unsigned j=0; j < NumInElts; ++j)
|
||||
Ops[Idx++] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
|
||||
DAG.getIntPtrConstant(j));
|
||||
DAG.getConstant(j, TLI.getVectorIdxTy()));
|
||||
}
|
||||
return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElts);
|
||||
}
|
||||
@ -2401,7 +2412,8 @@ SDValue DAGTypeLegalizer::WidenVecOp_SETCC(SDNode *N) {
|
||||
SVT.getVectorElementType(),
|
||||
N->getValueType(0).getVectorNumElements());
|
||||
SDValue CC = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl,
|
||||
ResVT, WideSETCC, DAG.getIntPtrConstant(0));
|
||||
ResVT, WideSETCC, DAG.getConstant(0,
|
||||
TLI.getVectorIdxTy()));
|
||||
|
||||
return PromoteTargetBoolean(CC, N->getValueType(0));
|
||||
}
|
||||
@ -2474,6 +2486,7 @@ static EVT FindMemType(SelectionDAG& DAG, const TargetLowering &TLI,
|
||||
static SDValue BuildVectorFromScalar(SelectionDAG& DAG, EVT VecTy,
|
||||
SmallVectorImpl<SDValue> &LdOps,
|
||||
unsigned Start, unsigned End) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
SDLoc dl(LdOps[Start]);
|
||||
EVT LdTy = LdOps[Start].getValueType();
|
||||
unsigned Width = VecTy.getSizeInBits();
|
||||
@ -2494,7 +2507,7 @@ static SDValue BuildVectorFromScalar(SelectionDAG& DAG, EVT VecTy,
|
||||
LdTy = NewLdTy;
|
||||
}
|
||||
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NewVecVT, VecOp, LdOps[i],
|
||||
DAG.getIntPtrConstant(Idx++));
|
||||
DAG.getConstant(Idx++, TLI.getVectorIdxTy()));
|
||||
}
|
||||
return DAG.getNode(ISD::BITCAST, dl, VecTy, VecOp);
|
||||
}
|
||||
@ -2733,7 +2746,7 @@ void DAGTypeLegalizer::GenWidenVectorStores(SmallVectorImpl<SDValue> &StChain,
|
||||
unsigned NumVTElts = NewVT.getVectorNumElements();
|
||||
do {
|
||||
SDValue EOp = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, NewVT, ValOp,
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI.getVectorIdxTy()));
|
||||
StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr,
|
||||
ST->getPointerInfo().getWithOffset(Offset),
|
||||
isVolatile, isNonTemporal,
|
||||
@ -2753,7 +2766,7 @@ void DAGTypeLegalizer::GenWidenVectorStores(SmallVectorImpl<SDValue> &StChain,
|
||||
Idx = Idx * ValEltWidth / NewVTWidth;
|
||||
do {
|
||||
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NewVT, VecOp,
|
||||
DAG.getIntPtrConstant(Idx++));
|
||||
DAG.getConstant(Idx++, TLI.getVectorIdxTy()));
|
||||
StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr,
|
||||
ST->getPointerInfo().getWithOffset(Offset),
|
||||
isVolatile, isNonTemporal,
|
||||
@ -2798,7 +2811,7 @@ DAGTypeLegalizer::GenWidenVectorTruncStores(SmallVectorImpl<SDValue> &StChain,
|
||||
unsigned Increment = ValEltVT.getSizeInBits() / 8;
|
||||
unsigned NumElts = StVT.getVectorNumElements();
|
||||
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ValEltVT, ValOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, BasePtr,
|
||||
ST->getPointerInfo(), StEltVT,
|
||||
isVolatile, isNonTemporal, Align));
|
||||
@ -2807,7 +2820,7 @@ DAGTypeLegalizer::GenWidenVectorTruncStores(SmallVectorImpl<SDValue> &StChain,
|
||||
SDValue NewBasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(),
|
||||
BasePtr, DAG.getIntPtrConstant(Offset));
|
||||
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ValEltVT, ValOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, NewBasePtr,
|
||||
ST->getPointerInfo().getWithOffset(Offset),
|
||||
StEltVT, isVolatile, isNonTemporal,
|
||||
@ -2844,7 +2857,7 @@ SDValue DAGTypeLegalizer::ModifyToType(SDValue InOp, EVT NVT) {
|
||||
|
||||
if (WidenNumElts < InNumElts && InNumElts % WidenNumElts)
|
||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, NVT, InOp,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
|
||||
// Fall back to extract and build.
|
||||
SmallVector<SDValue, 16> Ops(WidenNumElts);
|
||||
@ -2853,7 +2866,7 @@ SDValue DAGTypeLegalizer::ModifyToType(SDValue InOp, EVT NVT) {
|
||||
unsigned Idx;
|
||||
for (Idx = 0; Idx < MinNumElts; ++Idx)
|
||||
Ops[Idx] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI.getVectorIdxTy()));
|
||||
|
||||
SDValue UndefVal = DAG.getUNDEF(EltVT);
|
||||
for ( ; Idx < WidenNumElts; ++Idx)
|
||||
|
@ -6140,7 +6140,7 @@ SDValue SelectionDAG::UnrollVectorOp(SDNode *N, unsigned ResNE) {
|
||||
Operands[j] = getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
OperandEltVT,
|
||||
Operand,
|
||||
getConstant(i, TLI->getPointerTy()));
|
||||
getConstant(i, TLI->getVectorIdxTy()));
|
||||
} else {
|
||||
// A scalar operand; just use it as is.
|
||||
Operands[j] = Operand;
|
||||
|
@ -281,7 +281,7 @@ static SDValue getCopyFromPartsVector(SelectionDAG &DAG, SDLoc DL,
|
||||
assert(PartEVT.getVectorNumElements() > ValueVT.getVectorNumElements() &&
|
||||
"Cannot narrow, it would be a lossy transformation");
|
||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ValueVT, Val,
|
||||
DAG.getIntPtrConstant(0));
|
||||
DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
}
|
||||
|
||||
// Vector/Vector bitcast.
|
||||
@ -490,7 +490,8 @@ static void getCopyToPartsVector(SelectionDAG &DAG, SDLoc DL,
|
||||
SmallVector<SDValue, 16> Ops;
|
||||
for (unsigned i = 0, e = ValueVT.getVectorNumElements(); i != e; ++i)
|
||||
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
|
||||
ElementVT, Val, DAG.getIntPtrConstant(i)));
|
||||
ElementVT, Val, DAG.getConstant(i,
|
||||
TLI.getVectorIdxTy())));
|
||||
|
||||
for (unsigned i = ValueVT.getVectorNumElements(),
|
||||
e = PartVT.getVectorNumElements(); i != e; ++i)
|
||||
@ -516,7 +517,7 @@ static void getCopyToPartsVector(SelectionDAG &DAG, SDLoc DL,
|
||||
assert(ValueVT.getVectorNumElements() == 1 &&
|
||||
"Only trivial vector-to-scalar conversions should get here!");
|
||||
Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
|
||||
PartVT, Val, DAG.getIntPtrConstant(0));
|
||||
PartVT, Val, DAG.getConstant(0, TLI.getVectorIdxTy()));
|
||||
|
||||
bool Smaller = ValueVT.bitsLE(PartVT);
|
||||
Val = DAG.getNode((Smaller ? ISD::TRUNCATE : ISD::ANY_EXTEND),
|
||||
@ -546,10 +547,12 @@ static void getCopyToPartsVector(SelectionDAG &DAG, SDLoc DL,
|
||||
if (IntermediateVT.isVector())
|
||||
Ops[i] = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
|
||||
IntermediateVT, Val,
|
||||
DAG.getIntPtrConstant(i * (NumElements / NumIntermediates)));
|
||||
DAG.getConstant(i * (NumElements / NumIntermediates),
|
||||
TLI.getVectorIdxTy()));
|
||||
else
|
||||
Ops[i] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
|
||||
IntermediateVT, Val, DAG.getIntPtrConstant(i));
|
||||
IntermediateVT, Val,
|
||||
DAG.getConstant(i, TLI.getVectorIdxTy()));
|
||||
}
|
||||
|
||||
// Split the intermediate operands into legal parts.
|
||||
@ -2857,21 +2860,21 @@ void SelectionDAGBuilder::visitBitCast(const User &I) {
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitInsertElement(const User &I) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
SDValue InVec = getValue(I.getOperand(0));
|
||||
SDValue InVal = getValue(I.getOperand(1));
|
||||
SDValue InIdx = DAG.getNode(ISD::ZERO_EXTEND, getCurSDLoc(),
|
||||
TM.getTargetLowering()->getPointerTy(),
|
||||
getValue(I.getOperand(2)));
|
||||
SDValue InIdx = DAG.getSExtOrTrunc(getValue(I.getOperand(2)),
|
||||
getCurSDLoc(), TLI.getVectorIdxTy());
|
||||
setValue(&I, DAG.getNode(ISD::INSERT_VECTOR_ELT, getCurSDLoc(),
|
||||
TM.getTargetLowering()->getValueType(I.getType()),
|
||||
InVec, InVal, InIdx));
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitExtractElement(const User &I) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
SDValue InVec = getValue(I.getOperand(0));
|
||||
SDValue InIdx = DAG.getNode(ISD::ZERO_EXTEND, getCurSDLoc(),
|
||||
TM.getTargetLowering()->getPointerTy(),
|
||||
getValue(I.getOperand(1)));
|
||||
SDValue InIdx = DAG.getSExtOrTrunc(getValue(I.getOperand(1)),
|
||||
getCurSDLoc(), TLI.getVectorIdxTy());
|
||||
setValue(&I, DAG.getNode(ISD::EXTRACT_VECTOR_ELT, getCurSDLoc(),
|
||||
TM.getTargetLowering()->getValueType(I.getType()),
|
||||
InVec, InIdx));
|
||||
@ -3019,7 +3022,8 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
|
||||
Src = DAG.getUNDEF(VT);
|
||||
else
|
||||
Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, getCurSDLoc(), VT,
|
||||
Src, DAG.getIntPtrConstant(StartIdx[Input]));
|
||||
Src, DAG.getConstant(StartIdx[Input],
|
||||
TLI->getVectorIdxTy()));
|
||||
}
|
||||
|
||||
// Calculate new mask.
|
||||
@ -3045,7 +3049,7 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
|
||||
// replacing the shuffle with extract and build vector.
|
||||
// to insert and build vector.
|
||||
EVT EltVT = VT.getVectorElementType();
|
||||
EVT PtrVT = TLI->getPointerTy();
|
||||
EVT IdxVT = TLI->getVectorIdxTy();
|
||||
SmallVector<SDValue,8> Ops;
|
||||
for (unsigned i = 0; i != MaskNumElts; ++i) {
|
||||
int Idx = Mask[i];
|
||||
@ -3058,7 +3062,7 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
|
||||
if (Idx >= (int)SrcNumElts) Idx -= SrcNumElts;
|
||||
|
||||
Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, getCurSDLoc(),
|
||||
EltVT, Src, DAG.getConstant(Idx, PtrVT));
|
||||
EltVT, Src, DAG.getConstant(Idx, IdxVT));
|
||||
}
|
||||
|
||||
Ops.push_back(Res);
|
||||
@ -4817,7 +4821,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
||||
Res = DAG.getNode(ISD::INSERT_SUBVECTOR, sdl, DestVT,
|
||||
getValue(I.getArgOperand(0)),
|
||||
getValue(I.getArgOperand(1)),
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI->getVectorIdxTy()));
|
||||
setValue(&I, Res);
|
||||
return 0;
|
||||
}
|
||||
@ -4830,7 +4834,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
||||
DestVT.getVectorNumElements();
|
||||
Res = DAG.getNode(ISD::EXTRACT_SUBVECTOR, sdl, DestVT,
|
||||
getValue(I.getArgOperand(0)),
|
||||
DAG.getIntPtrConstant(Idx));
|
||||
DAG.getConstant(Idx, TLI->getVectorIdxTy()));
|
||||
setValue(&I, Res);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user