LLVM 24.0.0git
NVPTXISelLowering.cpp File Reference
#include "NVPTXISelLowering.h"
#include "MCTargetDesc/NVPTXBaseInfo.h"
#include "NVPTX.h"
#include "NVPTXMachineFunctionInfo.h"
#include "NVPTXSelectionDAGInfo.h"
#include "NVPTXSubtarget.h"
#include "NVPTXTargetMachine.h"
#include "NVPTXTargetObjectFile.h"
#include "NVPTXUtilities.h"
#include "NVVMProperties.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/SDPatternMatch.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/TargetCallingConv.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/FPEnv.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsNVPTX.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NVVMIntrinsicUtils.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/NVPTXAddrSpace.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iterator>
#include <optional>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "nvptx-lower"
#define TCGEN05_LD_RED_INTR(SHAPE, NUM, TYPE)
#define TCGEN05_LD_RED_INST(SHAPE, NUM, TYPE)
#define SPCOMPRESS_NODE_CASE(NumResults)
#define SPDECOMPRESS_NODE_CASE(NumResults)

Functions

static bool IsPTXVectorType (MVT VT)
static std::optional< std::pair< unsigned int, MVT > > getVectorLoweringShape (EVT VectorEVT, const NVPTXSubtarget &STI, unsigned AddressSpace)
static void ComputePTXValueVTs (const TargetLowering &TLI, const DataLayout &DL, LLVMContext &Ctx, CallingConv::ID CallConv, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > &Offsets, uint64_t StartingOffset=0)
 ComputePTXValueVTs - For the given Type Ty, returns the set of primitive legal-ish MVTs that compose it.
static EVT getVectorizedVT (EVT VT, unsigned N, LLVMContext &C)
static SDValue getExtractVectorizedValue (SDValue V, unsigned I, EVT VT, const SDLoc &dl, SelectionDAG &DAG)
template<typename T>
static SDValue getBuildVectorizedValue (unsigned N, const SDLoc &dl, SelectionDAG &DAG, T GetElement)
static EVT promoteScalarIntegerPTX (const EVT VT)
 PromoteScalarIntegerPTX Used to make sure the arguments/returns are suitable for passing and promote them to a larger size if they're not.
template<typename T>
static unsigned canMergeParamLoadStoresStartingAt (unsigned Idx, uint32_t AccessSize, const SmallVectorImpl< EVT > &ValueVTs, const SmallVectorImpl< T > &Offsets, Align ParamAlignment)
template<typename T>
static SmallVector< unsigned, 16 > VectorizePTXValueVTs (const SmallVectorImpl< EVT > &ValueVTs, const SmallVectorImpl< T > &Offsets, Align ParamAlignment, bool IsVAArg=false)
static MachinePointerInfo refinePtrAS (SDValue &Ptr, SelectionDAG &DAG)
static ISD::NodeType getExtOpcode (const ISD::ArgFlagsTy &Flags)
static SDValue correctParamType (SDValue V, EVT ExpectedVT, ISD::ArgFlagsTy Flags, SelectionDAG &DAG, SDLoc dl)
static SDValue getSymbolNode (SelectionDAG &DAG, MCSymbol *Sym, EVT T)
static SDValue getSymbolNode (SelectionDAG &DAG, const Twine &Name, EVT T)
static SDValue getPRMT (SDValue A, SDValue B, SDValue Selector, SDLoc DL, SelectionDAG &DAG, unsigned Mode=NVPTX::PTXPrmtMode::NONE)
static SDValue getPRMT (SDValue A, SDValue B, uint64_t Selector, SDLoc DL, SelectionDAG &DAG, unsigned Mode=NVPTX::PTXPrmtMode::NONE)
static SDValue buildTreeReduction (const SmallVector< SDValue > &Elements, EVT EltTy, ArrayRef< std::pair< unsigned, unsigned > > Ops, const SDLoc &DL, const SDNodeFlags Flags, SelectionDAG &DAG)
 Reduces the elements using the scalar operations provided.
static ISD::NodeType getScalarOpcodeForReduction (unsigned ReductionOpcode)
static std::optional< unsigned > getScalar3OpcodeForReduction (unsigned ReductionOpcode)
 Get 3-input scalar reduction opcode.
static SDValue PromoteBinOpToF32 (SDNode *N, SelectionDAG &DAG)
static SDValue lowerMUL_LOHI (SDValue Op, SelectionDAG &DAG)
static SDValue lowerFPTRUNC_ROUND (SDValue Op, SelectionDAG &DAG, const NVPTXSubtarget &STI)
static SDValue LowerVectorArith (SDValue Op, SelectionDAG &DAG)
static SDValue lowerTcgen05St (SDValue Op, SelectionDAG &DAG, bool hasOffset=false)
static SDValue lowerBSWAP (SDValue Op, SelectionDAG &DAG)
static SDValue lowerStAsyncWithMbarrier (SDValue Op, SelectionDAG &DAG)
static SDValue lowerStAsyncRelease (SDValue Op, SelectionDAG &DAG)
static unsigned getTcgen05MMADisableOutputLane (unsigned IID)
static SDValue LowerTcgen05MMADisableOutputLane (SDValue Op, SelectionDAG &DAG)
static std::optional< std::pair< SDValue, SDValue > > lowerTcgen05Ld (SDNode *N, SelectionDAG &DAG, bool HasOffset=false)
static SDValue reportInvalidTensormapReplaceUsage (SDValue Op, SelectionDAG &DAG, unsigned Val)
static SDValue lowerTensormapReplaceElemtype (SDValue Op, SelectionDAG &DAG)
static SDValue lowerTensormapReplaceSwizzleMode (SDValue Op, SelectionDAG &DAG)
static SDValue lowerIntrinsicVoid (SDValue Op, SelectionDAG &DAG)
static SDValue LowerClusterLaunchControlQueryCancel (SDValue Op, SelectionDAG &DAG)
static SDValue lowerCvtRSIntrinsics (SDValue Op, SelectionDAG &DAG)
static SDValue lowerPrmtIntrinsic (SDValue Op, SelectionDAG &DAG)
static unsigned getTcgen05LdRedID (Intrinsic::ID IID)
static std::optional< std::tuple< SDValue, SDValue, SDValue > > lowerTcgen05LdRed (SDNode *N, SelectionDAG &DAG)
static SDValue lowerIntrinsicWChain (SDValue Op, SelectionDAG &DAG)
static unsigned getSPNumRegs (EVT VT)
static EVT getSPRegType (EVT VT)
static void appendSplitSPOperands (ArrayRef< SDUse > Input, SmallVectorImpl< SDValue > &Output, SelectionDAG &DAG)
static SDValue joinSPRegs (EVT VT, ArrayRef< SDValue > Regs, const SDLoc &DL, SelectionDAG &DAG)
static unsigned getSPCompressNodeOpcode (unsigned NumResults)
static unsigned getSPDecompressNodeOpcode (unsigned NumResults)
static SDValue lowerSPIntrinsic (SDValue Op, SelectionDAG &DAG)
static SDValue lowerIntrinsicWOChain (SDValue Op, SelectionDAG &DAG)
static SDValue lowerCTLZCTPOP (SDValue Op, SelectionDAG &DAG)
static SDValue expandFSH64 (SDValue A, SDValue B, SDValue ShiftAmount, SDLoc DL, unsigned Opcode, SelectionDAG &DAG)
static SDValue lowerFSH (SDValue Op, SelectionDAG &DAG)
static SDValue lowerROT (SDValue Op, SelectionDAG &DAG)
static SDValue lowerSELECT (SDValue Op, SelectionDAG &DAG)
static SDValue lowerMSTORE (SDValue Op, SelectionDAG &DAG)
static SDValue lowerAtomicStore128 (SDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI)
static std::pair< MemSDNode *, uint32_t > convertMLOADToLoadWithUsedBytesMask (MemSDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI)
static std::optional< std::pair< SDValue, SDValue > > replaceLoadVector (SDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI)
 replaceLoadVector - Convert vector loads into multi-output scalar loads.
static void replaceLoadVector (SDNode *N, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results, const NVPTXSubtarget &STI)
static SDValue lowerLoadVector (SDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI)
static SDValue lowerLOADi1 (LoadSDNode *LD, SelectionDAG &DAG)
static SDValue lowerSTOREVector (SDValue Op, SelectionDAG &DAG, const NVPTXSubtarget &STI)
static bool isConstZero (const SDValue &Operand)
static SDValue PerformADDCombineWithOperands (SDNode *N, SDValue N0, SDValue N1, TargetLowering::DAGCombinerInfo &DCI)
 PerformADDCombineWithOperands - Try DAG combinations for an ADD with operands N0 and N1.
static SDValue combineUnpackingMovIntoLoad (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
 Fold unpacking movs into a load by increasing the number of return values.
static SDValue combinePackingMovIntoStore (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, unsigned Front, unsigned Back)
 Fold packing movs into a store.
static SDValue combineSTORE (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static SDValue combineLOAD (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static SDValue PerformADDCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, CodeGenOptLevel OptLevel)
 PerformADDCombine - Target-specific dag combine xforms for ISD::ADD.
static bool isNonCoalescableBuildVector (const SDValue &BV)
 Check if a v2f32 BUILD_VECTOR provably packs values from non-adjacent register pairs (non-coalescable).
static unsigned getMinMax3Opcode (unsigned MinMax2Opcode)
 Get 3-input version of a 2-input min/max opcode.
static SDValue PerformFMinMaxCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
 PerformFMinMaxCombine - Combine (fmaxnum (fmaxnum a, b), c) into (fmaxnum3 a, b, c).
static SDValue combineSZExtToMulWide (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, CodeGenOptLevel OptLevel)
static bool IsExtendedFromLte (SDValue Op, unsigned OptSize, bool &IsSigned)
 Check whether Op is explicitly extended from at most OptSize bits, setting IsSigned to the signedness of the extension.
static bool AreMulWideOperandsDemotable (SDValue LHS, SDValue RHS, unsigned OptSize, const SelectionDAG &DAG, bool &IsSigned)
 AreMulWideOperandsDemotable - Checks if the given LHS and RHS operands can be demoted to OptSize bits without loss of information using the same signedness.
static SDValue TryMULWIDECombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
 TryMULWIDECombine - Attempt to replace a multiply of M bits with a multiply of M/2 bits that produces an M-bit result (i.e.
static bool isConstOne (const SDValue &Operand)
static SDValue matchMADConstOnePattern (SDValue Add)
static SDValue combineMADConstOne (SDValue X, SDValue Add, EVT VT, SDLoc DL, TargetLowering::DAGCombinerInfo &DCI)
static SDValue combineMulSelectConstOne (SDValue X, SDValue Select, EVT VT, SDLoc DL, TargetLowering::DAGCombinerInfo &DCI)
static SDValue PerformMULCombineWithOperands (SDNode *N, SDValue N0, SDValue N1, TargetLowering::DAGCombinerInfo &DCI)
static SDValue PerformMULCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, CodeGenOptLevel OptLevel)
 PerformMULCombine - Runs PTX-specific DAG combine patterns on MUL nodes.
static SDValue combineShiftOfLogicOp (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
 Commute SHL with a bitwise logic operation when doing so exposes a common shifted operand.
static SDValue PerformSHLCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, CodeGenOptLevel OptLevel)
 PerformSHLCombine - Runs PTX-specific DAG combine patterns on SHL nodes.
static SDValue PerformSETCCCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static SDValue PerformEXTRACTCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static SDValue PerformSELECTShiftCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
 Transform patterns like: (select (ugt shift_amt, BitWidth-1), 0, (srl/shl x, shift_amt)) (select (ult shift_amt, BitWidth), (srl/shl x, shift_amt), 0) Into: (NVPTXISD::SRL_CLAMP x, shift_amt) or (NVPTXISD::SHL_CLAMP x, shift_amt)
static SDValue PerformVSELECTCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static SDValue PerformBUILD_VECTORCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static SDValue combineADDRSPACECAST (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static APInt getPRMTSelector (const APInt &Selector, unsigned Mode)
static APInt computePRMT (APInt A, APInt B, APInt Selector, unsigned Mode)
static SDValue combinePRMT (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, CodeGenOptLevel OptLevel)
static SDValue sinkProxyReg (SDValue R, SDValue Chain, TargetLowering::DAGCombinerInfo &DCI)
static unsigned getFAddWithNegOpcode (EVT VT, Intrinsic::ID IID, APFloat::roundingMode RoundingMode)
static SDValue combineFAddWithNeg (SDNode *N, SelectionDAG &DAG, Intrinsic::ID AddIntrinsicID, APFloat::roundingMode RoundingMode)
static bool isSupportedFPArith (SDNode *N, const NVPTXSubtarget &STI, unsigned ISDOpcode, Intrinsic::ID IID)
static SDValue diagnoseUnsupportedFPArith (SDNode *N, SelectionDAG &DAG, Intrinsic::ID IID, APFloat::roundingMode RoundingMode)
static SDValue combineIntrinsicWOChain (SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static SDValue combineProxyReg (SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static void ReplaceBITCAST (SDNode *Node, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results)
static void ReplaceINTRINSIC_W_CHAIN (SDNode *N, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results)
static void ReplaceCopyFromReg_128 (SDNode *N, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results)
static void replaceProxyReg (SDNode *N, SelectionDAG &DAG, const TargetLowering &TLI, SmallVectorImpl< SDValue > &Results)
static void replaceAtomicSwap128 (SDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI, SmallVectorImpl< SDValue > &Results)
static void replaceAtomicLoad128 (SDNode *N, SelectionDAG &DAG, const NVPTXSubtarget &STI, SmallVectorImpl< SDValue > &Results)
static TargetLoweringBase::AtomicExpansionKind getScalarAtomicRMWExpansion (AtomicRMWInst::BinOp Op, Type *Ty, unsigned AddressSpace, const Function &F, bool IgnoreDenormalMode, const NVPTXSubtarget &STI)
 Returns how NVPTX should expand a scalar atomicrmw.
static void computeKnownBitsForPRMT (const SDValue Op, KnownBits &Known, const SelectionDAG &DAG, unsigned Depth)
static void computeKnownBitsForLoadV (const SDValue Op, KnownBits &Known)
static std::pair< APInt, APInt > getPRMTDemandedBits (const APInt &SelectorVal, const APInt &DemandedBits)
static SDValue canonicalizePRMTInput (SDValue Op, SelectionDAG &DAG)
static SDValue simplifyDemandedBitsForPRMT (SDValue PRMT, const APInt &DemandedBits, SelectionDAG &DAG, const TargetLowering &TLI, unsigned Depth)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "nvptx-lower"

Definition at line 81 of file NVPTXISelLowering.cpp.

◆ SPCOMPRESS_NODE_CASE

#define SPCOMPRESS_NODE_CASE ( NumResults)
Value:
case NumResults: \
return NVPTXISD::SPCOMPRESS_R##NumResults

Referenced by getSPCompressNodeOpcode().

◆ SPDECOMPRESS_NODE_CASE

#define SPDECOMPRESS_NODE_CASE ( NumResults)
Value:
case NumResults: \
return NVPTXISD::SPDECOMPRESS_R##NumResults

Referenced by getSPDecompressNodeOpcode().

◆ TCGEN05_LD_RED_INST

#define TCGEN05_LD_RED_INST ( SHAPE,
NUM,
TYPE )
Value:
NVPTXISD::TCGEN05_LD_RED_##SHAPE##_X##NUM##_##TYPE
#define _

Definition at line 3096 of file NVPTXISelLowering.cpp.

Referenced by getTcgen05LdRedID().

◆ TCGEN05_LD_RED_INTR

#define TCGEN05_LD_RED_INTR ( SHAPE,
NUM,
TYPE )
Value:
Intrinsic::nvvm_tcgen05_ld_red_##SHAPE##_x##NUM##_##TYPE

Definition at line 3093 of file NVPTXISelLowering.cpp.

Referenced by getTcgen05LdRedID().

Function Documentation

◆ appendSplitSPOperands()

◆ AreMulWideOperandsDemotable()

bool AreMulWideOperandsDemotable ( SDValue LHS,
SDValue RHS,
unsigned OptSize,
const SelectionDAG & DAG,
bool & IsSigned )
static

AreMulWideOperandsDemotable - Checks if the given LHS and RHS operands can be demoted to OptSize bits without loss of information using the same signedness.

The signedness of the operands is placed in IsSigned.

Definition at line 6671 of file NVPTXISelLowering.cpp.

References llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeMaxSignificantBits(), llvm::KnownBits::countMaxActiveBits(), llvm::dyn_cast(), IsExtendedFromLte(), llvm::APInt::isIntN(), llvm::APInt::isSignedIntN(), LHS, and RHS.

Referenced by TryMULWIDECombine().

◆ buildTreeReduction()

SDValue buildTreeReduction ( const SmallVector< SDValue > & Elements,
EVT EltTy,
ArrayRef< std::pair< unsigned, unsigned > > Ops,
const SDLoc & DL,
const SDNodeFlags Flags,
SelectionDAG & DAG )
static

Reduces the elements using the scalar operations provided.

The operations are sorted descending in number of inputs they take. The flags on the original reduction operation will be propagated to each scalar operation. Nearby elements are grouped in tree reduction, unlike the shuffle reduction used in ExpandReductions and SelectionDAG.

Definition at line 1804 of file NVPTXISelLowering.cpp.

References AbstractManglingParser< Derived, Alloc >::Ops, assert(), DL, E(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SelectionDAG::getNode(), I, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ArrayRef< T >::slice().

◆ canMergeParamLoadStoresStartingAt()

template<typename T>
unsigned canMergeParamLoadStoresStartingAt ( unsigned Idx,
uint32_t AccessSize,
const SmallVectorImpl< EVT > & ValueVTs,
const SmallVectorImpl< T > & Offsets,
Align ParamAlignment )
static

◆ canonicalizePRMTInput()

SDValue canonicalizePRMTInput ( SDValue Op,
SelectionDAG & DAG )
static

Definition at line 8519 of file NVPTXISelLowering.cpp.

References llvm::SelectionDAG::getConstant(), and SDValue().

Referenced by simplifyDemandedBitsForPRMT().

◆ combineADDRSPACECAST()

SDValue combineADDRSPACECAST ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

Definition at line 7269 of file NVPTXISelLowering.cpp.

References assert(), llvm::cast(), llvm::dyn_cast(), N, and SDValue().

◆ combineFAddWithNeg()

SDValue combineFAddWithNeg ( SDNode * N,
SelectionDAG & DAG,
Intrinsic::ID AddIntrinsicID,
APFloat::roundingMode RoundingMode )
static

◆ combineIntrinsicWOChain()

◆ combineLOAD()

◆ combineMADConstOne()

◆ combineMulSelectConstOne()

◆ combinePackingMovIntoStore()

SDValue combinePackingMovIntoStore ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI,
unsigned Front,
unsigned Back )
static

◆ combinePRMT()

◆ combineProxyReg()

SDValue combineProxyReg ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

Definition at line 7554 of file NVPTXISelLowering.cpp.

References llvm::ISD::LOAD, N, Reg, SDValue(), sinkProxyReg(), and V.

◆ combineShiftOfLogicOp()

SDValue combineShiftOfLogicOp ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

Commute SHL with a bitwise logic operation when doing so exposes a common shifted operand.

For example:

Before: N = shl (zext (LogicOp X, C)), ShiftAmount OtherShift = shl (zext (OtherLogicOp X, OtherC)), ShiftAmount

After: ShiftedX = shl (zext X), ShiftAmount N = LogicOp ShiftedX, ShiftedC OtherShift = OtherLogicOp ShiftedX, ShiftedOtherC

ShiftedC = (zext C) << ShiftAmount and ShiftedOtherC = (zext OtherC) << ShiftAmount are folded constants. This replaces two variable shifts with the single shared ShiftedX. Requiring another matching shift avoids disrupting isolated address calculations where a shift may be folded into the addressing mode.

Definition at line 6911 of file NVPTXISelLowering.cpp.

References C(), llvm::TargetLowering::DAGCombinerInfo::CombineTo(), llvm::TargetLowering::DAGCombinerInfo::DAG, DL, llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SDNode::getFlags(), llvm::SelectionDAG::getNode(), llvm::isConstOrConstSplat(), llvm::ISD::isExtOpcode(), llvm::PatternMatch::m_BitwiseLogic(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), N, llvm::SmallVectorTemplateBase< T, bool >::push_back(), SDValue(), llvm::ISD::SHL, llvm::SDNode::users(), and X.

Referenced by PerformSHLCombine().

◆ combineSTORE()

◆ combineSZExtToMulWide()

◆ combineUnpackingMovIntoLoad()

SDValue combineUnpackingMovIntoLoad ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

Fold unpacking movs into a load by increasing the number of return values.

ex: L: v2f16,ch = load

a: f16 = extractelt L:0, 0 b: f16 = extractelt L:0, 1 use(a, b)

...is turned into...

L: f16,f16,ch = LoadV2

use(L:0, L:1)

Definition at line 6122 of file NVPTXISelLowering.cpp.

References llvm::all_of(), llvm::TargetLowering::DAGCombinerInfo::isAfterLegalizeDAG(), llvm::NVPTX::isPackedVectorTy(), N, and SDValue().

Referenced by combineLOAD().

◆ computeKnownBitsForLoadV()

void computeKnownBitsForLoadV ( const SDValue Op,
KnownBits & Known )
static

◆ computeKnownBitsForPRMT()

◆ computePRMT()

◆ ComputePTXValueVTs()

void ComputePTXValueVTs ( const TargetLowering & TLI,
const DataLayout & DL,
LLVMContext & Ctx,
CallingConv::ID CallConv,
Type * Ty,
SmallVectorImpl< EVT > & ValueVTs,
SmallVectorImpl< uint64_t > & Offsets,
uint64_t StartingOffset = 0 )
static

ComputePTXValueVTs - For the given Type Ty, returns the set of primitive legal-ish MVTs that compose it.

Unlike ComputeValueVTs, this will legalize the types as required by the calling convention (with special handling for i8s). NOTE: This is a band-aid for code that expects ComputeValueVTs to return the same number of types as the Ins/Outs arrays in LowerFormalArguments, LowerCall, and LowerReturn.

Definition at line 273 of file NVPTXISelLowering.cpp.

References assert(), llvm::ComputeValueVTs(), DL, llvm::MVT::getStoreSize(), I, llvm::Off, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::seq(), TLI, uint64_t, and llvm::zip().

Referenced by llvm::NVPTXTargetLowering::LowerCall(), llvm::NVPTXTargetLowering::LowerFormalArguments(), and llvm::NVPTXTargetLowering::LowerReturn().

◆ convertMLOADToLoadWithUsedBytesMask()

◆ correctParamType()

◆ diagnoseUnsupportedFPArith()

◆ expandFSH64()

◆ getBuildVectorizedValue()

◆ getExtOpcode()

ISD::NodeType getExtOpcode ( const ISD::ArgFlagsTy & Flags)
static

◆ getExtractVectorizedValue()

◆ getFAddWithNegOpcode()

unsigned getFAddWithNegOpcode ( EVT VT,
Intrinsic::ID IID,
APFloat::roundingMode RoundingMode )
static

◆ getMinMax3Opcode()

unsigned getMinMax3Opcode ( unsigned MinMax2Opcode)
static

Get 3-input version of a 2-input min/max opcode.

Definition at line 6542 of file NVPTXISelLowering.cpp.

References llvm::ISD::FMAXIMUM, llvm::ISD::FMAXIMUMNUM, llvm::ISD::FMAXNUM, llvm::ISD::FMINIMUM, llvm::ISD::FMINIMUMNUM, llvm::ISD::FMINNUM, and llvm_unreachable.

Referenced by PerformFMinMaxCombine().

◆ getPRMT() [1/2]

◆ getPRMT() [2/2]

SDValue getPRMT ( SDValue A,
SDValue B,
uint64_t Selector,
SDLoc DL,
SelectionDAG & DAG,
unsigned Mode = NVPTX::PTXPrmtMode::NONE )
static

◆ getPRMTDemandedBits()

std::pair< APInt, APInt > getPRMTDemandedBits ( const APInt & SelectorVal,
const APInt & DemandedBits )
static

◆ getPRMTSelector()

◆ getScalar3OpcodeForReduction()

std::optional< unsigned > getScalar3OpcodeForReduction ( unsigned ReductionOpcode)
static

◆ getScalarAtomicRMWExpansion()

◆ getScalarOpcodeForReduction()

◆ getSPCompressNodeOpcode()

unsigned getSPCompressNodeOpcode ( unsigned NumResults)
static

Definition at line 3305 of file NVPTXISelLowering.cpp.

References llvm_unreachable, and SPCOMPRESS_NODE_CASE.

Referenced by lowerSPIntrinsic().

◆ getSPDecompressNodeOpcode()

unsigned getSPDecompressNodeOpcode ( unsigned NumResults)
static

Definition at line 3334 of file NVPTXISelLowering.cpp.

References llvm_unreachable, and SPDECOMPRESS_NODE_CASE.

Referenced by lowerSPIntrinsic().

◆ getSPNumRegs()

unsigned getSPNumRegs ( EVT VT)
static

◆ getSPRegType()

EVT getSPRegType ( EVT VT)
static

◆ getSymbolNode() [1/2]

SDValue getSymbolNode ( SelectionDAG & DAG,
const Twine & Name,
EVT T )
static

◆ getSymbolNode() [2/2]

◆ getTcgen05LdRedID()

unsigned getTcgen05LdRedID ( Intrinsic::ID IID)
static

Definition at line 3099 of file NVPTXISelLowering.cpp.

References F32, llvm_unreachable, TCGEN05_LD_RED_INST, and TCGEN05_LD_RED_INTR.

Referenced by lowerTcgen05LdRed().

◆ getTcgen05MMADisableOutputLane()

unsigned getTcgen05MMADisableOutputLane ( unsigned IID)
static

Definition at line 2672 of file NVPTXISelLowering.cpp.

References llvm_unreachable.

Referenced by LowerTcgen05MMADisableOutputLane().

◆ getVectorizedVT()

◆ getVectorLoweringShape()

◆ isConstOne()

bool isConstOne ( const SDValue & Operand)
static

Definition at line 6793 of file NVPTXISelLowering.cpp.

References llvm::dyn_cast().

Referenced by combineMulSelectConstOne(), and matchMADConstOnePattern().

◆ isConstZero()

bool isConstZero ( const SDValue & Operand)
static

Definition at line 5984 of file NVPTXISelLowering.cpp.

References llvm::dyn_cast().

Referenced by PerformADDCombineWithOperands().

◆ IsExtendedFromLte()

bool IsExtendedFromLte ( SDValue Op,
unsigned OptSize,
bool & IsSigned )
static

Check whether Op is explicitly extended from at most OptSize bits, setting IsSigned to the signedness of the extension.

Definition at line 6649 of file NVPTXISelLowering.cpp.

References llvm::EVT::getFixedSizeInBits(), llvm::ISD::SIGN_EXTEND, llvm::ISD::SIGN_EXTEND_INREG, and llvm::ISD::ZERO_EXTEND.

Referenced by AreMulWideOperandsDemotable(), and TryMULWIDECombine().

◆ isNonCoalescableBuildVector()

bool isNonCoalescableBuildVector ( const SDValue & BV)
static

Check if a v2f32 BUILD_VECTOR provably packs values from non-adjacent register pairs (non-coalescable).

Definition at line 6370 of file NVPTXISelLowering.cpp.

References llvm::ISD::BUILD_VECTOR, llvm::dyn_cast(), llvm::ISD::EXTRACT_VECTOR_ELT, llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), and llvm::SDValue::getValueType().

◆ IsPTXVectorType()

bool IsPTXVectorType ( MVT VT)
static

◆ isSupportedFPArith()

◆ joinSPRegs()

◆ lowerAtomicStore128()

◆ lowerBSWAP()

◆ LowerClusterLaunchControlQueryCancel()

◆ lowerCTLZCTPOP()

◆ lowerCvtRSIntrinsics()

◆ lowerFPTRUNC_ROUND()

◆ lowerFSH()

SDValue lowerFSH ( SDValue Op,
SelectionDAG & DAG )
static

Definition at line 3498 of file NVPTXISelLowering.cpp.

References expandFSH64().

Referenced by llvm::NVPTXTargetLowering::LowerOperation().

◆ lowerIntrinsicVoid()

◆ lowerIntrinsicWChain()

SDValue lowerIntrinsicWChain ( SDValue Op,
SelectionDAG & DAG )
static

◆ lowerIntrinsicWOChain()

◆ lowerLOADi1()

◆ lowerLoadVector()

SDValue lowerLoadVector ( SDNode * N,
SelectionDAG & DAG,
const NVPTXSubtarget & STI )
static

Definition at line 4036 of file NVPTXISelLowering.cpp.

References llvm::SelectionDAG::getMergeValues(), N, replaceLoadVector(), and SDValue().

Referenced by combineLOAD().

◆ lowerMSTORE()

◆ lowerMUL_LOHI()

◆ lowerPrmtIntrinsic()

◆ lowerROT()

SDValue lowerROT ( SDValue Op,
SelectionDAG & DAG )
static

◆ lowerSELECT()

◆ lowerSPIntrinsic()

◆ lowerStAsyncRelease()

◆ lowerStAsyncWithMbarrier()

◆ lowerSTOREVector()

◆ lowerTcgen05Ld()

◆ lowerTcgen05LdRed()

◆ LowerTcgen05MMADisableOutputLane()

◆ lowerTcgen05St()

◆ lowerTensormapReplaceElemtype()

◆ lowerTensormapReplaceSwizzleMode()

◆ LowerVectorArith()

◆ matchMADConstOnePattern()

SDValue matchMADConstOnePattern ( SDValue Add)
static

◆ PerformADDCombine()

SDValue PerformADDCombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI,
CodeGenOptLevel OptLevel )
static

PerformADDCombine - Target-specific dag combine xforms for ISD::ADD.

Definition at line 6346 of file NVPTXISelLowering.cpp.

References llvm::SDValue::getValueType(), llvm::EVT::isVector(), N, llvm::None, PerformADDCombineWithOperands(), and SDValue().

◆ PerformADDCombineWithOperands()

SDValue PerformADDCombineWithOperands ( SDNode * N,
SDValue N0,
SDValue N1,
TargetLowering::DAGCombinerInfo & DCI )
static

PerformADDCombineWithOperands - Try DAG combinations for an ADD with operands N0 and N1.

This is a helper for PerformADDCombine that is called with the default operands, and if that fails, with commuted operands.

Definition at line 5994 of file NVPTXISelLowering.cpp.

References llvm::ISD::ADD, llvm::TargetLowering::DAGCombinerInfo::DAG, DL, llvm::SDValue::getNode(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDNode::getOperand(), llvm::SelectionDAG::getSelect(), llvm::SDValue::getValueType(), llvm::SDNode::hasOneUse(), isConstZero(), llvm::ISD::MUL, Mul, N, SDValue(), and llvm::ISD::SELECT.

◆ PerformBUILD_VECTORCombine()

◆ PerformEXTRACTCombine()

◆ PerformFMinMaxCombine()

SDValue PerformFMinMaxCombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI,
const NVPTXSubtarget & STI )
static

PerformFMinMaxCombine - Combine (fmaxnum (fmaxnum a, b), c) into (fmaxnum3 a, b, c).

Also covers other llvm min/max intrinsics.

Definition at line 6561 of file NVPTXISelLowering.cpp.

References A(), B(), C(), llvm::TargetLowering::DAGCombinerInfo::DAG, getMinMax3Opcode(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SDValue::hasOneUse(), N, and SDValue().

◆ PerformMULCombine()

SDValue PerformMULCombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI,
CodeGenOptLevel OptLevel )
static

PerformMULCombine - Runs PTX-specific DAG combine patterns on MUL nodes.

Definition at line 6880 of file NVPTXISelLowering.cpp.

References N, llvm::None, PerformMULCombineWithOperands(), SDValue(), and TryMULWIDECombine().

◆ PerformMULCombineWithOperands()

SDValue PerformMULCombineWithOperands ( SDNode * N,
SDValue N0,
SDValue N1,
TargetLowering::DAGCombinerInfo & DCI )
static

◆ PerformSELECTShiftCombine()

SDValue PerformSELECTShiftCombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

Transform patterns like: (select (ugt shift_amt, BitWidth-1), 0, (srl/shl x, shift_amt)) (select (ult shift_amt, BitWidth), (srl/shl x, shift_amt), 0) Into: (NVPTXISD::SRL_CLAMP x, shift_amt) or (NVPTXISD::SHL_CLAMP x, shift_amt)

These patterns arise from code like s >= 32 ? 0 : x >> s. In LLVM, over-shifting a value results in poison, but PTX shr/shl instructions clamp the shift amount to BitWidth, making the guard redundant.

Note: We only handle SRL and SHL, not SRA, because arithmetic right shifts can produce 0 or -1 when shift >= BitWidth. Note: We don't handle uge or ule. These don't appear because of canonicalization.

Definition at line 7127 of file NVPTXISelLowering.cpp.

References llvm::BitWidth, llvm::SelectionDAG::computeKnownBits(), llvm::KnownBits::countMaxActiveBits(), llvm::TargetLowering::DAGCombinerInfo::DAG, llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SDValue::getValueSizeInBits(), llvm::SDValue::getValueType(), llvm::TargetLowering::DAGCombinerInfo::isAfterLegalizeDAG(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), N, SDValue(), llvm::ISD::SETUGT, llvm::ISD::SETULT, and llvm::ISD::SRL.

◆ PerformSETCCCombine()

◆ PerformSHLCombine()

SDValue PerformSHLCombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI,
CodeGenOptLevel OptLevel )
static

PerformSHLCombine - Runs PTX-specific DAG combine patterns on SHL nodes.

Definition at line 7019 of file NVPTXISelLowering.cpp.

References combineShiftOfLogicOp(), N, llvm::None, SDValue(), and TryMULWIDECombine().

◆ PerformVSELECTCombine()

◆ PromoteBinOpToF32()

◆ promoteScalarIntegerPTX()

EVT promoteScalarIntegerPTX ( const EVT VT)
static

PromoteScalarIntegerPTX Used to make sure the arguments/returns are suitable for passing and promote them to a larger size if they're not.

The promoted type is placed in PromoteVT if the function returns true.

Definition at line 363 of file NVPTXISelLowering.cpp.

References llvm::EVT::getFixedSizeInBits(), llvm::EVT::isScalarInteger(), llvm_unreachable, and llvm::PowerOf2Ceil().

Referenced by llvm::NVPTXTargetLowering::LowerCall(), and llvm::NVPTXTargetLowering::LowerReturn().

◆ refinePtrAS()

◆ replaceAtomicLoad128()

◆ replaceAtomicSwap128()

◆ ReplaceBITCAST()

◆ ReplaceCopyFromReg_128()

void ReplaceCopyFromReg_128 ( SDNode * N,
SelectionDAG & DAG,
SmallVectorImpl< SDValue > & Results )
static

◆ ReplaceINTRINSIC_W_CHAIN()

◆ replaceLoadVector() [1/2]

◆ replaceLoadVector() [2/2]

void replaceLoadVector ( SDNode * N,
SelectionDAG & DAG,
SmallVectorImpl< SDValue > & Results,
const NVPTXSubtarget & STI )
static

Definition at line 4029 of file NVPTXISelLowering.cpp.

References N, replaceLoadVector(), and Results.

◆ replaceProxyReg()

◆ reportInvalidTensormapReplaceUsage()

◆ simplifyDemandedBitsForPRMT()

◆ sinkProxyReg()

◆ TryMULWIDECombine()

SDValue TryMULWIDECombine ( SDNode * N,
TargetLowering::DAGCombinerInfo & DCI )
static

TryMULWIDECombine - Attempt to replace a multiply of M bits with a multiply of M/2 bits that produces an M-bit result (i.e.

mul.wide). This transform works on both multiply DAG nodes and SHL DAG nodes with a constant shift amount.

Definition at line 6710 of file NVPTXISelLowering.cpp.

References AreMulWideOperandsDemotable(), llvm::BitWidth, llvm::TargetLowering::DAGCombinerInfo::DAG, DL, llvm::dyn_cast(), llvm::ConstantSDNode::getAPIntValue(), llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getNodeIfExists(), llvm::EVT::getSizeInBits(), llvm::Hi, llvm::isa(), IsExtendedFromLte(), LHS, llvm::ISD::MUL, llvm::ISD::MULHS, llvm::ISD::MULHU, N, Opc, RHS, SDValue(), llvm::APInt::sge(), llvm::ISD::SHL, llvm::Signed, llvm::APInt::slt(), std::swap(), and llvm::ISD::TRUNCATE.

Referenced by PerformMULCombine(), and PerformSHLCombine().

◆ VectorizePTXValueVTs()