LLVM 24.0.0git
AMDGPUUniformIntrinsicCombine.cpp File Reference

This pass simplifies certain intrinsic calls when the arguments are uniform. More...

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

Detailed Description

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.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpu-uniform-intrinsic-combine"

Definition at line 35 of file AMDGPUUniformIntrinsicCombine.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( AMDGPUUniformIntrinsicCombineLegacy ,
DEBUG_TYPE ,
"AMDGPU Uniform Intrinsic Combine" ,
false ,
false  )

◆ optimizeUniformCmpReadFirstLane()

◆ optimizeUniformIntrinsic()

bool optimizeUniformIntrinsic ( IntrinsicInst & II,
UniformityInfo & UI )
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().

◆ runUniformIntrinsicCombine()

bool runUniformIntrinsicCombine ( Function & F,
UniformityInfo & UI )
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().

Variable Documentation

◆ Combine

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 212 of file AMDGPUUniformIntrinsicCombine.cpp.

◆ false

AMDGPU Uniform Intrinsic false

Definition at line 213 of file AMDGPUUniformIntrinsicCombine.cpp.