mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Fixed a few problems with vector shifts
- when transforming a vector shift of a non-immediate scalar shift amount, zero extend the i32 shift amount to i64 since the vector shift reads 64 bits - when transforming i16 vectors to use a vector shift, zero extend i16 shift amount - improve the code quality in some cases when transforming vectors to use a vector shift git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80935 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f67df794a
commit
efa422023f
@ -6359,9 +6359,23 @@ X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The vector shift intrinsics with scalars uses 32b shift amounts but
|
||||||
|
// the sse2/mmx shift instructions reads 64 bits. Set the upper 32 bits
|
||||||
|
// to be zero.
|
||||||
|
SDValue ShOps[4];
|
||||||
|
ShOps[0] = ShAmt;
|
||||||
|
ShOps[1] = DAG.getConstant(0, MVT::i32);
|
||||||
|
if (ShAmtVT == MVT::v4i32) {
|
||||||
|
ShOps[2] = DAG.getUNDEF(MVT::i32);
|
||||||
|
ShOps[3] = DAG.getUNDEF(MVT::i32);
|
||||||
|
ShAmt = DAG.getNode(ISD::BUILD_VECTOR, dl, ShAmtVT, &ShOps[0], 4);
|
||||||
|
} else {
|
||||||
|
ShAmt = DAG.getNode(ISD::BUILD_VECTOR, dl, ShAmtVT, &ShOps[0], 2);
|
||||||
|
}
|
||||||
|
|
||||||
EVT VT = Op.getValueType();
|
EVT VT = Op.getValueType();
|
||||||
ShAmt = DAG.getNode(ISD::BIT_CONVERT, dl, VT,
|
ShAmt = DAG.getNode(ISD::BIT_CONVERT, dl, VT, ShAmt);
|
||||||
DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, ShAmtVT, ShAmt));
|
|
||||||
return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT,
|
return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT,
|
||||||
DAG.getConstant(NewIntNo, MVT::i32),
|
DAG.getConstant(NewIntNo, MVT::i32),
|
||||||
Op.getOperand(1), ShAmt);
|
Op.getOperand(1), ShAmt);
|
||||||
@ -8554,7 +8568,7 @@ static SDValue PerformShiftCombine(SDNode* N, SelectionDAG &DAG,
|
|||||||
SDValue ShAmtOp = N->getOperand(1);
|
SDValue ShAmtOp = N->getOperand(1);
|
||||||
EVT EltVT = VT.getVectorElementType();
|
EVT EltVT = VT.getVectorElementType();
|
||||||
DebugLoc DL = N->getDebugLoc();
|
DebugLoc DL = N->getDebugLoc();
|
||||||
SDValue BaseShAmt;
|
SDValue BaseShAmt = SDValue();
|
||||||
if (ShAmtOp.getOpcode() == ISD::BUILD_VECTOR) {
|
if (ShAmtOp.getOpcode() == ISD::BUILD_VECTOR) {
|
||||||
unsigned NumElts = VT.getVectorNumElements();
|
unsigned NumElts = VT.getVectorNumElements();
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
@ -8573,15 +8587,34 @@ static SDValue PerformShiftCombine(SDNode* N, SelectionDAG &DAG,
|
|||||||
}
|
}
|
||||||
} else if (ShAmtOp.getOpcode() == ISD::VECTOR_SHUFFLE &&
|
} else if (ShAmtOp.getOpcode() == ISD::VECTOR_SHUFFLE &&
|
||||||
cast<ShuffleVectorSDNode>(ShAmtOp)->isSplat()) {
|
cast<ShuffleVectorSDNode>(ShAmtOp)->isSplat()) {
|
||||||
BaseShAmt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, ShAmtOp,
|
SDValue InVec = ShAmtOp.getOperand(0);
|
||||||
DAG.getIntPtrConstant(0));
|
if (InVec.getOpcode() == ISD::BUILD_VECTOR) {
|
||||||
|
unsigned NumElts = InVec.getValueType().getVectorNumElements();
|
||||||
|
unsigned i = 0;
|
||||||
|
for (; i != NumElts; ++i) {
|
||||||
|
SDValue Arg = InVec.getOperand(i);
|
||||||
|
if (Arg.getOpcode() == ISD::UNDEF) continue;
|
||||||
|
BaseShAmt = Arg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (InVec.getOpcode() == ISD::INSERT_VECTOR_ELT) {
|
||||||
|
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(InVec.getOperand(2))) {
|
||||||
|
unsigned SplatIdx = cast<ShuffleVectorSDNode>(ShAmtOp)->getSplatIndex();
|
||||||
|
if (C->getZExtValue() == SplatIdx)
|
||||||
|
BaseShAmt = InVec.getOperand(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (BaseShAmt.getNode() == 0)
|
||||||
|
BaseShAmt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, ShAmtOp,
|
||||||
|
DAG.getIntPtrConstant(0));
|
||||||
} else
|
} else
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
|
// The shift amount is an i32.
|
||||||
if (EltVT.bitsGT(MVT::i32))
|
if (EltVT.bitsGT(MVT::i32))
|
||||||
BaseShAmt = DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, BaseShAmt);
|
BaseShAmt = DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, BaseShAmt);
|
||||||
else if (EltVT.bitsLT(MVT::i32))
|
else if (EltVT.bitsLT(MVT::i32))
|
||||||
BaseShAmt = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i32, BaseShAmt);
|
BaseShAmt = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i32, BaseShAmt);
|
||||||
|
|
||||||
// The shift amount is identical so we can do a vector shift.
|
// The shift amount is identical so we can do a vector shift.
|
||||||
SDValue ValOp = N->getOperand(0);
|
SDValue ValOp = N->getOperand(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user