[llvm-branch-commits] [llvm-tag] r91625 - /llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
Bill Wendling
isanbard at gmail.com
Thu Dec 17 13:34:57 PST 2009
Author: void
Date: Thu Dec 17 15:34:57 2009
New Revision: 91625
URL: http://llvm.org/viewvc/llvm-project?rev=91625&view=rev
Log:
Patch for <rdar://problem/7098635>.
Modified:
llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
Modified: llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=91625&r1=91624&r2=91625&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original)
+++ llvm/tags/Apple/llvmCore-2120/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Thu Dec 17 15:34:57 2009
@@ -1419,8 +1419,9 @@
SmallVector<SDValue, 16> NewOps(N->op_begin(), N->op_end());
NewOps.reserve(WidenNumElts);
+ SDValue LastElt = NewOps[NumElts - 1];
for (unsigned i = NumElts; i < WidenNumElts; ++i)
- NewOps.push_back(DAG.getUNDEF(EltVT));
+ NewOps.push_back(LastElt);
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &NewOps[0], NewOps.size());
}
@@ -1674,10 +1675,11 @@
LdChain.push_back(Ops[i].getValue(1));
}
- // Fill the rest with undefs
- SDValue UndefVal = DAG.getUNDEF(EltVT);
+ // Fill the rest with the last element instead of undefs in case the
+ // widen operation can trap.
+ unsigned last_i = i - 1;
for (; i != WidenNumElts; ++i)
- Ops[i] = UndefVal;
+ Ops[i] = Ops[last_i];
Result = DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], Ops.size());
} else {
@@ -1685,6 +1687,18 @@
unsigned int LdWidth = LdVT.getSizeInBits();
Result = GenWidenVectorLoads(LdChain, Chain, BasePtr, SV, SVOffset,
Align, isVolatile, LdWidth, WidenVT, dl);
+ // Splat the last element instead of leaving the values undefined in case
+ // the widen operation can trap.
+ unsigned WidenNumElts = WidenVT.getVectorNumElements();
+ unsigned NumElts = LdVT.getVectorNumElements();
+ SmallVector<int, 16> Mask;
+ unsigned i = 0;
+ for (i = 0; i < NumElts; ++i)
+ Mask.push_back(i);
+ for (; i < WidenNumElts; ++i)
+ Mask.push_back(NumElts - 1);
+ Result = DAG.getVectorShuffle(WidenVT, dl, Result, DAG.getUNDEF(WidenVT),
+ &Mask[0]);
}
// If we generate a single load, we can use that for the chain. Otherwise,
More information about the llvm-branch-commits
mailing list