mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-30 15:45:26 +00:00
Make Extract128BitVector and Insert128BitVector take an unsigned instead of an ConstantNode SDValue. getConstant was almost always called just before only to have the functions take it apart and build a new ConstantSDNode.
llvm-svn: 155325
This commit is contained in:
parent
5669044c57
commit
2dedfa7805
@ -62,10 +62,8 @@ static SDValue getMOVL(SelectionDAG &DAG, DebugLoc dl, EVT VT, SDValue V1,
|
||||
/// simple subregister reference. Idx is an index in the 128 bits we
|
||||
/// want. It need not be aligned to a 128-bit bounday. That makes
|
||||
/// lowering EXTRACT_VECTOR_ELT operations easier.
|
||||
static SDValue Extract128BitVector(SDValue Vec,
|
||||
SDValue Idx,
|
||||
SelectionDAG &DAG,
|
||||
DebugLoc dl) {
|
||||
static SDValue Extract128BitVector(SDValue Vec, unsigned IdxVal,
|
||||
SelectionDAG &DAG, DebugLoc dl) {
|
||||
EVT VT = Vec.getValueType();
|
||||
assert(VT.getSizeInBits() == 256 && "Unexpected vector size!");
|
||||
EVT ElVT = VT.getVectorElementType();
|
||||
@ -77,26 +75,20 @@ static SDValue Extract128BitVector(SDValue Vec,
|
||||
if (Vec.getOpcode() == ISD::UNDEF)
|
||||
return DAG.getUNDEF(ResultVT);
|
||||
|
||||
if (isa<ConstantSDNode>(Idx)) {
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
// Extract the relevant 128 bits. Generate an EXTRACT_SUBVECTOR
|
||||
// we can match to VEXTRACTF128.
|
||||
unsigned ElemsPerChunk = 128 / ElVT.getSizeInBits();
|
||||
|
||||
// Extract the relevant 128 bits. Generate an EXTRACT_SUBVECTOR
|
||||
// we can match to VEXTRACTF128.
|
||||
unsigned ElemsPerChunk = 128 / ElVT.getSizeInBits();
|
||||
// This is the index of the first element of the 128-bit chunk
|
||||
// we want.
|
||||
unsigned NormalizedIdxVal = (((IdxVal * ElVT.getSizeInBits()) / 128)
|
||||
* ElemsPerChunk);
|
||||
|
||||
// This is the index of the first element of the 128-bit chunk
|
||||
// we want.
|
||||
unsigned NormalizedIdxVal = (((IdxVal * ElVT.getSizeInBits()) / 128)
|
||||
* ElemsPerChunk);
|
||||
SDValue VecIdx = DAG.getConstant(NormalizedIdxVal, MVT::i32);
|
||||
SDValue Result = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, ResultVT, Vec,
|
||||
VecIdx);
|
||||
|
||||
SDValue VecIdx = DAG.getConstant(NormalizedIdxVal, MVT::i32);
|
||||
SDValue Result = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, ResultVT, Vec,
|
||||
VecIdx);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Generate a DAG to put 128-bits into a vector > 128 bits. This
|
||||
@ -104,34 +96,27 @@ static SDValue Extract128BitVector(SDValue Vec,
|
||||
/// simple superregister reference. Idx is an index in the 128 bits
|
||||
/// we want. It need not be aligned to a 128-bit bounday. That makes
|
||||
/// lowering INSERT_VECTOR_ELT operations easier.
|
||||
static SDValue Insert128BitVector(SDValue Result,
|
||||
SDValue Vec,
|
||||
SDValue Idx,
|
||||
SelectionDAG &DAG,
|
||||
static SDValue Insert128BitVector(SDValue Result, SDValue Vec,
|
||||
unsigned IdxVal, SelectionDAG &DAG,
|
||||
DebugLoc dl) {
|
||||
if (isa<ConstantSDNode>(Idx)) {
|
||||
EVT VT = Vec.getValueType();
|
||||
assert(VT.getSizeInBits() == 128 && "Unexpected vector size!");
|
||||
EVT VT = Vec.getValueType();
|
||||
assert(VT.getSizeInBits() == 128 && "Unexpected vector size!");
|
||||
|
||||
EVT ElVT = VT.getVectorElementType();
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
EVT ResultVT = Result.getValueType();
|
||||
EVT ElVT = VT.getVectorElementType();
|
||||
EVT ResultVT = Result.getValueType();
|
||||
|
||||
// Insert the relevant 128 bits.
|
||||
unsigned ElemsPerChunk = 128/ElVT.getSizeInBits();
|
||||
// Insert the relevant 128 bits.
|
||||
unsigned ElemsPerChunk = 128/ElVT.getSizeInBits();
|
||||
|
||||
// This is the index of the first element of the 128-bit chunk
|
||||
// we want.
|
||||
unsigned NormalizedIdxVal = (((IdxVal * ElVT.getSizeInBits())/128)
|
||||
* ElemsPerChunk);
|
||||
// This is the index of the first element of the 128-bit chunk
|
||||
// we want.
|
||||
unsigned NormalizedIdxVal = (((IdxVal * ElVT.getSizeInBits())/128)
|
||||
* ElemsPerChunk);
|
||||
|
||||
SDValue VecIdx = DAG.getConstant(NormalizedIdxVal, MVT::i32);
|
||||
Result = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, ResultVT, Result, Vec,
|
||||
VecIdx);
|
||||
return Result;
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
SDValue VecIdx = DAG.getConstant(NormalizedIdxVal, MVT::i32);
|
||||
Result = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, ResultVT, Result, Vec,
|
||||
VecIdx);
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Concat two 128-bit vectors into a 256 bit vector using VINSERTF128
|
||||
@ -141,10 +126,8 @@ static SDValue Insert128BitVector(SDValue Result,
|
||||
static SDValue Concat128BitVectors(SDValue V1, SDValue V2, EVT VT,
|
||||
unsigned NumElems, SelectionDAG &DAG,
|
||||
DebugLoc dl) {
|
||||
SDValue V = Insert128BitVector(DAG.getUNDEF(VT), V1,
|
||||
DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
return Insert128BitVector(V, V2, DAG.getConstant(NumElems/2, MVT::i32),
|
||||
DAG, dl);
|
||||
SDValue V = Insert128BitVector(DAG.getUNDEF(VT), V1, 0, DAG, dl);
|
||||
return Insert128BitVector(V, V2, NumElems/2, DAG, dl);
|
||||
}
|
||||
|
||||
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
||||
@ -4341,7 +4324,7 @@ static SDValue PromoteSplat(ShuffleVectorSDNode *SV, SelectionDAG &DAG) {
|
||||
// the splat element index when it refers to the higher register.
|
||||
if (Size == 256) {
|
||||
unsigned Idx = (EltNo >= NumElems/2) ? NumElems/2 : 0;
|
||||
V1 = Extract128BitVector(V1, DAG.getConstant(Idx, MVT::i32), DAG, dl);
|
||||
V1 = Extract128BitVector(V1, Idx, DAG, dl);
|
||||
if (Idx > 0)
|
||||
EltNo -= NumElems/2;
|
||||
}
|
||||
@ -5144,8 +5127,7 @@ X86TargetLowering::LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const {
|
||||
Item = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v4i32, Item);
|
||||
if (VT.getSizeInBits() == 256) {
|
||||
SDValue ZeroVec = getZeroVector(MVT::v8i32, Subtarget, DAG, dl);
|
||||
Item = Insert128BitVector(ZeroVec, Item, DAG.getConstant(0, MVT::i32),
|
||||
DAG, dl);
|
||||
Item = Insert128BitVector(ZeroVec, Item, 0, DAG, dl);
|
||||
} else {
|
||||
assert(VT.getSizeInBits() == 128 && "Expected an SSE value type!");
|
||||
Item = getShuffleVectorZeroOrUndef(Item, 0, true, Subtarget, DAG);
|
||||
@ -6035,13 +6017,12 @@ LowerVECTOR_SHUFFLE_256(ShuffleVectorSDNode *SVOp, SelectionDAG &DAG) {
|
||||
Shufs[l] = DAG.getUNDEF(NVT);
|
||||
} else {
|
||||
SDValue Op0 = Extract128BitVector(SVOp->getOperand(InputUsed[0] / 2),
|
||||
DAG.getConstant((InputUsed[0] % 2) * NumLaneElems, MVT::i32),
|
||||
DAG, dl);
|
||||
(InputUsed[0] % 2) * NumLaneElems,
|
||||
DAG, dl);
|
||||
// If only one input was used, use an undefined vector for the other.
|
||||
SDValue Op1 = (InputUsed[1] < 0) ? DAG.getUNDEF(NVT) :
|
||||
Extract128BitVector(SVOp->getOperand(InputUsed[1] / 2),
|
||||
DAG.getConstant((InputUsed[1] % 2) * NumLaneElems, MVT::i32),
|
||||
DAG, dl);
|
||||
(InputUsed[1] % 2) * NumLaneElems, DAG, dl);
|
||||
// At least one input vector was used. Create a new shuffle vector.
|
||||
Shufs[l] = DAG.getVectorShuffle(NVT, dl, Op0, Op1, &Mask[0]);
|
||||
}
|
||||
@ -6776,8 +6757,7 @@ X86TargetLowering::LowerEXTRACT_VECTOR_ELT(SDValue Op,
|
||||
|
||||
// Get the 128-bit vector.
|
||||
bool Upper = IdxVal >= NumElems/2;
|
||||
Vec = Extract128BitVector(Vec,
|
||||
DAG.getConstant(Upper ? NumElems/2 : 0, MVT::i32), DAG, dl);
|
||||
Vec = Extract128BitVector(Vec, Upper ? NumElems/2 : 0, DAG, dl);
|
||||
|
||||
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, Op.getValueType(), Vec,
|
||||
Upper ? DAG.getConstant(IdxVal-NumElems/2, MVT::i32) : Idx);
|
||||
@ -6916,7 +6896,7 @@ X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const {
|
||||
unsigned NumElems = VT.getVectorNumElements();
|
||||
unsigned IdxVal = cast<ConstantSDNode>(N2)->getZExtValue();
|
||||
bool Upper = IdxVal >= NumElems/2;
|
||||
SDValue Ins128Idx = DAG.getConstant(Upper ? NumElems/2 : 0, MVT::i32);
|
||||
unsigned Ins128Idx = Upper ? NumElems/2 : 0;
|
||||
SDValue V = Extract128BitVector(N0, Ins128Idx, DAG, dl);
|
||||
|
||||
// Insert the element into the desired half.
|
||||
@ -6962,9 +6942,7 @@ X86TargetLowering::LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const {
|
||||
Op = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, VT128, Op.getOperand(0));
|
||||
|
||||
// Insert the 128-bit vector.
|
||||
return Insert128BitVector(DAG.getUNDEF(OpVT), Op,
|
||||
DAG.getConstant(0, MVT::i32),
|
||||
DAG, dl);
|
||||
return Insert128BitVector(DAG.getUNDEF(OpVT), Op, 0, DAG, dl);
|
||||
}
|
||||
|
||||
if (Op.getValueType() == MVT::v1i64 &&
|
||||
@ -6988,9 +6966,11 @@ X86TargetLowering::LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const {
|
||||
SDValue Vec = Op.getNode()->getOperand(0);
|
||||
SDValue Idx = Op.getNode()->getOperand(1);
|
||||
|
||||
if (Op.getNode()->getValueType(0).getSizeInBits() == 128
|
||||
&& Vec.getNode()->getValueType(0).getSizeInBits() == 256) {
|
||||
return Extract128BitVector(Vec, Idx, DAG, dl);
|
||||
if (Op.getNode()->getValueType(0).getSizeInBits() == 128 &&
|
||||
Vec.getNode()->getValueType(0).getSizeInBits() == 256 &&
|
||||
isa<ConstantSDNode>(Idx)) {
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
return Extract128BitVector(Vec, IdxVal, DAG, dl);
|
||||
}
|
||||
}
|
||||
return SDValue();
|
||||
@ -7007,9 +6987,11 @@ X86TargetLowering::LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const {
|
||||
SDValue SubVec = Op.getNode()->getOperand(1);
|
||||
SDValue Idx = Op.getNode()->getOperand(2);
|
||||
|
||||
if (Op.getNode()->getValueType(0).getSizeInBits() == 256
|
||||
&& SubVec.getNode()->getValueType(0).getSizeInBits() == 128) {
|
||||
return Insert128BitVector(Vec, SubVec, Idx, DAG, dl);
|
||||
if (Op.getNode()->getValueType(0).getSizeInBits() == 256 &&
|
||||
SubVec.getNode()->getValueType(0).getSizeInBits() == 128 &&
|
||||
isa<ConstantSDNode>(Idx)) {
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
return Insert128BitVector(Vec, SubVec, IdxVal, DAG, dl);
|
||||
}
|
||||
}
|
||||
return SDValue();
|
||||
@ -8355,18 +8337,16 @@ static SDValue Lower256IntVSETCC(SDValue Op, SelectionDAG &DAG) {
|
||||
int NumElems = VT.getVectorNumElements();
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
SDValue CC = Op.getOperand(2);
|
||||
SDValue Idx0 = DAG.getConstant(0, MVT::i32);
|
||||
SDValue Idx1 = DAG.getConstant(NumElems/2, MVT::i32);
|
||||
|
||||
// Extract the LHS vectors
|
||||
SDValue LHS = Op.getOperand(0);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, Idx0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, Idx1, DAG, dl);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, 0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, NumElems/2, DAG, dl);
|
||||
|
||||
// Extract the RHS vectors
|
||||
SDValue RHS = Op.getOperand(1);
|
||||
SDValue RHS1 = Extract128BitVector(RHS, Idx0, DAG, dl);
|
||||
SDValue RHS2 = Extract128BitVector(RHS, Idx1, DAG, dl);
|
||||
SDValue RHS1 = Extract128BitVector(RHS, 0, DAG, dl);
|
||||
SDValue RHS2 = Extract128BitVector(RHS, NumElems/2, DAG, dl);
|
||||
|
||||
// Issue the operation on the smaller types and concatenate the result back
|
||||
MVT EltVT = VT.getVectorElementType().getSimpleVT();
|
||||
@ -10153,18 +10133,16 @@ static SDValue Lower256IntArith(SDValue Op, SelectionDAG &DAG) {
|
||||
|
||||
int NumElems = VT.getVectorNumElements();
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
SDValue Idx0 = DAG.getConstant(0, MVT::i32);
|
||||
SDValue Idx1 = DAG.getConstant(NumElems/2, MVT::i32);
|
||||
|
||||
// Extract the LHS vectors
|
||||
SDValue LHS = Op.getOperand(0);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, Idx0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, Idx1, DAG, dl);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, 0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, NumElems/2, DAG, dl);
|
||||
|
||||
// Extract the RHS vectors
|
||||
SDValue RHS = Op.getOperand(1);
|
||||
SDValue RHS1 = Extract128BitVector(RHS, Idx0, DAG, dl);
|
||||
SDValue RHS2 = Extract128BitVector(RHS, Idx1, DAG, dl);
|
||||
SDValue RHS1 = Extract128BitVector(RHS, 0, DAG, dl);
|
||||
SDValue RHS2 = Extract128BitVector(RHS, NumElems/2, DAG, dl);
|
||||
|
||||
MVT EltVT = VT.getVectorElementType().getSimpleVT();
|
||||
EVT NewVT = MVT::getVectorVT(EltVT, NumElems/2);
|
||||
@ -10426,9 +10404,8 @@ SDValue X86TargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG) const {
|
||||
EVT NewVT = MVT::getVectorVT(EltVT, NumElems/2);
|
||||
|
||||
// Extract the two vectors
|
||||
SDValue V1 = Extract128BitVector(R, DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
SDValue V2 = Extract128BitVector(R, DAG.getConstant(NumElems/2, MVT::i32),
|
||||
DAG, dl);
|
||||
SDValue V1 = Extract128BitVector(R, 0, DAG, dl);
|
||||
SDValue V2 = Extract128BitVector(R, NumElems/2, DAG, dl);
|
||||
|
||||
// Recreate the shift amount vectors
|
||||
SDValue Amt1, Amt2;
|
||||
@ -10447,9 +10424,8 @@ SDValue X86TargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG) const {
|
||||
&Amt2Csts[0], NumElems/2);
|
||||
} else {
|
||||
// Variable shift amount
|
||||
Amt1 = Extract128BitVector(Amt, DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
Amt2 = Extract128BitVector(Amt, DAG.getConstant(NumElems/2, MVT::i32),
|
||||
DAG, dl);
|
||||
Amt1 = Extract128BitVector(Amt, 0, DAG, dl);
|
||||
Amt2 = Extract128BitVector(Amt, NumElems/2, DAG, dl);
|
||||
}
|
||||
|
||||
// Issue new vector shifts for the smaller types
|
||||
@ -10560,13 +10536,11 @@ SDValue X86TargetLowering::LowerSIGN_EXTEND_INREG(SDValue Op,
|
||||
if (!Subtarget->hasAVX2()) {
|
||||
// needs to be split
|
||||
int NumElems = VT.getVectorNumElements();
|
||||
SDValue Idx0 = DAG.getConstant(0, MVT::i32);
|
||||
SDValue Idx1 = DAG.getConstant(NumElems/2, MVT::i32);
|
||||
|
||||
// Extract the LHS vectors
|
||||
SDValue LHS = Op.getOperand(0);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, Idx0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, Idx1, DAG, dl);
|
||||
SDValue LHS1 = Extract128BitVector(LHS, 0, DAG, dl);
|
||||
SDValue LHS2 = Extract128BitVector(LHS, NumElems/2, DAG, dl);
|
||||
|
||||
MVT EltVT = VT.getVectorElementType().getSimpleVT();
|
||||
EVT NewVT = MVT::getVectorVT(EltVT, NumElems/2);
|
||||
@ -12952,8 +12926,7 @@ static SDValue PerformShuffleCombine256(SDNode *N, SelectionDAG &DAG,
|
||||
// Emit a zeroed vector and insert the desired subvector on its
|
||||
// first half.
|
||||
SDValue Zeros = getZeroVector(VT, Subtarget, DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(Zeros, V1.getOperand(0),
|
||||
DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(Zeros, V1.getOperand(0), 0, DAG, dl);
|
||||
return DCI.CombineTo(N, InsV);
|
||||
}
|
||||
|
||||
@ -12963,19 +12936,15 @@ static SDValue PerformShuffleCombine256(SDNode *N, SelectionDAG &DAG,
|
||||
|
||||
// vector_shuffle <4, 5, 6, 7, u, u, u, u> or <2, 3, u, u>
|
||||
if (isShuffleHigh128VectorInsertLow(SVOp)) {
|
||||
SDValue V = Extract128BitVector(V1, DAG.getConstant(NumElems/2, MVT::i32),
|
||||
DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(DAG.getUNDEF(VT), V,
|
||||
DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
SDValue V = Extract128BitVector(V1, NumElems/2, DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(DAG.getUNDEF(VT), V, 0, DAG, dl);
|
||||
return DCI.CombineTo(N, InsV);
|
||||
}
|
||||
|
||||
// vector_shuffle <u, u, u, u, 0, 1, 2, 3> or <u, u, 0, 1>
|
||||
if (isShuffleLow128VectorInsertHigh(SVOp)) {
|
||||
SDValue V = Extract128BitVector(V1, DAG.getConstant(0, MVT::i32), DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(DAG.getUNDEF(VT), V,
|
||||
DAG.getConstant(NumElems/2, MVT::i32),
|
||||
DAG, dl);
|
||||
SDValue V = Extract128BitVector(V1, 0, DAG, dl);
|
||||
SDValue InsV = Insert128BitVector(DAG.getUNDEF(VT), V, NumElems/2, DAG, dl);
|
||||
return DCI.CombineTo(N, InsV);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user