mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-19 06:31:18 +00:00
Teach DAG combiner to turn a BUILD_VECTOR of UNDEFs into an UNDEF of vector type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b5a6b63dd
commit
d3b588965d
@ -7142,11 +7142,13 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) {
|
|||||||
// optimizations. We do not handle sign-extend because we can't fill the sign
|
// optimizations. We do not handle sign-extend because we can't fill the sign
|
||||||
// using shuffles.
|
// using shuffles.
|
||||||
EVT SourceType = MVT::Other;
|
EVT SourceType = MVT::Other;
|
||||||
bool allAnyExt = true;
|
bool AllAnyExt = true;
|
||||||
for (unsigned i = 0; i < NumInScalars; ++i) {
|
bool AllUndef = true;
|
||||||
|
for (unsigned i = 0; i != NumInScalars; ++i) {
|
||||||
SDValue In = N->getOperand(i);
|
SDValue In = N->getOperand(i);
|
||||||
// Ignore undef inputs.
|
// Ignore undef inputs.
|
||||||
if (In.getOpcode() == ISD::UNDEF) continue;
|
if (In.getOpcode() == ISD::UNDEF) continue;
|
||||||
|
AllUndef = false;
|
||||||
|
|
||||||
bool AnyExt = In.getOpcode() == ISD::ANY_EXTEND;
|
bool AnyExt = In.getOpcode() == ISD::ANY_EXTEND;
|
||||||
bool ZeroExt = In.getOpcode() == ISD::ZERO_EXTEND;
|
bool ZeroExt = In.getOpcode() == ISD::ZERO_EXTEND;
|
||||||
@ -7171,9 +7173,11 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if all of the extends are ANY_EXTENDs.
|
// Check if all of the extends are ANY_EXTENDs.
|
||||||
allAnyExt &= AnyExt;
|
AllAnyExt &= AnyExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AllUndef)
|
||||||
|
return DAG.getUNDEF(VT);
|
||||||
|
|
||||||
// In order to have valid types, all of the inputs must be extended from the
|
// In order to have valid types, all of the inputs must be extended from the
|
||||||
// same source type and all of the inputs must be any or zero extend.
|
// same source type and all of the inputs must be any or zero extend.
|
||||||
@ -7193,7 +7197,7 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) {
|
|||||||
bool isLE = TLI.isLittleEndian();
|
bool isLE = TLI.isLittleEndian();
|
||||||
unsigned ElemRatio = OutScalarTy.getSizeInBits()/SourceType.getSizeInBits();
|
unsigned ElemRatio = OutScalarTy.getSizeInBits()/SourceType.getSizeInBits();
|
||||||
assert(ElemRatio > 1 && "Invalid element size ratio");
|
assert(ElemRatio > 1 && "Invalid element size ratio");
|
||||||
SDValue Filler = allAnyExt ? DAG.getUNDEF(SourceType):
|
SDValue Filler = AllAnyExt ? DAG.getUNDEF(SourceType):
|
||||||
DAG.getConstant(0, SourceType);
|
DAG.getConstant(0, SourceType);
|
||||||
|
|
||||||
unsigned NewBVElems = ElemRatio * N->getValueType(0).getVectorNumElements();
|
unsigned NewBVElems = ElemRatio * N->getValueType(0).getVectorNumElements();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user