diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -848,22 +848,28 @@ /// Create a logical NOT operation as (XOR Val, BooleanOne). SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT); + /// Returns sum of the base pointer and offset. + /// Unlike getObjectPtrOffset this does not set NoUnsignedWrap by default. + SDValue getMemBasePlusOffset(SDValue Base, int64_t Offset, const SDLoc &DL, + const SDNodeFlags Flags = SDNodeFlags()); + SDValue getMemBasePlusOffset(SDValue Base, SDValue Offset, const SDLoc &DL, + const SDNodeFlags Flags = SDNodeFlags()); + /// Create an add instruction with appropriate flags when used for /// addressing some offset of an object. i.e. if a load is split into multiple /// components, create an add nuw from the base pointer to the offset. - SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset) { - EVT VT = Op.getValueType(); - return getObjectPtrOffset(SL, Op, getConstant(Offset, SL, VT)); + SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, int64_t Offset) { + SDNodeFlags Flags; + Flags.setNoUnsignedWrap(true); + return getMemBasePlusOffset(Ptr, Offset, SL, Flags); } - SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, SDValue Offset) { - EVT VT = Op.getValueType(); - + SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, SDValue Offset) { // The object itself can't wrap around the address space, so it shouldn't be // possible for the adds of the offsets to the split parts to overflow. SDNodeFlags Flags; Flags.setNoUnsignedWrap(true); - return getNode(ISD::ADD, SL, VT, Op, Offset, Flags); + return getMemBasePlusOffset(Ptr, Offset, SL, Flags); } /// Return a new CALLSEQ_START node, that starts new call frame, in which @@ -1137,11 +1143,6 @@ SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM); - /// Returns sum of the base pointer and offset. - /// Unlike getObjectPtrOffset this does not set NoUnsignedWrap by default. - SDValue getMemBasePlusOffset(SDValue Base, int64_t Offset, const SDLoc &DL); - SDValue getMemBasePlusOffset(SDValue Base, SDValue Offset, const SDLoc &DL); - SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base, SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -5733,16 +5733,18 @@ } SDValue SelectionDAG::getMemBasePlusOffset(SDValue Base, int64_t Offset, - const SDLoc &DL) { + const SDLoc &DL, + const SDNodeFlags Flags) { EVT VT = Base.getValueType(); - return getMemBasePlusOffset(Base, getConstant(Offset, DL, VT), DL); + return getMemBasePlusOffset(Base, getConstant(Offset, DL, VT), DL, Flags); } SDValue SelectionDAG::getMemBasePlusOffset(SDValue Ptr, SDValue Offset, - const SDLoc &DL) { + const SDLoc &DL, + const SDNodeFlags Flags) { assert(Offset.getValueType().isInteger()); EVT BasePtrVT = Ptr.getValueType(); - return getNode(ISD::ADD, DL, BasePtrVT, Ptr, Offset); + return getNode(ISD::ADD, DL, BasePtrVT, Ptr, Offset, Flags); } /// Returns true if memcpy source is constant data.