|
LLVM 24.0.0git
|
This pass simplifies certain intrinsic calls when the arguments are uniform. More...
#include "AMDGPU.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/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 | optimizeUniformIntrinsic (IntrinsicInst &II, UniformityInfo &UI) |
| Optimizes uniform intrinsics calls if their operand can be proven uniform. | |
| static bool | optimizeUniformCmpReadFirstLane (ICmpInst &Cmp, UniformityInfo &UI) |
| Fold icmp pred (readfirstlane X), X when X is uniform at that use. | |
| static bool | runUniformIntrinsicCombine (Function &F, UniformityInfo &UI) |
| Iterates over the Function, optimizing uniform intrinsic calls and comparisons against a readfirstlane of a uniform value. | |
| INITIALIZE_PASS_BEGIN (AMDGPUUniformIntrinsicCombineLegacy, DEBUG_TYPE, "AMDGPU Uniform Intrinsic Combine", false, false) INITIALIZE_PASS_END(AMDGPUUniformIntrinsicCombineLegacy | |
Variables | |
| DEBUG_TYPE | |
| AMDGPU Uniform Intrinsic | Combine |
| AMDGPU Uniform Intrinsic | false |
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).
Definition in file AMDGPUUniformIntrinsicCombine.cpp.
| #define DEBUG_TYPE "amdgpu-uniform-intrinsic-combine" |
Definition at line 35 of file AMDGPUUniformIntrinsicCombine.cpp.
| INITIALIZE_PASS_BEGIN | ( | AMDGPUUniformIntrinsicCombineLegacy | , |
| DEBUG_TYPE | , | ||
| "AMDGPU Uniform Intrinsic Combine" | , | ||
| false | , | ||
| false | ) |
References DEBUG_TYPE, and INITIALIZE_PASS_DEPENDENCY.
|
static |
Fold icmp pred (readfirstlane X), X when X is uniform at that use.
Definition at line 127 of file AMDGPUUniformIntrinsicCombine.cpp.
References llvm::dbgs(), llvm::GenericUniformityInfo< ContextT >::forgetValue(), llvm::CallBase::getArgOperandUse(), llvm::GenericUniformityInfo< ContextT >::isDivergentAtUse(), llvm::CmpInst::isTrueWhenEqual(), LLVM_DEBUG, llvm::PatternMatch::m_AnyIntrinsic(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatchHelpers::m_CombineAnd(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Intrinsic(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by runUniformIntrinsicCombine().
|
static |
Optimizes uniform intrinsics calls if their operand can be proven uniform.
We deliberately do not simplify readfirstlane with a uniform argument, so that frontends can use it to force a copy to SGPR and thereby prevent the backend from generating unwanted waterfall loops.
Definition at line 42 of file AMDGPUUniformIntrinsicCombine.cpp.
References Changed, llvm::BinaryOperator::CreateNot(), llvm::dbgs(), llvm::dyn_cast(), llvm::GenericUniformityInfo< ContextT >::forgetValue(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::AMDGPU::Idx, II, llvm::GenericUniformityInfo< ContextT >::isDivergentAtUse(), LLVM_DEBUG, llvm::PatternMatch::m_Zero(), llvm::make_early_inc_range(), llvm::PatternMatch::match(), Mod, and Pred.
Referenced by runUniformIntrinsicCombine().
|
static |
Iterates over the Function, optimizing uniform intrinsic calls and comparisons against a readfirstlane of a uniform value.
Definition at line 153 of file AMDGPUUniformIntrinsicCombine.cpp.
References llvm::dyn_cast(), F, I, II, instructions, llvm::make_early_inc_range(), optimizeUniformCmpReadFirstLane(), and optimizeUniformIntrinsic().
Referenced by llvm::AMDGPUUniformIntrinsicCombinePass::run().
| AMDGPU Uniform Intrinsic Combine |
Definition at line 213 of file AMDGPUUniformIntrinsicCombine.cpp.
Referenced by llvm::ImutAVLFactory< ImutInfo, Canonicalize >::merge_internal(), llvm::ImutAVLFactory< ImutInfo, Canonicalize >::mergeTrees(), llvm::ImmutableMap< KeyT, ValT, ValInfo, Canonicalize >::Factory::mergeWith(), TOCRestoreNeededForCallToImplementation(), and llvm::ImutAVLFactory< ImutInfo, Canonicalize >::transformTree().
| DEBUG_TYPE |
Definition at line 212 of file AMDGPUUniformIntrinsicCombine.cpp.
| AMDGPU Uniform Intrinsic false |
Definition at line 213 of file AMDGPUUniformIntrinsicCombine.cpp.