diff options
author | Craig Topper <craig.topper@gmail.com> | 2012-01-17 09:09:48 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2012-01-17 09:09:48 +0000 |
commit | 02cb0fb136ff4edb023a2e9da4599cc52088c7a0 (patch) | |
tree | f65ddd172ccbad130d6c76774963698935f7aa1a /llvm | |
parent | 60deeee7836843497a92e856fbf90bff8df9980b (diff) | |
download | bcm5719-llvm-02cb0fb136ff4edb023a2e9da4599cc52088c7a0.tar.gz bcm5719-llvm-02cb0fb136ff4edb023a2e9da4599cc52088c7a0.zip |
Teach DAG combiner to turn a BUILD_VECTOR of UNDEFs into an UNDEF of vector type.
llvm-svn: 148297
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b9099277cf8..769fc726249 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7142,11 +7142,13 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) { // optimizations. We do not handle sign-extend because we can't fill the sign // using shuffles. EVT SourceType = MVT::Other; - bool allAnyExt = true; - for (unsigned i = 0; i < NumInScalars; ++i) { + bool AllAnyExt = true; + bool AllUndef = true; + for (unsigned i = 0; i != NumInScalars; ++i) { SDValue In = N->getOperand(i); // Ignore undef inputs. if (In.getOpcode() == ISD::UNDEF) continue; + AllUndef = false; bool AnyExt = In.getOpcode() == ISD::ANY_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. - 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 // 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(); unsigned ElemRatio = OutScalarTy.getSizeInBits()/SourceType.getSizeInBits(); assert(ElemRatio > 1 && "Invalid element size ratio"); - SDValue Filler = allAnyExt ? DAG.getUNDEF(SourceType): + SDValue Filler = AllAnyExt ? DAG.getUNDEF(SourceType): DAG.getConstant(0, SourceType); unsigned NewBVElems = ElemRatio * N->getValueType(0).getVectorNumElements(); |