[llvm-commits] [llvm] r148297 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Craig Topper
craig.topper at gmail.com
Tue Jan 17 01:09:48 PST 2012
Author: ctopper
Date: Tue Jan 17 03:09:48 2012
New Revision: 148297
URL: http://llvm.org/viewvc/llvm-project?rev=148297&view=rev
Log:
Teach DAG combiner to turn a BUILD_VECTOR of UNDEFs into an UNDEF of vector type.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=148297&r1=148296&r2=148297&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jan 17 03:09:48 2012
@@ -7142,11 +7142,13 @@
// 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 @@
}
// 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 @@
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();
More information about the llvm-commits
mailing list