From 787e078f3ec89bce82a789d2ee01beecc98db4d7 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 30 Dec 2019 19:07:36 -0800 Subject: [TargetLowering][AMDGPU] Make scalarizeVectorLoad return a pair of SDValues instead of creating a MERGE_VALUES node. NFCI This allows us to clean up some places that were peeking through the MERGE_VALUES node after the call. By returning the SDValues directly, we can clean that up. Unfortunately, there are several call sites in AMDGPU that wanted the MERGE_VALUES and now need to create their own. --- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp | 10 +--------- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp index d9f95df57be..dcfa1e78d86 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -752,15 +752,7 @@ SDValue VectorLegalizer::ExpandLoad(SDValue Op) { NewChain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, LoadChains); Value = DAG.getBuildVector(Op.getNode()->getValueType(0), dl, Vals); } else { - SDValue Scalarized = TLI.scalarizeVectorLoad(LD, DAG); - // Skip past MERGE_VALUE node if known. - if (Scalarized->getOpcode() == ISD::MERGE_VALUES) { - NewChain = Scalarized.getOperand(1); - Value = Scalarized.getOperand(0); - } else { - NewChain = Scalarized.getValue(1); - Value = Scalarized.getValue(0); - } + std::tie(Value, NewChain) = TLI.scalarizeVectorLoad(LD, DAG); } AddLegalizedOperand(Op.getValue(0), Value); diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index ee2e40b3c59..0bfd1b62db2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -6497,8 +6497,9 @@ bool TargetLowering::expandABS(SDNode *N, SDValue &Result, return true; } -SDValue TargetLowering::scalarizeVectorLoad(LoadSDNode *LD, - SelectionDAG &DAG) const { +std::pair +TargetLowering::scalarizeVectorLoad(LoadSDNode *LD, + SelectionDAG &DAG) const { SDLoc SL(LD); SDValue Chain = LD->getChain(); SDValue BasePTR = LD->getBasePtr(); @@ -6532,7 +6533,7 @@ SDValue TargetLowering::scalarizeVectorLoad(LoadSDNode *LD, SDValue NewChain = DAG.getNode(ISD::TokenFactor, SL, MVT::Other, LoadChains); SDValue Value = DAG.getBuildVector(LD->getValueType(0), SL, Vals); - return DAG.getMergeValues({Value, NewChain}, SL); + return std::make_pair(Value, NewChain); } SDValue TargetLowering::scalarizeVectorStore(StoreSDNode *ST, @@ -6626,10 +6627,7 @@ TargetLowering::expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const { if (!isOperationLegalOrCustom(ISD::LOAD, intVT) && LoadedVT.isVector()) { // Scalarize the load and let the individual components be handled. - SDValue Scalarized = scalarizeVectorLoad(LD, DAG); - if (Scalarized->getOpcode() == ISD::MERGE_VALUES) - return std::make_pair(Scalarized.getOperand(0), Scalarized.getOperand(1)); - return std::make_pair(Scalarized.getValue(0), Scalarized.getValue(1)); + return scalarizeVectorLoad(LD, DAG); } // Expand to a (misaligned) integer load of the same size, -- cgit v1.2.3