LLVM 22.0.0git
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/LoopInfo.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/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "amdgpu-promote-alloca"

Functions

 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, AllocaAnalysis &AA)
static std::optional< GEPToVectorIndex > computeGEPToVectorIndex (GetElementPtrInst *GEP, AllocaInst *Alloca, Type *VecElemTy, const DataLayout &DL)
static ValuepromoteAllocaUserToVector (Instruction *Inst, const DataLayout &DL, AllocaAnalysis &AA, unsigned VecStoreSize, unsigned ElementSize, function_ref< Value *()> GetCurVal)
 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 BasicBlock::iterator skipToNonAllocaInsertPt (BasicBlock &BB, BasicBlock::iterator I)
 Find an insert point after an alloca, after all other allocas clustered at the start of the block.
static bool isCallPromotable (CallInst *CI)

Variables

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

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpu-promote-alloca"

Definition at line 48 of file AMDGPUPromoteAlloca.cpp.

Function Documentation

◆ calculateVectorIndex()

Value * calculateVectorIndex ( Value * Ptr,
AllocaAnalysis & AA )
static

◆ computeGEPToVectorIndex()

◆ forEachWorkListItem()

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

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

Definition at line 820 of file AMDGPUPromoteAlloca.cpp.

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

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( AMDGPUPromoteAlloca ,
DEBUG_TYPE ,
"AMDGPU promote alloca to vector or LDS" ,
false ,
false  )

◆ isCallPromotable()

bool isCallPromotable ( CallInst * CI)
static

Definition at line 1274 of file AMDGPUPromoteAlloca.cpp.

References llvm::dyn_cast(), and II.

◆ isSupportedAccessType()

◆ isSupportedMemset()

◆ promoteAllocaUserToVector()

Value * promoteAllocaUserToVector ( Instruction * Inst,
const DataLayout & DL,
AllocaAnalysis & AA,
unsigned VecStoreSize,
unsigned ElementSize,
function_ref< Value *()> GetCurVal )
static

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

Parameters
InstInstruction to be promoted.
DLModule Data Layout.
AAAlloca Analysis.
VecStoreSizeSize of VectorTy in bytes.
ElementSizeSize of VectorTy element type in bytes.
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.
Returns
the stored value if Inst would have written to the alloca, or nullptr otherwise.

Definition at line 591 of file AMDGPUPromoteAlloca.cpp.

References assert(), calculateVectorIndex(), llvm::cast(), DL, llvm::dyn_cast(), llvm::FixedVectorType::get(), llvm::PoisonValue::get(), llvm::Value::getContext(), llvm::Type::getIntNTy(), getNumElements(), llvm::Instruction::getOpcode(), llvm::getPointerOperand(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), llvm::isa(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isKnownMultipleOf(), llvm::Type::isPointerTy(), llvm::Type::isPtrOrPtrVectorTy(), llvm::Length, llvm_unreachable, llvm::PoisonMaskElem, llvm::Value::replaceAllUsesWith(), and Size.

◆ skipToNonAllocaInsertPt()

BasicBlock::iterator skipToNonAllocaInsertPt ( BasicBlock & BB,
BasicBlock::iterator I )
static

Find an insert point after an alloca, after all other allocas clustered at the start of the block.

Definition at line 858 of file AMDGPUPromoteAlloca.cpp.

References E(), llvm::BasicBlock::end(), I, and llvm::isa().

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 242 of file AMDGPUPromoteAlloca.cpp.

◆ false

AMDGPU promote alloca to vector or false

Definition at line 243 of file AMDGPUPromoteAlloca.cpp.

◆ LDS

AMDGPU promote alloca to vector or LDS

Definition at line 243 of file AMDGPUPromoteAlloca.cpp.