Skip to content

Commit

Permalink
Lower ConstantAggregateZero into zeros
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24890 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Dec 21, 2005
1 parent 8263c5e commit 3b841e9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,29 @@ class SelectionDAGLowering {
// Constant or ConstantFP node onto the ops list for each element of
// the packed constant.
std::vector<SDOperand> Ops;
for (unsigned i = 0; i < NumElements; ++i) {
const Constant *CEl = C->getOperand(i);
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) {
if (MVT::isFloatingPoint(PVT)) {
for (unsigned i = 0; i != NumElements; ++i) {
const ConstantFP *El = cast<ConstantFP>(CP->getOperand(i));
Ops.push_back(DAG.getConstantFP(El->getValue(), PVT));
}
} else {
for (unsigned i = 0; i != NumElements; ++i) {
const ConstantIntegral *El =
cast<ConstantIntegral>(CP->getOperand(i));
Ops.push_back(DAG.getConstant(El->getRawValue(), PVT));
}
}
} else {
assert(isa<ConstantAggregateZero>(C) && "Unknown packed constant!");
SDOperand Op;
if (MVT::isFloatingPoint(PVT))
Ops.push_back(DAG.getConstantFP(cast<ConstantFP>(CEl)->getValue(),
PVT));
Op = DAG.getConstantFP(0, PVT);
else
Ops.push_back(
DAG.getConstant(cast<ConstantIntegral>(CEl)->getRawValue(),
PVT));
Op = DAG.getConstant(0, PVT);
Ops.assign(NumElements, Op);
}

// Handle the case where we have a 1-element vector, in which
// case we want to immediately turn it into a scalar constant.
if (Ops.size() == 1) {
Expand Down

0 comments on commit 3b841e9

Please sign in to comment.