mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-23 04:28:40 +00:00
[DAG] fix formatting of isConstantSplat(); NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301366 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
185d3194ea
commit
2b2adc9567
@ -7629,52 +7629,48 @@ Type *ConstantPoolSDNode::getType() const {
|
|||||||
return Val.ConstVal->getType();
|
return Val.ConstVal->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildVectorSDNode::isConstantSplat(APInt &SplatValue,
|
bool BuildVectorSDNode::isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
|
||||||
APInt &SplatUndef,
|
|
||||||
unsigned &SplatBitSize,
|
unsigned &SplatBitSize,
|
||||||
bool &HasAnyUndefs,
|
bool &HasAnyUndefs,
|
||||||
unsigned MinSplatBits,
|
unsigned MinSplatBits,
|
||||||
bool isBigEndian) const {
|
bool IsBigEndian) const {
|
||||||
EVT VT = getValueType(0);
|
EVT VT = getValueType(0);
|
||||||
assert(VT.isVector() && "Expected a vector type");
|
assert(VT.isVector() && "Expected a vector type");
|
||||||
unsigned sz = VT.getSizeInBits();
|
unsigned VecWidth = VT.getSizeInBits();
|
||||||
if (MinSplatBits > sz)
|
if (MinSplatBits > VecWidth)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SplatValue = APInt(sz, 0);
|
SplatValue = APInt(VecWidth, 0);
|
||||||
SplatUndef = APInt(sz, 0);
|
SplatUndef = APInt(VecWidth, 0);
|
||||||
|
|
||||||
// Get the bits. Bits with undefined values (when the corresponding element
|
// Get the bits. Bits with undefined values (when the corresponding element
|
||||||
// of the vector is an ISD::UNDEF value) are set in SplatUndef and cleared
|
// of the vector is an ISD::UNDEF value) are set in SplatUndef and cleared
|
||||||
// in SplatValue. If any of the values are not constant, give up and return
|
// in SplatValue. If any of the values are not constant, give up and return
|
||||||
// false.
|
// false.
|
||||||
unsigned int nOps = getNumOperands();
|
unsigned int NumOps = getNumOperands();
|
||||||
assert(nOps > 0 && "isConstantSplat has 0-size build vector");
|
assert(NumOps > 0 && "isConstantSplat has 0-size build vector");
|
||||||
unsigned EltBitSize = VT.getScalarSizeInBits();
|
unsigned EltWidth = VT.getScalarSizeInBits();
|
||||||
|
|
||||||
for (unsigned j = 0; j < nOps; ++j) {
|
for (unsigned j = 0; j < NumOps; ++j) {
|
||||||
unsigned i = isBigEndian ? nOps-1-j : j;
|
unsigned i = IsBigEndian ? NumOps - 1 - j : j;
|
||||||
SDValue OpVal = getOperand(i);
|
SDValue OpVal = getOperand(i);
|
||||||
unsigned BitPos = j * EltBitSize;
|
unsigned BitPos = j * EltWidth;
|
||||||
|
|
||||||
if (OpVal.isUndef())
|
if (OpVal.isUndef())
|
||||||
SplatUndef.setBits(BitPos, BitPos + EltBitSize);
|
SplatUndef.setBits(BitPos, BitPos + EltWidth);
|
||||||
else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(OpVal))
|
else if (auto *CN = dyn_cast<ConstantSDNode>(OpVal))
|
||||||
SplatValue.insertBits(CN->getAPIntValue().zextOrTrunc(EltBitSize),
|
SplatValue.insertBits(CN->getAPIntValue().zextOrTrunc(EltWidth), BitPos);
|
||||||
BitPos);
|
else if (auto *CN = dyn_cast<ConstantFPSDNode>(OpVal))
|
||||||
else if (ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(OpVal))
|
|
||||||
SplatValue.insertBits(CN->getValueAPF().bitcastToAPInt(), BitPos);
|
SplatValue.insertBits(CN->getValueAPF().bitcastToAPInt(), BitPos);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The build_vector is all constants or undefs. Find the smallest element
|
// The build_vector is all constants or undefs. Find the smallest element
|
||||||
// size that splats the vector.
|
// size that splats the vector.
|
||||||
|
|
||||||
HasAnyUndefs = (SplatUndef != 0);
|
HasAnyUndefs = (SplatUndef != 0);
|
||||||
while (sz > 8) {
|
while (VecWidth > 8) {
|
||||||
|
unsigned HalfSize = VecWidth / 2;
|
||||||
unsigned HalfSize = sz / 2;
|
|
||||||
APInt HighValue = SplatValue.lshr(HalfSize).trunc(HalfSize);
|
APInt HighValue = SplatValue.lshr(HalfSize).trunc(HalfSize);
|
||||||
APInt LowValue = SplatValue.trunc(HalfSize);
|
APInt LowValue = SplatValue.trunc(HalfSize);
|
||||||
APInt HighUndef = SplatUndef.lshr(HalfSize).trunc(HalfSize);
|
APInt HighUndef = SplatUndef.lshr(HalfSize).trunc(HalfSize);
|
||||||
@ -7688,10 +7684,10 @@ bool BuildVectorSDNode::isConstantSplat(APInt &SplatValue,
|
|||||||
SplatValue = HighValue | LowValue;
|
SplatValue = HighValue | LowValue;
|
||||||
SplatUndef = HighUndef & LowUndef;
|
SplatUndef = HighUndef & LowUndef;
|
||||||
|
|
||||||
sz = HalfSize;
|
VecWidth = HalfSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SplatBitSize = sz;
|
SplatBitSize = VecWidth;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user