LLVM 18.0.0git
Classes | Macros | Functions | Variables
AMDGPUPromoteAlloca.cpp File Reference
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/InstSimplifyFolder.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/IntrinsicsR600.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"

Go to the source code of this file.


struct  MemTransferInfo


#define DEBUG_TYPE   "amdgpu-promote-alloca"


 INITIALIZE_PASS_BEGIN (AMDGPUPromoteAlloca, DEBUG_TYPE, "AMDGPU promote alloca to vector or LDS", false, false) INITIALIZE_PASS_END(AMDGPUPromoteAlloca
static bool isSupportedMemset (MemSetInst *I, AllocaInst *AI, const DataLayout &DL)
static ValuecalculateVectorIndex (Value *Ptr, const std::map< GetElementPtrInst *, Value * > &GEPIdx)
static ValueGEPToVectorIndex (GetElementPtrInst *GEP, AllocaInst *Alloca, Type *VecElemTy, const DataLayout &DL)
static ValuepromoteAllocaUserToVector (Instruction *Inst, const DataLayout &DL, FixedVectorType *VectorTy, unsigned VecStoreSize, unsigned ElementSize, DenseMap< MemTransferInst *, MemTransferInfo > &TransferInfo, std::map< GetElementPtrInst *, Value * > &GEPVectorIdx, Value *CurVal, SmallVectorImpl< LoadInst * > &DeferredLoads)
 Promotes a single user of the alloca to a vector form.
static bool isSupportedAccessType (FixedVectorType *VecTy, Type *AccessTy, const DataLayout &DL)
template<typename InstContainer >
static void forEachWorkListItem (const InstContainer &WorkList, std::function< void(Instruction *)> Fn)
 Iterates over an instruction worklist that may contain multiple instructions from the same basic block, but in a different order.
static bool isCallPromotable (CallInst *CI)


AMDGPU promote alloca to vector or LDS
AMDGPU promote alloca to vector or false

Macro Definition Documentation


#define DEBUG_TYPE   "amdgpu-promote-alloca"

Definition at line 46 of file AMDGPUPromoteAlloca.cpp.

Function Documentation

◆ calculateVectorIndex()

static Value * calculateVectorIndex ( Value Ptr,
const std::map< GetElementPtrInst *, Value * > &  GEPIdx 

◆ forEachWorkListItem()

template<typename InstContainer >
static void forEachWorkListItem ( const InstContainer &  WorkList,
std::function< void(Instruction *)>  Fn 

Iterates over an instruction worklist that may contain multiple instructions from the same basic block, but in a different order.

Definition at line 567 of file AMDGPUPromoteAlloca.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().

◆ GEPToVectorIndex()

static Value * GEPToVectorIndex ( GetElementPtrInst GEP,
AllocaInst Alloca,
Type VecElemTy,
const DataLayout DL 


"AMDGPU promote alloca to vector or LDS"  ,
false  ,

◆ isCallPromotable()

static bool isCallPromotable ( CallInst CI)

Definition at line 984 of file AMDGPUPromoteAlloca.cpp.

References llvm::IntrinsicInst::getIntrinsicID().

◆ isSupportedAccessType()

static bool isSupportedAccessType ( FixedVectorType VecTy,
Type AccessTy,
const DataLayout DL 

◆ isSupportedMemset()

static bool isSupportedMemset ( MemSetInst I,
AllocaInst AI,
const DataLayout DL 

◆ promoteAllocaUserToVector()

static Value * promoteAllocaUserToVector ( Instruction Inst,
const DataLayout DL,
FixedVectorType VectorTy,
unsigned  VecStoreSize,
unsigned  ElementSize,
DenseMap< MemTransferInst *, MemTransferInfo > &  TransferInfo,
std::map< GetElementPtrInst *, Value * > &  GEPVectorIdx,
Value CurVal,
SmallVectorImpl< LoadInst * > &  DeferredLoads 

Promotes a single user of the alloca to a vector form.

InstInstruction to be promoted.
DLModule Data Layout.
VectorTyVectorized Type.
VecStoreSizeSize of VectorTy in bytes.
ElementSizeSize of VectorTy element type in bytes.
TransferInfoMemTransferInst info map.
GEPVectorIdxGEP -> VectorIdx cache.
CurValCurrent value of the vector (e.g. last stored value)
[out]DeferredLoadsInst is added to this vector if it can't be promoted now. This happens when promoting requires CurVal, but CurVal is nullptr.
the stored value if Inst would have written to the alloca, or nullptr otherwise.

Definition at line 348 of file AMDGPUPromoteAlloca.cpp.

References assert(), Builder, calculateVectorIndex(), MemTransferInfo::DestIndex, DL, llvm::FixedVectorType::get(), llvm::PoisonValue::get(), llvm::Value::getContext(), llvm::VectorType::getElementCount(), llvm::VectorType::getElementType(), llvm::FixedVectorType::getNumElements(), llvm::Instruction::getOpcode(), llvm::getPointerOperand(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), Idx, llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isKnownMultipleOf(), llvm::Type::isPtrOrPtrVectorTy(), llvm::Length, llvm_unreachable, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), Size, and MemTransferInfo::SrcIndex.

Variable Documentation



Definition at line 189 of file AMDGPUPromoteAlloca.cpp.

◆ false

AMDGPU promote alloca to vector or false

Definition at line 190 of file AMDGPUPromoteAlloca.cpp.


AMDGPU promote alloca to vector or LDS