LLVM 20.0.0git
Macros | Functions | Variables
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/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/Mutex.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, ...)   case ISD::VPSD:
 
#define VP_PROPERTY_BINARYOP   return true;
 
#define END_REGISTER_VP_SDNODE(VPSD)   break;
 
#define BEGIN_REGISTER_VP_SDNODE(VPSD, ...)   case ISD::VPSD:
 
#define VP_PROPERTY_REDUCTION(STARTPOS, ...)   return true;
 
#define END_REGISTER_VP_SDNODE(VPSD)   break;
 
#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, ...)   case ISD::VPOPC:
 
#define VP_PROPERTY_FUNCTIONAL_SDOPC(SDOPC)   return ISD::SDOPC;
 
#define END_REGISTER_VP_SDNODE(VPOPC)   break;
 
#define BEGIN_REGISTER_VP_SDNODE(VPOPC, ...)   break;
 
#define VP_PROPERTY_FUNCTIONAL_SDOPC(SDOPC)   case ISD::SDOPC:
 
#define END_REGISTER_VP_SDNODE(VPOPC)   return ISD::VPOPC;
 
#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)    case ISD::STRICT_##DAGN: NewOpc = ISD::DAGN; break;
 
#define CMP_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)    case ISD::STRICT_##DAGN: NewOpc = ISD::SETCC; break;
 

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 VerifySDNode (SDNode *N, const TargetLowering *TLI)
 VerifySDNode - Check the given SDNode. Aborts if it is invalid.
 
static void commuteShuffle (SDValue &N1, SDValue &N2, MutableArrayRef< int > M)
 Swaps the values of N1 and N2.
 
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, AAResults *AA)
 
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 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))
 

Macro Definition Documentation

◆ BEGIN_REGISTER_VP_SDNODE [1/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [2/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [3/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [4/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [5/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [6/7]

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

◆ BEGIN_REGISTER_VP_SDNODE [7/7]

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

◆ CMP_INSTRUCTION

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

◆ DAG_INSTRUCTION

#define DAG_INSTRUCTION (   NAME,
  NARG,
  ROUND_MODE,
  INTRINSIC,
  DAGN 
)     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/4]

#define END_REGISTER_VP_SDNODE (   VPOPC)    break;

◆ END_REGISTER_VP_SDNODE [2/4]

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

◆ END_REGISTER_VP_SDNODE [3/4]

#define END_REGISTER_VP_SDNODE (   VPSD)    break;

◆ END_REGISTER_VP_SDNODE [4/4]

#define END_REGISTER_VP_SDNODE (   VPSD)    break;

◆ VP_PROPERTY_BINARYOP

#define VP_PROPERTY_BINARYOP   return true;

◆ VP_PROPERTY_FUNCTIONAL_SDOPC [1/2]

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

◆ VP_PROPERTY_FUNCTIONAL_SDOPC [2/2]

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

◆ VP_PROPERTY_REDUCTION

#define VP_PROPERTY_REDUCTION (   STARTPOS,
  ... 
)    return true;

Function Documentation

◆ AddNodeIDCustom()

static 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 717 of file SelectionDAG.cpp.

References llvm::ISD::AssertAlign, llvm::ISD::ATOMIC_CMP_SWAP, llvm::ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, llvm::ISD::ATOMIC_LOAD, llvm::ISD::ATOMIC_LOAD_ADD, llvm::ISD::ATOMIC_LOAD_AND, llvm::ISD::ATOMIC_LOAD_CLR, llvm::ISD::ATOMIC_LOAD_MAX, llvm::ISD::ATOMIC_LOAD_MIN, llvm::ISD::ATOMIC_LOAD_NAND, llvm::ISD::ATOMIC_LOAD_OR, llvm::ISD::ATOMIC_LOAD_SUB, llvm::ISD::ATOMIC_LOAD_UMAX, llvm::ISD::ATOMIC_LOAD_UMIN, llvm::ISD::ATOMIC_LOAD_XOR, llvm::ISD::ATOMIC_STORE, llvm::ISD::ATOMIC_SWAP, llvm::ISD::BasicBlock, llvm::ISD::BlockAddress, llvm::CallingConv::C, llvm::ISD::Constant, llvm::ISD::ConstantFP, llvm::ISD::ConstantPool, llvm::ISD::ExternalSymbol, llvm::ISD::FrameIndex, llvm::MachinePointerInfo::getAddrSpace(), llvm::getAlign(), llvm::SelectionDAG::getBasicBlock(), llvm::BlockAddressSDNode::getBlockAddress(), llvm::MachineMemOperand::getFlags(), llvm::GlobalAddressSDNode::getGlobal(), llvm::TargetIndexSDNode::getIndex(), llvm::MemSDNode::getMemOperand(), llvm::MemSDNode::getMemoryVT(), llvm::GlobalAddressSDNode::getOffset(), llvm::TargetIndexSDNode::getOffset(), llvm::BlockAddressSDNode::getOffset(), llvm::getOffset(), llvm::MemSDNode::getPointerInfo(), llvm::EVT::getRawBits(), llvm::MemSDNode::getRawSubclassData(), getReg(), getSize(), llvm::GlobalAddressSDNode::getTargetFlags(), llvm::TargetIndexSDNode::getTargetFlags(), llvm::BlockAddressSDNode::getTargetFlags(), llvm::ISD::GlobalAddress, llvm::ISD::GlobalTLSAddress, llvm::ISD::INTRINSIC_VOID, llvm::ISD::INTRINSIC_W_CHAIN, llvm::ISD::JumpTable, llvm::ISD::LIFETIME_END, llvm::ISD::LIFETIME_START, llvm_unreachable, llvm::ISD::LOAD, llvm::ISD::MCSymbol, llvm::ISD::MGATHER, llvm::ISD::MLOAD, llvm::ISD::MSCATTER, llvm::ISD::MSTORE, N, llvm::ISD::PREFETCH, llvm::ISD::PSEUDO_PROBE, llvm::ISD::Register, llvm::ISD::RegisterMask, llvm::ISD::SRCVALUE, llvm::ISD::STORE, 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, value, and llvm::ISD::VECTOR_SHUFFLE.

Referenced by AddNodeIDNode().

◆ AddNodeIDNode() [1/2]

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

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

Definition at line 950 of file SelectionDAG.cpp.

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

◆ AddNodeIDNode() [2/2]

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

Definition at line 709 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::getFrameIndex(), llvm::SelectionDAG::getGatherVP(), llvm::SelectionDAG::getGetFPEnv(), llvm::SelectionDAG::getGlobalAddress(), llvm::SelectionDAG::getIndexedStore(), llvm::SelectionDAG::getIndexedStoreVP(), llvm::SelectionDAG::getJumpTable(), llvm::SelectionDAG::getLabelNode(), llvm::SelectionDAG::getLifetimeNode(), llvm::SelectionDAG::getLoad(), 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::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::getTruncStore(), llvm::SelectionDAG::getTruncStoreVP(), llvm::SelectionDAG::getTruncStridedStoreVP(), llvm::SelectionDAG::getVectorShuffle(), llvm::SelectionDAG::MorphNodeTo(), and llvm::SDNode::Profile().

◆ AddNodeIDOpcode()

static void AddNodeIDOpcode ( FoldingSetNodeID ID,
unsigned  OpC 
)
static

AddNodeIDOpcode - Add the node opcode to the NodeID data.

Definition at line 681 of file SelectionDAG.cpp.

Referenced by AddNodeIDNode().

◆ AddNodeIDOperands() [1/2]

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

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

Definition at line 701 of file SelectionDAG.cpp.

◆ AddNodeIDOperands() [2/2]

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

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

Definition at line 692 of file SelectionDAG.cpp.

Referenced by AddNodeIDNode().

◆ AddNodeIDValueTypes()

static 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 687 of file SelectionDAG.cpp.

References llvm::SDVTList::VTs.

Referenced by AddNodeIDNode().

◆ chainLoadsAndStoresForMemcpy()

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

◆ checkAddrSpaceIsValidForLibcall()

static void checkAddrSpaceIsValidForLibcall ( const TargetLowering TLI,
unsigned  AS 
)
static

◆ checkForCyclesHelper()

static void checkForCyclesHelper ( const SDNode N,
SmallPtrSetImpl< const SDNode * > &  Visited,
SmallPtrSetImpl< const SDNode * > &  Checked,
const llvm::SelectionDAG DAG 
)
static

◆ commuteShuffle()

static 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 2095 of file SelectionDAG.cpp.

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

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

◆ doNotCSE()

static bool doNotCSE ( SDNode N)
static

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

Definition at line 966 of file SelectionDAG.cpp.

References llvm::ISD::EH_LABEL, llvm::ISD::HANDLENODE, and N.

◆ FoldBUILD_VECTOR()

static SDValue FoldBUILD_VECTOR ( const SDLoc DL,
EVT  VT,
ArrayRef< SDValue Ops,
SelectionDAG DAG 
)
static

◆ foldCONCAT_VECTORS()

static SDValue foldCONCAT_VECTORS ( const SDLoc DL,
EVT  VT,
ArrayRef< SDValue Ops,
SelectionDAG DAG 
)
static

◆ FoldSTEP_VECTOR()

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

◆ FoldValue()

static std::optional< APInt > FoldValue ( unsigned  Opcode,
const APInt C1,
const APInt C2 
)
static

◆ FoldValueWithUndef()

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

◆ getMemcpyLoadsAndStores()

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,
AAResults AA 
)
static

Definition at line 7842 of file SelectionDAG.cpp.

References llvm::ConstantDataArraySlice::Array, assert(), llvm::EVT::bitsGE(), llvm::CallingConv::C, chainLoadsAndStoresForMemcpy(), llvm::commonAlignment(), llvm::MemOp::Copy(), DL, 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::AAResults::pointsToConstantMemory(), llvm::Align::previous(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MemOp::Set(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), llvm::SmallVectorBase< Size_T >::size(), Size, llvm::AAMDNodes::TBAA, llvm::AAMDNodes::TBAAStruct, llvm::ISD::TokenFactor, TRI, and llvm::MachinePointerInfo::V.

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

◆ getMemmoveLoadsAndStores()

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

Definition at line 8045 of file SelectionDAG.cpp.

References assert(), llvm::CallingConv::C, llvm::SmallVectorImpl< T >::clear(), llvm::MemOp::Copy(), DL, 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::Align::previous(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachineFrameInfo::setObjectAlignment(), shouldLowerMemFuncForSize(), llvm::SmallVectorBase< Size_T >::size(), Size, llvm::AAMDNodes::TBAA, llvm::AAMDNodes::TBAAStruct, llvm::ISD::TokenFactor, and TRI.

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

◆ getMemsetStores()

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 
)
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 8170 of file SelectionDAG.cpp.

References assert(), llvm::ISD::BITCAST, llvm::EVT::bitsLT(), DL, llvm::ISD::EXTRACT_VECTOR_ELT, 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::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::SelectionDAG::getVectorIdxConstant(), 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::Align::previous(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), 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()

static SDValue getMemsetStringVal ( EVT  VT,
const SDLoc dl,
SelectionDAG DAG,
const TargetLowering TLI,
const ConstantDataArraySlice Slice 
)
static

◆ getMemsetValue()

static SDValue getMemsetValue ( SDValue  Value,
EVT  VT,
SelectionDAG DAG,
const SDLoc dl 
)
static

◆ getSetCCInverseImpl()

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

◆ gluePropagatesDivergence()

static bool gluePropagatesDivergence ( const SDNode Node)
static

Return true if a glue output should propagate divergence information.

Definition at line 11614 of file SelectionDAG.cpp.

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

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

◆ haveNoCommonBitsSetCommutative()

static bool haveNoCommonBitsSetCommutative ( SDValue  A,
SDValue  B 
)
static

◆ InferPointerInfo() [1/2]

static 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 8880 of file SelectionDAG.cpp.

References llvm::ISD::ADD, llvm::MachinePointerInfo::getFixedStack(), llvm::SelectionDAG::getMachineFunction(), Info, 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]

static 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 8904 of file SelectionDAG.cpp.

References InferPointerInfo(), Info, llvm::SDValue::isUndef(), and Ptr.

◆ isMemSrcFromConstant()

static bool isMemSrcFromConstant ( SDValue  Src,
ConstantDataArraySlice Slice 
)
static

Returns true if memcpy source is constant data.

Definition at line 7790 of file SelectionDAG.cpp.

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

Referenced by getMemcpyLoadsAndStores().

◆ isSignedOp()

static 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 614 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()

static 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()

static SelectionDAG::OverflowKind mapOverflowResult ( ConstantRange::OverflowResult  OR)
static

◆ NewSDValueDbgMsg()

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

◆ shouldLowerMemFuncForSize()

static bool shouldLowerMemFuncForSize ( const MachineFunction MF,
SelectionDAG DAG 
)
static

◆ VerifySDNode()

static void VerifySDNode ( SDNode N,
const TargetLowering TLI 
)
static

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().