diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index 76a903278960..13e11fa361e4 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -221,9 +221,9 @@ namespace { bool selectAddr(SDNode *Parent, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, SDValue &Segment); - bool selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base, - SDValue &Scale, SDValue &Index, SDValue &Disp, - SDValue &Segment); + bool selectVectorAddr(MemSDNode *Parent, SDValue BasePtr, SDValue IndexOp, + SDValue ScaleOp, SDValue &Base, SDValue &Scale, + SDValue &Index, SDValue &Disp, SDValue &Segment); bool selectMOV64Imm32(SDValue N, SDValue &Imm); bool selectLEAAddr(SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, @@ -2319,15 +2319,16 @@ bool X86DAGToDAGISel::matchVectorAddress(SDValue N, X86ISelAddressMode &AM) { return matchAddressBase(N, AM); } -bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base, - SDValue &Scale, SDValue &Index, - SDValue &Disp, SDValue &Segment) { +bool X86DAGToDAGISel::selectVectorAddr(MemSDNode *Parent, SDValue BasePtr, + SDValue IndexOp, SDValue ScaleOp, + SDValue &Base, SDValue &Scale, + SDValue &Index, SDValue &Disp, + SDValue &Segment) { X86ISelAddressMode AM; - auto *Mgs = cast(Parent); - AM.IndexReg = Mgs->getIndex(); - AM.Scale = cast(Mgs->getScale())->getZExtValue(); + AM.IndexReg = IndexOp; + AM.Scale = cast(ScaleOp)->getZExtValue(); - unsigned AddrSpace = cast(Parent)->getPointerInfo().getAddrSpace(); + unsigned AddrSpace = Parent->getPointerInfo().getAddrSpace(); if (AddrSpace == X86AS::GS) AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16); if (AddrSpace == X86AS::FS) @@ -2335,11 +2336,11 @@ bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base, if (AddrSpace == X86AS::SS) AM.Segment = CurDAG->getRegister(X86::SS, MVT::i16); - SDLoc DL(N); - MVT VT = N.getSimpleValueType(); + SDLoc DL(BasePtr); + MVT VT = BasePtr.getSimpleValueType(); // Try to match into the base and displacement fields. - if (matchVectorAddress(N, AM)) + if (matchVectorAddress(BasePtr, AM)) return false; getAddressOperands(AM, DL, VT, Base, Scale, Index, Disp, Segment); @@ -5467,9 +5468,9 @@ void X86DAGToDAGISel::Select(SDNode *Node) { if (!Opc) break; - SDValue BasePtr = Mgt->getBasePtr(); SDValue Base, Scale, Index, Disp, Segment; - if (!selectVectorAddr(Node, BasePtr, Base, Scale, Index, Disp, Segment)) + if (!selectVectorAddr(Mgt, Mgt->getBasePtr(), IndexOp, Mgt->getScale(), + Base, Scale, Index, Disp, Segment)) break; SDValue PassThru = Mgt->getPassThru(); @@ -5540,9 +5541,9 @@ void X86DAGToDAGISel::Select(SDNode *Node) { else break; - SDValue BasePtr = Sc->getBasePtr(); SDValue Base, Scale, Index, Disp, Segment; - if (!selectVectorAddr(Node, BasePtr, Base, Scale, Index, Disp, Segment)) + if (!selectVectorAddr(Sc, Sc->getBasePtr(), IndexOp, Sc->getScale(), + Base, Scale, Index, Disp, Segment)) break; SDValue Mask = Sc->getMask();