LLVM 22.0.0git
|
This pass simplifies certain intrinsic calls when the arguments are uniform. More...
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/UniformityAnalysis.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "amdgpu-uniform-intrinsic-combine" |
Functions | |
static bool | isDivergentUseWithNew (const Use &U, const UniformityInfo &UI, const ValueMap< const Value *, bool > &Tracker) |
Wrapper for querying uniformity info that first checks locally tracked instructions. | |
static bool | optimizeUniformIntrinsic (IntrinsicInst &II, const UniformityInfo &UI, ValueMap< const Value *, bool > &Tracker) |
Optimizes uniform intrinsics calls if their operand can be proven uniform. | |
static bool | runUniformIntrinsicCombine (Module &M, ModuleAnalysisManager &AM) |
Iterates over intrinsic declarations in the module to optimize their uses. |
This pass simplifies certain intrinsic calls when the arguments are uniform.
It's true that this pass has transforms that can lead to a situation where some instruction whose operand was previously recognized as statically uniform is later on no longer recognized as statically uniform. However, the semantics of how programs execute don't (and must not, for this precise reason) care about static uniformity, they only ever care about dynamic uniformity. And every instruction that's downstream and cares about dynamic uniformity must be convergent (and isel will introduce v_readfirstlane for them if their operands can't be proven statically uniform).
This pass is implemented as a ModulePass because intrinsic declarations exist at the module scope, allowing us to skip processing entirely if no declarations are present and to traverse their user lists directly when they are. A FunctionPass would instead require scanning every instruction in every function to find relevant intrinsics, which is far less efficient.
Definition in file AMDGPUUniformIntrinsicCombine.cpp.
#define DEBUG_TYPE "amdgpu-uniform-intrinsic-combine" |
Definition at line 44 of file AMDGPUUniformIntrinsicCombine.cpp.
|
static |
Wrapper for querying uniformity info that first checks locally tracked instructions.
Definition at line 53 of file AMDGPUUniformIntrinsicCombine.cpp.
References llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::ValueMap< KeyT, ValueT, Config >::find(), and llvm::GenericUniformityInfo< ContextT >::isDivergentUse().
Referenced by optimizeUniformIntrinsic().
|
static |
Optimizes uniform intrinsics calls if their operand can be proven uniform.
Definition at line 62 of file AMDGPUUniformIntrinsicCombine.cpp.
References Changed, llvm::BinaryOperator::CreateNot(), llvm::dbgs(), llvm::dyn_cast(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, II, isDivergentUseWithNew(), LLVM_DEBUG, llvm_unreachable, llvm::PatternMatch::m_Zero(), llvm::make_early_inc_range(), and llvm::PatternMatch::match().
Referenced by runUniformIntrinsicCombine().
|
static |
Iterates over intrinsic declarations in the module to optimize their uses.
Definition at line 124 of file AMDGPUUniformIntrinsicCombine.cpp.
References llvm::cast(), F, FAM, llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult(), II, llvm::make_early_inc_range(), and optimizeUniformIntrinsic().
Referenced by llvm::AMDGPUUniformIntrinsicCombinePass::run().