From: Craig Topper Date: Tue, 9 Jul 2019 23:05:54 +0000 (+0000) Subject: [X86] Don't form extloads in combineExtInVec unless the load extension is legal. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=269b4e691da7e7579ffda4b91b90b6c96c2ab91f;p=llvm [X86] Don't form extloads in combineExtInVec unless the load extension is legal. This should prevent doing this on pre-sse4.1 targets or for 256 bit vectors without avx2. I don't know of a failure from this. Op legalization will probably take care of, but seemed better to be safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365577 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 3cab44b0ac1..40e3070ae94 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -43996,6 +43996,7 @@ static SDValue combineExtInVec(SDNode *N, SelectionDAG &DAG, const X86Subtarget &Subtarget) { EVT VT = N->getValueType(0); SDValue In = N->getOperand(0); + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Try to merge vector loads and extend_inreg to an extload. if (!DCI.isBeforeLegalizeOps() && ISD::isNormalLoad(In.getNode()) && @@ -44006,12 +44007,14 @@ static SDValue combineExtInVec(SDNode *N, SelectionDAG &DAG, ISD::LoadExtType Ext = N->getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG ? ISD::SEXTLOAD : ISD::ZEXTLOAD; EVT MemVT = EVT::getVectorVT(*DAG.getContext(), SVT, VT.getVectorNumElements()); - SDValue Load = - DAG.getExtLoad(Ext, SDLoc(N), VT, Ld->getChain(), Ld->getBasePtr(), - Ld->getPointerInfo(), MemVT, Ld->getAlignment(), - Ld->getMemOperand()->getFlags()); - DAG.ReplaceAllUsesOfValueWith(SDValue(Ld, 1), Load.getValue(1)); - return Load; + if (TLI.isLoadExtLegal(Ext, VT, MemVT)) { + SDValue Load = + DAG.getExtLoad(Ext, SDLoc(N), VT, Ld->getChain(), Ld->getBasePtr(), + Ld->getPointerInfo(), MemVT, Ld->getAlignment(), + Ld->getMemOperand()->getFlags()); + DAG.ReplaceAllUsesOfValueWith(SDValue(Ld, 1), Load.getValue(1)); + return Load; + } } } @@ -44022,7 +44025,6 @@ static SDValue combineExtInVec(SDNode *N, SelectionDAG &DAG, return SDValue(); // Combine (ext_invec (ext_invec X)) -> (ext_invec X) - const TargetLowering &TLI = DAG.getTargetLoweringInfo(); if (In.getOpcode() == N->getOpcode() && TLI.isTypeLegal(VT) && TLI.isTypeLegal(In.getOperand(0).getValueType())) return DAG.getNode(N->getOpcode(), SDLoc(N), VT, In.getOperand(0));