LLVM 22.0.0git
SelectionDAG.cpp File Reference
#include "llvm/CodeGen/SelectionDAG.h"
#include "SDNodeDbgValue.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/RuntimeLibcallUtil.h"
#include "llvm/CodeGen/SDPatternMatch.h"
#include "llvm/CodeGen/SelectionDAGAddressAnalysis.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "llvm/IR/VPIntrinsics.def"
#include "llvm/IR/ConstrainedOps.def"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "selectiondag"
#define BEGIN_REGISTER_VP_SDNODE(VPSD, ...)
#define BEGIN_REGISTER_VP_SDNODE(VPSD, ...)
#define VP_PROPERTY_BINARYOP   return true;
#define END_REGISTER_VP_SDNODE(VPSD)
#define BEGIN_REGISTER_VP_SDNODE(VPSD, LEGALPOS, TDNAME, MASKPOS, ...)
#define BEGIN_REGISTER_VP_SDNODE(VPSD, LEGALPOS, TDNAME, MASKPOS, EVLPOS)
#define BEGIN_REGISTER_VP_SDNODE(VPOPC, ...)
#define VP_PROPERTY_FUNCTIONAL_SDOPC(SDOPC)
#define END_REGISTER_VP_SDNODE(VPOPC)
#define BEGIN_REGISTER_VP_SDNODE(VPOPC, ...)
#define VP_PROPERTY_FUNCTIONAL_SDOPC(SDOPC)
#define END_REGISTER_VP_SDNODE(VPOPC)
#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)
#define CMP_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)

Functions

static SDVTList makeVTList (const EVT *VTs, unsigned NumVTs)
 makeVTList - Return an instance of the SDVTList struct initialized with the specified members.
static void NewSDValueDbgMsg (SDValue V, StringRef Msg, SelectionDAG *G)
static ISD::CondCode getSetCCInverseImpl (ISD::CondCode Op, bool isIntegerLike)
static int isSignedOp (ISD::CondCode Opcode)
 For an integer comparison, return 1 if the comparison is a signed operation and 2 if the result is an unsigned comparison.
static void AddNodeIDOpcode (FoldingSetNodeID &ID, unsigned OpC)
 AddNodeIDOpcode - Add the node opcode to the NodeID data.
static void AddNodeIDValueTypes (FoldingSetNodeID &ID, SDVTList VTList)
 AddNodeIDValueTypes - Value type lists are intern'd so we can represent them solely with their pointer.
static void AddNodeIDOperands (FoldingSetNodeID &ID, ArrayRef< SDValue > Ops)
 AddNodeIDOperands - Various routines for adding operands to the NodeID data.
static void AddNodeIDOperands (FoldingSetNodeID &ID, ArrayRef< SDUse > Ops)
 AddNodeIDOperands - Various routines for adding operands to the NodeID data.
static void AddNodeIDNode (FoldingSetNodeID &ID, unsigned OpC, SDVTList VTList, ArrayRef< SDValue > OpList)
static void AddNodeIDCustom (FoldingSetNodeID &ID, const SDNode *N)
 If this is an SDNode with special info, add this info to the NodeID data.
static void AddNodeIDNode (FoldingSetNodeID &ID, const SDNode *N)
 AddNodeIDNode - Generic routine for adding a nodes info to the NodeID data.
static bool doNotCSE (SDNode *N)
 doNotCSE - Return true if CSE should not be performed for this node.
static void commuteShuffle (SDValue &N1, SDValue &N2, MutableArrayRef< int > M)
 Swaps the values of N1 and N2.
static bool canFoldStoreIntoLibCallOutputPointers (StoreSDNode *StoreNode, SDNode *FPNode)
 Given a store node StoreNode, return true if it is safe to fold that node into FPNode, which expands to a library call with output pointers.
static SelectionDAG::OverflowKind mapOverflowResult (ConstantRange::OverflowResult OR)
 Convert ConstantRange OverflowResult into SelectionDAG::OverflowKind.
static bool haveNoCommonBitsSetCommutative (SDValue A, SDValue B)
static SDValue FoldSTEP_VECTOR (const SDLoc &DL, EVT VT, SDValue Step, SelectionDAG &DAG)
static SDValue FoldBUILD_VECTOR (const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
static SDValue foldCONCAT_VECTORS (const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
 Try to simplify vector concatenation to an input value, undef, or build vector.
static std::optional< APIntFoldValue (unsigned Opcode, const APInt &C1, const APInt &C2)
static std::optional< APIntFoldValueWithUndef (unsigned Opcode, const APInt &C1, bool IsUndef1, const APInt &C2, bool IsUndef2)
static SDValue getMemsetValue (SDValue Value, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
 getMemsetValue - Vectorized representation of the memset value operand.
static SDValue getMemsetStringVal (EVT VT, const SDLoc &dl, SelectionDAG &DAG, const TargetLowering &TLI, const ConstantDataArraySlice &Slice)
 getMemsetStringVal - Similar to getMemsetValue.
static bool isMemSrcFromConstant (SDValue Src, ConstantDataArraySlice &Slice)
 Returns true if memcpy source is constant data.
static bool shouldLowerMemFuncForSize (const MachineFunction &MF, SelectionDAG &DAG)
static void chainLoadsAndStoresForMemcpy (SelectionDAG &DAG, const SDLoc &dl, SmallVector< SDValue, 32 > &OutChains, unsigned From, unsigned To, SmallVector< SDValue, 16 > &OutLoadChains, SmallVector< SDValue, 16 > &OutStoreChains)
static SDValue getMemcpyLoadsAndStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, Align Alignment, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo, BatchAAResults *BatchAA)
static SDValue getMemmoveLoadsAndStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, Align Alignment, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo)
static SDValue getMemsetStores (SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, Align Alignment, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, const AAMDNodes &AAInfo)
 Lower the call to 'memset' intrinsic function into a series of store operations.
static void checkAddrSpaceIsValidForLibcall (const TargetLowering *TLI, unsigned AS)
static bool isInTailCallPositionWrapper (const CallInst *CI, const SelectionDAG *SelDAG, bool AllowReturnsFirstArg)
static MachinePointerInfo InferPointerInfo (const MachinePointerInfo &Info, SelectionDAG &DAG, SDValue Ptr, int64_t Offset=0)
 InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.
static MachinePointerInfo InferPointerInfo (const MachinePointerInfo &Info, SelectionDAG &DAG, SDValue Ptr, SDValue OffsetOp)
 InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.
static bool gluePropagatesDivergence (const SDNode *Node)
 Return true if a glue output should propagate divergence information.
static void checkForCyclesHelper (const SDNode *N, SmallPtrSetImpl< const SDNode * > &Visited, SmallPtrSetImpl< const SDNode * > &Checked, const llvm::SelectionDAG *DAG)

Variables

static cl::opt< boolEnableMemCpyDAGOpt ("enable-memcpy-dag-opt", cl::Hidden, cl::init(true), cl::desc("Gang up loads and stores generated by inlining of memcpy"))
static cl::opt< int > MaxLdStGlue ("ldstmemcpy-glue-max", cl::desc("Number limit for gluing ld/st of memcpy."), cl::Hidden, cl::init(0))
static cl::opt< unsignedMaxSteps ("has-predecessor-max-steps", cl::Hidden, cl::init(8192), cl::desc("DAG combiner limit number of steps when searching DAG " "for predecessor nodes"))

Macro Definition Documentation

◆ BEGIN_REGISTER_VP_SDNODE [1/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPOPC,
... )
Value:
case ISD::VPOPC:

◆ BEGIN_REGISTER_VP_SDNODE [2/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPOPC,
... )
Value:
break;

◆ BEGIN_REGISTER_VP_SDNODE [3/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPSD,
LEGALPOS,
TDNAME,
MASKPOS,
EVLPOS )
Value:
case ISD::VPSD: \
return EVLPOS;

◆ BEGIN_REGISTER_VP_SDNODE [4/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPSD,
LEGALPOS,
TDNAME,
MASKPOS,
... )
Value:
case ISD::VPSD: \
return MASKPOS;

◆ BEGIN_REGISTER_VP_SDNODE [5/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPSD,
... )
Value:
case ISD::VPSD: \
return true;

◆ BEGIN_REGISTER_VP_SDNODE [6/6]

#define BEGIN_REGISTER_VP_SDNODE ( VPSD,
... )
Value:
case ISD::VPSD:

◆ CMP_INSTRUCTION

#define CMP_INSTRUCTION ( NAME,
NARG,
ROUND_MODE,
INTRINSIC,
DAGN )
Value:
case ISD::STRICT_##DAGN: NewOpc = ISD::SETCC; break;
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
Definition ISDOpcodes.h:801

◆ DAG_INSTRUCTION

#define DAG_INSTRUCTION ( NAME,
NARG,
ROUND_MODE,
INTRINSIC,
DAGN )
Value:
case ISD::STRICT_##DAGN: NewOpc = ISD::DAGN; break;

◆ DEBUG_TYPE

#define DEBUG_TYPE   "selectiondag"

Definition at line 102 of file SelectionDAG.cpp.

◆ END_REGISTER_VP_SDNODE [1/3]

#define END_REGISTER_VP_SDNODE ( VPOPC)
Value:
break;

◆ END_REGISTER_VP_SDNODE [2/3]

#define END_REGISTER_VP_SDNODE ( VPOPC)
Value:
return ISD::VPOPC;

◆ END_REGISTER_VP_SDNODE [3/3]

#define END_REGISTER_VP_SDNODE ( VPSD)
Value:
break;

◆ VP_PROPERTY_BINARYOP

#define VP_PROPERTY_BINARYOP   return true;

◆ VP_PROPERTY_FUNCTIONAL_SDOPC [1/2]

#define VP_PROPERTY_FUNCTIONAL_SDOPC ( SDOPC)
Value:
return ISD::SDOPC;

◆ VP_PROPERTY_FUNCTIONAL_SDOPC [2/2]

#define VP_PROPERTY_FUNCTIONAL_SDOPC ( SDOPC)
Value:
case ISD::SDOPC:

Function Documentation

◆ AddNodeIDCustom()

void AddNodeIDCustom ( FoldingSetNodeID & ID,
const SDNode * N )
static

If this is an SDNode with special info, add this info to the NodeID data.

Definition at line 743 of file SelectionDAG.cpp.

References llvm::ISD::AssertAlign, llvm::ISD::BasicBlock, llvm::ISD::BlockAddress, llvm::CallingConv::C, llvm::cast(), llvm::ISD::Constant, llvm::ISD::ConstantFP, llvm::ISD::ConstantPool, llvm::dyn_cast(), llvm::ISD::ExternalSymbol, llvm::ISD::FrameIndex, llvm::MachinePointerInfo::getAddrSpace(), llvm::getAlign(), llvm::SelectionDAG::getBasicBlock(), llvm::BlockAddressSDNode::getBlockAddress(), llvm::AddrSpaceCastSDNode::getDestAddressSpace(), llvm::MachineMemOperand::getFlags(), llvm::GlobalAddressSDNode::getGlobal(), llvm::TargetIndexSDNode::getIndex(), llvm::MemSDNode::getMemOperand(), llvm::MemSDNode::getMemoryVT(), llvm::BlockAddressSDNode::getOffset(), llvm::GlobalAddressSDNode::getOffset(), llvm::TargetIndexSDNode::getOffset(), llvm::MemSDNode::getPointerInfo(), llvm::EVT::getRawBits(), llvm::MemSDNode::getRawSubclassData(), getReg(), llvm::AddrSpaceCastSDNode::getSrcAddressSpace(), llvm::BlockAddressSDNode::getTargetFlags(), llvm::GlobalAddressSDNode::getTargetFlags(), llvm::TargetIndexSDNode::getTargetFlags(), llvm::ISD::GlobalAddress, llvm::ISD::GlobalTLSAddress, llvm::ISD::INTRINSIC_VOID, llvm::ISD::INTRINSIC_W_CHAIN, llvm::ISD::JumpTable, llvm_unreachable, llvm::ISD::MCSymbol, N, llvm::ISD::Register, llvm::ISD::RegisterMask, llvm::ISD::TargetBlockAddress, llvm::ISD::TargetConstant, llvm::ISD::TargetConstantFP, llvm::ISD::TargetConstantPool, llvm::ISD::TargetExternalSymbol, llvm::ISD::TargetFrameIndex, llvm::ISD::TargetGlobalAddress, llvm::ISD::TargetGlobalTLSAddress, llvm::ISD::TargetIndex, llvm::ISD::TargetJumpTable, and llvm::ISD::VECTOR_SHUFFLE.

Referenced by AddNodeIDNode().

◆ AddNodeIDNode() [1/2]

void AddNodeIDNode ( FoldingSetNodeID & ID,
const SDNode * N )
static

AddNodeIDNode - Generic routine for adding a nodes info to the NodeID data.

Definition at line 986 of file SelectionDAG.cpp.

References AddNodeIDCustom(), AddNodeIDOpcode(), AddNodeIDOperands(), AddNodeIDValueTypes(), and N.

◆ AddNodeIDNode() [2/2]

void AddNodeIDNode ( FoldingSetNodeID & ID,
unsigned OpC,
SDVTList VTList,
ArrayRef< SDValue > OpList )
static

Definition at line 735 of file SelectionDAG.cpp.

References AddNodeIDOpcode(), AddNodeIDOperands(), and AddNodeIDValueTypes().

Referenced by llvm::SelectionDAG::doesNodeExist(), llvm::SelectionDAG::getAddrSpaceCast(), llvm::SelectionDAG::getAssertAlign(), llvm::SelectionDAG::getAtomic(), llvm::SelectionDAG::getBasicBlock(), llvm::SelectionDAG::getBlockAddress(), llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getConstantFP(), llvm::SelectionDAG::getConstantPool(), llvm::SelectionDAG::getConstantPool(), llvm::SelectionDAG::getFrameIndex(), llvm::SelectionDAG::getGatherVP(), llvm::SelectionDAG::getGetFPEnv(), llvm::SelectionDAG::getGlobalAddress(), llvm::SelectionDAG::getIndexedStoreVP(), llvm::SelectionDAG::getJumpTable(), llvm::SelectionDAG::getLabelNode(), llvm::SelectionDAG::getLifetimeNode(), llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getLoadFFVP(), llvm::SelectionDAG::getLoadVP(), llvm::SelectionDAG::getMachineNode(), llvm::SelectionDAG::getMaskedGather(), llvm::SelectionDAG::getMaskedHistogram(), llvm::SelectionDAG::getMaskedLoad(), llvm::SelectionDAG::getMaskedScatter(), llvm::SelectionDAG::getMaskedStore(), llvm::SelectionDAG::getMDNode(), llvm::SelectionDAG::getMemIntrinsicNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNodeIfExists(), llvm::SelectionDAG::getPseudoProbeNode(), llvm::SelectionDAG::getRegister(), llvm::SelectionDAG::getRegisterMask(), llvm::SelectionDAG::getScatterVP(), llvm::SelectionDAG::getSetFPEnv(), llvm::SelectionDAG::getSrcValue(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getStoreVP(), llvm::SelectionDAG::getStridedLoadVP(), llvm::SelectionDAG::getStridedStoreVP(), llvm::SelectionDAG::getTruncStoreVP(), llvm::SelectionDAG::getTruncStridedStoreVP(), llvm::SelectionDAG::getVectorShuffle(), llvm::SelectionDAG::MorphNodeTo(), and llvm::SDNode::Profile().

◆ AddNodeIDOpcode()

void AddNodeIDOpcode ( FoldingSetNodeID & ID,
unsigned OpC )
static

AddNodeIDOpcode - Add the node opcode to the NodeID data.

Definition at line 707 of file SelectionDAG.cpp.

Referenced by AddNodeIDNode(), and AddNodeIDNode().

◆ AddNodeIDOperands() [1/2]

void AddNodeIDOperands ( FoldingSetNodeID & ID,
ArrayRef< SDUse > Ops )
static

AddNodeIDOperands - Various routines for adding operands to the NodeID data.

Definition at line 727 of file SelectionDAG.cpp.

References AbstractManglingParser< Derived, Alloc >::Ops.

◆ AddNodeIDOperands() [2/2]

void AddNodeIDOperands ( FoldingSetNodeID & ID,
ArrayRef< SDValue > Ops )
static

AddNodeIDOperands - Various routines for adding operands to the NodeID data.

Definition at line 718 of file SelectionDAG.cpp.

References AbstractManglingParser< Derived, Alloc >::Ops.

Referenced by AddNodeIDNode(), and AddNodeIDNode().

◆ AddNodeIDValueTypes()

void AddNodeIDValueTypes ( FoldingSetNodeID & ID,
SDVTList VTList )
static

AddNodeIDValueTypes - Value type lists are intern'd so we can represent them solely with their pointer.

Definition at line 713 of file SelectionDAG.cpp.

References llvm::SDVTList::VTs.

Referenced by AddNodeIDNode(), and AddNodeIDNode().

◆ canFoldStoreIntoLibCallOutputPointers()

bool canFoldStoreIntoLibCallOutputPointers ( StoreSDNode * StoreNode,
SDNode * FPNode )
static

◆ chainLoadsAndStoresForMemcpy()

◆ checkAddrSpaceIsValidForLibcall()

◆ checkForCyclesHelper()

◆ commuteShuffle()

void commuteShuffle ( SDValue & N1,
SDValue & N2,
MutableArrayRef< int > M )
static

Swaps the values of N1 and N2.

Swaps all indices in the shuffle mask M that point at N1 to point at N2 and indices that point at N2 to point at N1.

Definition at line 2137 of file SelectionDAG.cpp.

References llvm::ShuffleVectorSDNode::commuteMask(), and std::swap().

Referenced by llvm::SelectionDAG::getVectorShuffle().

◆ doNotCSE()

bool doNotCSE ( SDNode * N)
static

doNotCSE - Return true if CSE should not be performed for this node.

Definition at line 1002 of file SelectionDAG.cpp.

References N.

◆ FoldBUILD_VECTOR()

◆ foldCONCAT_VECTORS()

◆ FoldSTEP_VECTOR()

SDValue FoldSTEP_VECTOR ( const SDLoc & DL,
EVT VT,
SDValue Step,
SelectionDAG & DAG )
static

◆ FoldValue()

◆ FoldValueWithUndef()

std::optional< APInt > FoldValueWithUndef ( unsigned Opcode,
const APInt & C1,
bool IsUndef1,
const APInt & C2,
bool IsUndef2 )
static

◆ getMemcpyLoadsAndStores()

SDValue getMemcpyLoadsAndStores ( SelectionDAG & DAG,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Src,
uint64_t Size,
Align Alignment,
bool isVol,
bool AlwaysInline,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo,
const AAMDNodes & AAInfo,
BatchAAResults * BatchAA )
static

Definition at line 8647 of file SelectionDAG.cpp.

References llvm::ConstantDataArraySlice::Array, assert(), llvm::EVT::bitsGE(), llvm::CallingConv::C, chainLoadsAndStoresForMemcpy(), llvm::commonAlignment(), llvm::MemOp::Copy(), DL, llvm::dyn_cast(), llvm::dyn_cast_if_present(), EnableMemCpyDAGOpt, llvm::ISD::EXTLOAD, llvm::TargetLowering::findOptimalMemOpLowering(), llvm::MachinePointerInfo::getAddrSpace(), llvm::Function::getAttributes(), llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getDataLayout(), llvm::SelectionDAG::getExtLoad(), llvm::TypeSize::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::FrameIndexSDNode::getIndex(), llvm::SelectionDAG::getMachineFunction(), llvm::TargetLoweringBase::getMaxGluedStoresPerMemcpy(), llvm::TargetLoweringBase::getMaxStoresPerMemcpy(), llvm::SelectionDAG::getMemBasePlusOffset(), getMemsetStringVal(), llvm::SelectionDAG::getNode(), llvm::MachineFrameInfo::getObjectAlign(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::EVT::getSizeInBits(), llvm::SelectionDAG::getStore(), llvm::MachineFunction::getSubtarget(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SelectionDAG::getTruncStore(), llvm::TargetLoweringBase::getTypeToTransformTo(), llvm::MachinePointerInfo::getWithOffset(), llvm::SelectionDAG::InferPtrAlign(), isConstant(), llvm::MachinePointerInfo::isDereferenceable(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::EVT::isInteger(), isMemSrcFromConstant(), llvm::EVT::isVector(), llvm::ConstantDataArraySlice::Length, MaxLdStGlue, llvm::MachineMemOperand::MODereferenceable, llvm::MachineMemOperand::MOInvariant, llvm::MachineMemOperand::MONone, llvm::ConstantDataArraySlice::move(), llvm::MachineMemOperand::MOVolatile, llvm::ConstantDataArraySlice::Offset, llvm::BatchAAResults::pointsToConstantMemory(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), SDValue(), llvm::MemOp::Set(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), Size, llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::AAMDNodes::TBAA, llvm::AAMDNodes::TBAAStruct, llvm::ISD::TokenFactor, TRI, and llvm::MachinePointerInfo::V.

Referenced by llvm::SelectionDAG::getMemcpy().

◆ getMemmoveLoadsAndStores()

SDValue getMemmoveLoadsAndStores ( SelectionDAG & DAG,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Src,
uint64_t Size,
Align Alignment,
bool isVol,
bool AlwaysInline,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo,
const AAMDNodes & AAInfo )
static

Definition at line 8848 of file SelectionDAG.cpp.

References assert(), llvm::CallingConv::C, llvm::SmallVectorImpl< T >::clear(), llvm::MemOp::Copy(), DL, llvm::dyn_cast(), llvm::TargetLowering::findOptimalMemOpLowering(), llvm::MachinePointerInfo::getAddrSpace(), llvm::Function::getAttributes(), llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getDataLayout(), llvm::TypeSize::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::FrameIndexSDNode::getIndex(), llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getMachineFunction(), llvm::TargetLoweringBase::getMaxStoresPerMemmove(), llvm::SelectionDAG::getMemBasePlusOffset(), llvm::SelectionDAG::getNode(), llvm::MachineFrameInfo::getObjectAlign(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::EVT::getSizeInBits(), llvm::SelectionDAG::getStore(), llvm::MachineFunction::getSubtarget(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::MachinePointerInfo::getWithOffset(), llvm::SelectionDAG::InferPtrAlign(), llvm::MachinePointerInfo::isDereferenceable(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::MachineMemOperand::MODereferenceable, llvm::MachineMemOperand::MONone, llvm::MachineMemOperand::MOVolatile, llvm::SmallVectorTemplateBase< T, bool >::push_back(), SDValue(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), Size, llvm::AAMDNodes::TBAA, llvm::AAMDNodes::TBAAStruct, llvm::ISD::TokenFactor, and TRI.

Referenced by llvm::SelectionDAG::getMemmove().

◆ getMemsetStores()

SDValue getMemsetStores ( SelectionDAG & DAG,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Src,
uint64_t Size,
Align Alignment,
bool isVol,
bool AlwaysInline,
MachinePointerInfo DstPtrInfo,
const AAMDNodes & AAInfo )
static

Lower the call to 'memset' intrinsic function into a series of store operations.

Parameters
DAGSelection DAG where lowered code is placed.
dlLink to corresponding IR location.
ChainControl flow dependency.
DstPointer to destination memory location.
SrcValue of byte to write into the memory.
SizeNumber of bytes to write.
AlignmentAlignment of the destination in bytes.
isVolTrue if destination is volatile.
AlwaysInlineMakes sure no function call is generated.
DstPtrInfoIR information on the memory pointer.
Returns
New head in the control flow, if lowering was successful, empty SDValue otherwise.

The function tries to replace 'llvm.memset' intrinsic with several store operations and value calculation code. This is usually profitable for small memory size or when the semantic requires inlining.

Definition at line 8973 of file SelectionDAG.cpp.

References assert(), llvm::EVT::bitsLT(), llvm::CallingConv::C, DL, llvm::dyn_cast(), llvm::TargetLowering::findOptimalMemOpLowering(), llvm::MachinePointerInfo::getAddrSpace(), llvm::Function::getAttributes(), llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getDataLayout(), llvm::SelectionDAG::getExtractVectorElt(), llvm::TypeSize::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::FrameIndexSDNode::getIndex(), llvm::SelectionDAG::getMachineFunction(), llvm::TargetLoweringBase::getMaxStoresPerMemset(), llvm::SelectionDAG::getMemBasePlusOffset(), getMemsetValue(), llvm::SelectionDAG::getNode(), llvm::MachineFrameInfo::getObjectAlign(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::EVT::getScalarType(), llvm::EVT::getSizeInBits(), llvm::SelectionDAG::getStore(), llvm::MachineFunction::getSubtarget(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::EVT::getTypeForEVT(), llvm::EVT::getVectorVT(), llvm::MachinePointerInfo::getWithOffset(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::isNullConstant(), llvm::TargetLoweringBase::isTruncateFree(), llvm::TargetLoweringBase::isTypeLegal(), llvm::EVT::isVector(), llvm::MachineMemOperand::MONone, llvm::MachineMemOperand::MOVolatile, llvm::SmallVectorTemplateBase< T, bool >::push_back(), SDValue(), llvm::MemOp::Set(), llvm::MachineFrameInfo::setObjectAlignment(), llvm::TargetLoweringBase::shallExtractConstSplatVectorElementToStore(), shouldLowerMemFuncForSize(), Size, llvm::AAMDNodes::TBAA, llvm::AAMDNodes::TBAAStruct, llvm::ISD::TokenFactor, TRI, and llvm::ISD::TRUNCATE.

Referenced by llvm::SelectionDAG::getMemset().

◆ getMemsetStringVal()

◆ getMemsetValue()

◆ getSetCCInverseImpl()

ISD::CondCode getSetCCInverseImpl ( ISD::CondCode Op,
bool isIntegerLike )
static

◆ gluePropagatesDivergence()

bool gluePropagatesDivergence ( const SDNode * Node)
static

Return true if a glue output should propagate divergence information.

Definition at line 12448 of file SelectionDAG.cpp.

References llvm::ISD::CopyFromReg, llvm::ISD::CopyToReg, and llvm_unreachable.

Referenced by llvm::SelectionDAG::calculateDivergence().

◆ haveNoCommonBitsSetCommutative()

bool haveNoCommonBitsSetCommutative ( SDValue A,
SDValue B )
static

◆ InferPointerInfo() [1/2]

MachinePointerInfo InferPointerInfo ( const MachinePointerInfo & Info,
SelectionDAG & DAG,
SDValue Ptr,
int64_t Offset = 0 )
static

InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.

This is particularly useful because the code generator has many cases where it doesn't bother passing in a MachinePointerInfo to getLoad or getStore when it has "FI+Cst".

Definition at line 9708 of file SelectionDAG.cpp.

References llvm::ISD::ADD, llvm::cast(), llvm::dyn_cast(), llvm::MachinePointerInfo::getFixedStack(), llvm::SelectionDAG::getMachineFunction(), Info, llvm::isa(), llvm::Offset, and Ptr.

Referenced by llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getLoadVP(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTruncStore(), llvm::SelectionDAG::getTruncStoreVP(), and InferPointerInfo().

◆ InferPointerInfo() [2/2]

MachinePointerInfo InferPointerInfo ( const MachinePointerInfo & Info,
SelectionDAG & DAG,
SDValue Ptr,
SDValue OffsetOp )
static

InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record from it.

This is particularly useful because the code generator has many cases where it doesn't bother passing in a MachinePointerInfo to getLoad or getStore when it has "FI+Cst".

Definition at line 9732 of file SelectionDAG.cpp.

References llvm::dyn_cast(), InferPointerInfo(), Info, and Ptr.

◆ isInTailCallPositionWrapper()

◆ isMemSrcFromConstant()

bool isMemSrcFromConstant ( SDValue Src,
ConstantDataArraySlice & Slice )
static

Returns true if memcpy source is constant data.

Definition at line 8595 of file SelectionDAG.cpp.

References llvm::cast(), llvm::ISD::Constant, G, llvm::getConstantDataArrayInfo(), and llvm::ISD::GlobalAddress.

Referenced by getMemcpyLoadsAndStores().

◆ isSignedOp()

int isSignedOp ( ISD::CondCode Opcode)
static

For an integer comparison, return 1 if the comparison is a signed operation and 2 if the result is an unsigned comparison.

Return zero if the operation does not depend on the sign of the input (setne and seteq).

Definition at line 640 of file SelectionDAG.cpp.

References llvm_unreachable, llvm::ISD::SETEQ, llvm::ISD::SETGE, llvm::ISD::SETGT, llvm::ISD::SETLE, llvm::ISD::SETLT, llvm::ISD::SETNE, llvm::ISD::SETUGE, llvm::ISD::SETUGT, llvm::ISD::SETULE, and llvm::ISD::SETULT.

Referenced by llvm::ISD::getSetCCAndOperation(), and llvm::ISD::getSetCCOrOperation().

◆ makeVTList()

SDVTList makeVTList ( const EVT * VTs,
unsigned NumVTs )
static

makeVTList - Return an instance of the SDVTList struct initialized with the specified members.

Definition at line 89 of file SelectionDAG.cpp.

Referenced by llvm::SelectionDAG::getVTList().

◆ mapOverflowResult()

◆ NewSDValueDbgMsg()

void NewSDValueDbgMsg ( SDValue V,
StringRef Msg,
SelectionDAG * G )
static

◆ shouldLowerMemFuncForSize()

Variable Documentation

◆ EnableMemCpyDAGOpt

cl::opt< bool > EnableMemCpyDAGOpt("enable-memcpy-dag-opt", cl::Hidden, cl::init(true), cl::desc("Gang up loads and stores generated by inlining of memcpy")) ( "enable-memcpy-dag-opt" ,
cl::Hidden ,
cl::init(true) ,
cl::desc("Gang up loads and stores generated by inlining of memcpy")  )
static

Referenced by getMemcpyLoadsAndStores().

◆ MaxLdStGlue

cl::opt< int > MaxLdStGlue("ldstmemcpy-glue-max", cl::desc("Number limit for gluing ld/st of memcpy."), cl::Hidden, cl::init(0)) ( "ldstmemcpy-glue-max" ,
cl::desc("Number limit for gluing ld/st of memcpy.") ,
cl::Hidden ,
cl::init(0)  )
static

Referenced by getMemcpyLoadsAndStores().

◆ MaxSteps

cl::opt< unsigned > MaxSteps("has-predecessor-max-steps", cl::Hidden, cl::init(8192), cl::desc("DAG combiner limit number of steps when searching DAG " "for predecessor nodes")) ( "has-predecessor-max-steps" ,
cl::Hidden ,
cl::init(8192) ,
cl::desc("DAG combiner limit number of steps when searching DAG " "for predecessor nodes")  )
static