From 07890bbec4a8949be67e487bab91dda3e9e712e6 Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Tue, 22 Nov 2005 01:29:36 +0000 Subject: Rather than attempting to legalize 1 x float, make sure the SD ISel never generates it. Make MVT::Vector expand-only, and remove the code in Legalize that attempts to legalize it. The plan for supporting N x Type is to continually epxand it in ExpandOp until it gets down to 2 x Type, where it will be scalarized into a pair of scalars. llvm-svn: 24482 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index c025c2d4780..079b16b1f82 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -517,9 +517,19 @@ void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp, setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); } else { const PackedType *PTy = cast(Ty); - SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32); - SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType())); - setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2)); + unsigned NumElements = PTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + + // Immediately scalarize packed types containing only one element, so that + // the Legalize pass does not have to deal with them. + if (NumElements == 1) { + unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp; + setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2)); + } else { + SDOperand Num = DAG.getConstant(NumElements, MVT::i32); + SDOperand Typ = DAG.getValueType(PVT); + setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2)); + } } } @@ -726,9 +736,17 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) { if (Type::PackedTyID == Ty->getTypeID()) { const PackedType *PTy = cast(Ty); - L = DAG.getVecLoad(PTy->getNumElements(), - TLI.getValueType(PTy->getElementType()), Root, Ptr, - DAG.getSrcValue(I.getOperand(0))); + unsigned NumElements = PTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + + // 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 { + L = DAG.getVecLoad(NumElements, PVT, Root, Ptr, + DAG.getSrcValue(I.getOperand(0))); + } } else { L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, DAG.getSrcValue(I.getOperand(0))); -- cgit v1.2.3