diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-11-30 08:22:07 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-11-30 08:22:07 +0000 |
commit | f43a3ca26d7bf431be5cdfb5963350a158e840af (patch) | |
tree | 7bacbc487489a6dde94a6ab88ce1503037c19609 /lib/CodeGen | |
parent | 7f0db91f86cfbd7c7268f945385d7a3056150bc7 (diff) | |
download | external_llvm-f43a3ca26d7bf431be5cdfb5963350a158e840af.zip external_llvm-f43a3ca26d7bf431be5cdfb5963350a158e840af.tar.gz external_llvm-f43a3ca26d7bf431be5cdfb5963350a158e840af.tar.bz2 |
First chunk of actually generating vector code for packed types. These
changes allow us to generate the following code:
_foo:
li r2, 0
lvx v0, r2, r3
vaddfp v0, v0, v0
stvx v0, r2, r3
blr
for this llvm:
void %foo(<4 x float>* %a) {
entry:
%tmp1 = load <4 x float>* %a
%tmp2 = add <4 x float> %tmp1, %tmp1
store <4 x float> %tmp2, <4 x float>* %a
ret void
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index aad1708..30d9433 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -520,12 +520,19 @@ void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp, const PackedType *PTy = cast<PackedType>(Ty); unsigned NumElements = PTy->getNumElements(); MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements); // Immediately scalarize packed types containing only one element, so that - // the Legalize pass does not have to deal with them. + // the Legalize pass does not have to deal with them. Similarly, if the + // abstract vector is going to turn into one that the target natively + // supports, generate that type now so that Legalize doesn't have to deal + // with that either. These steps ensure that Legalize only has to handle + // vector types in its Expand case. + unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp; if (NumElements == 1) { - unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp; setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2)); + } else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) { + setValue(&I, DAG.getNode(Opc, TVT, Op1, Op2)); } else { SDOperand Num = DAG.getConstant(NumElements, MVT::i32); SDOperand Typ = DAG.getValueType(PVT); @@ -777,11 +784,14 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) { const PackedType *PTy = cast<PackedType>(Ty); unsigned NumElements = PTy->getNumElements(); MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements); // Immediately scalarize packed types containing only one element, so that // the Legalize pass does not have to deal with them. if (NumElements == 1) { L = DAG.getLoad(PVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0))); + } else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) { + L = DAG.getLoad(TVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0))); } else { L = DAG.getVecLoad(NumElements, PVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0))); |