From 687531fbed080b86c31144bf66c29f4a30e10e84 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 4 Jul 2024 17:07:39 +0100 Subject: [PATCH] [DAG] PromoteIntRes_EXTRACT_SUBVECTOR - pull out repeated getOperand/getVectorElementType calls. NFC. --- .../CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index a058b509b3aca7..38f8f072dccfd6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -5724,21 +5724,20 @@ SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N) { SDValue InOp0 = N->getOperand(0); if (getTypeAction(InOp0.getValueType()) == TargetLowering::TypePromoteInteger) - InOp0 = GetPromotedInteger(N->getOperand(0)); + InOp0 = GetPromotedInteger(InOp0); EVT InVT = InOp0.getValueType(); + EVT InSVT = InVT.getVectorElementType(); unsigned OutNumElems = OutVT.getVectorNumElements(); SmallVector Ops; Ops.reserve(OutNumElems); for (unsigned i = 0; i != OutNumElems; ++i) { - // Extract the element from the original vector. - SDValue Index = DAG.getNode(ISD::ADD, dl, BaseIdx.getValueType(), - BaseIdx, DAG.getConstant(i, dl, BaseIdx.getValueType())); - SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, - InVT.getVectorElementType(), N->getOperand(0), Index); - + SDValue Index = DAG.getNode(ISD::ADD, dl, BaseIdx.getValueType(), BaseIdx, + DAG.getConstant(i, dl, BaseIdx.getValueType())); + SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InSVT, + N->getOperand(0), Index); SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem); // Insert the converted element to the new vector. Ops.push_back(Op);