mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 20:12:56 +02:00
[X86][SSE] LowerScalarImmediateShift - remove 32-bit vXi64 special case handling.
This is all handled generally by getTargetConstantBitsFromNode now llvm-svn: 343387
This commit is contained in:
parent
9661cf1100
commit
9d4246e3f3
@ -23515,8 +23515,10 @@ static SDValue LowerScalarImmediateShift(SDValue Op, SelectionDAG &DAG,
|
||||
// Optimize shl/srl/sra with constant shift amount.
|
||||
APInt UndefElts;
|
||||
SmallVector<APInt, 8> EltBits;
|
||||
if (getTargetConstantBitsFromNode(Amt, EltSizeInBits, UndefElts, EltBits,
|
||||
true, false)) {
|
||||
if (!getTargetConstantBitsFromNode(Amt, EltSizeInBits, UndefElts, EltBits,
|
||||
true, false))
|
||||
return SDValue();
|
||||
|
||||
int SplatIndex = -1;
|
||||
for (int i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
|
||||
if (UndefElts[i])
|
||||
@ -23591,72 +23593,6 @@ static SDValue LowerScalarImmediateShift(SDValue Op, SelectionDAG &DAG,
|
||||
}
|
||||
llvm_unreachable("Unknown shift opcode.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check cases (mainly 32-bit) where i64 is expanded into high and low parts.
|
||||
// TODO: Replace constant extraction with getTargetConstantBitsFromNode.
|
||||
if (!Subtarget.hasXOP() &&
|
||||
(VT == MVT::v2i64 || (Subtarget.hasInt256() && VT == MVT::v4i64) ||
|
||||
(Subtarget.hasAVX512() && VT == MVT::v8i64))) {
|
||||
|
||||
// AVX1 targets maybe extracting a 128-bit vector from a 256-bit constant.
|
||||
unsigned SubVectorScale = 1;
|
||||
if (Amt.getOpcode() == ISD::EXTRACT_SUBVECTOR) {
|
||||
SubVectorScale =
|
||||
Amt.getOperand(0).getValueSizeInBits() / Amt.getValueSizeInBits();
|
||||
Amt = Amt.getOperand(0);
|
||||
}
|
||||
|
||||
// Peek through any splat that was introduced for i64 shift vectorization.
|
||||
int SplatIndex = -1;
|
||||
if (ShuffleVectorSDNode *SVN = dyn_cast<ShuffleVectorSDNode>(Amt.getNode()))
|
||||
if (SVN->isSplat()) {
|
||||
SplatIndex = SVN->getSplatIndex();
|
||||
Amt = Amt.getOperand(0);
|
||||
assert(SplatIndex < (int)VT.getVectorNumElements() &&
|
||||
"Splat shuffle referencing second operand");
|
||||
}
|
||||
|
||||
if (Amt.getOpcode() != ISD::BITCAST ||
|
||||
Amt.getOperand(0).getOpcode() != ISD::BUILD_VECTOR)
|
||||
return SDValue();
|
||||
|
||||
Amt = Amt.getOperand(0);
|
||||
unsigned Ratio = Amt.getSimpleValueType().getVectorNumElements() /
|
||||
(SubVectorScale * VT.getVectorNumElements());
|
||||
unsigned RatioInLog2 = Log2_32_Ceil(Ratio);
|
||||
uint64_t ShiftAmt = 0;
|
||||
unsigned BaseOp = (SplatIndex < 0 ? 0 : SplatIndex * Ratio);
|
||||
for (unsigned i = 0; i != Ratio; ++i) {
|
||||
ConstantSDNode *C = dyn_cast<ConstantSDNode>(Amt.getOperand(i + BaseOp));
|
||||
if (!C)
|
||||
return SDValue();
|
||||
// 6 == Log2(64)
|
||||
ShiftAmt |= C->getZExtValue() << (i * (1 << (6 - RatioInLog2)));
|
||||
}
|
||||
|
||||
// Check remaining shift amounts (if not a splat).
|
||||
if (SplatIndex < 0) {
|
||||
for (unsigned i = Ratio; i != Amt.getNumOperands(); i += Ratio) {
|
||||
uint64_t ShAmt = 0;
|
||||
for (unsigned j = 0; j != Ratio; ++j) {
|
||||
ConstantSDNode *C = dyn_cast<ConstantSDNode>(Amt.getOperand(i + j));
|
||||
if (!C)
|
||||
return SDValue();
|
||||
// 6 == Log2(64)
|
||||
ShAmt |= C->getZExtValue() << (j * (1 << (6 - RatioInLog2)));
|
||||
}
|
||||
if (ShAmt != ShiftAmt)
|
||||
return SDValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (SupportedVectorShiftWithImm(VT, Subtarget, Op.getOpcode()))
|
||||
return getTargetVShiftByConstNode(X86Opc, dl, VT, R, ShiftAmt, DAG);
|
||||
|
||||
if (Op.getOpcode() == ISD::SRA)
|
||||
return ArithmeticShiftRight64(ShiftAmt);
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user