29#include "llvm/IR/IntrinsicsAMDGPU.h"
35#define DEBUG_TYPE "amdgpu-uniform-intrinsic-combine"
48 case Intrinsic::amdgcn_permlane64:
49 case Intrinsic::amdgcn_readlane: {
50 Value *Src =
II.getArgOperand(0);
54 II.replaceAllUsesWith(Src);
59 case Intrinsic::amdgcn_ballot: {
60 Value *Src =
II.getArgOperand(0);
68 Value *Op0 = ICmp->getOperand(0);
69 Value *Op1 = ICmp->getOperand(1);
71 Value *OtherOp = Op0 == &
II ? Op1 : Op0;
78 ICmp->replaceAllUsesWith(NotOp);
84 ICmp->replaceAllUsesWith(Src);
97 case Intrinsic::amdgcn_wave_shuffle: {
98 Use &Val =
II.getOperandUse(0);
103 II.replaceAllUsesWith(Val);
105 II.eraseFromParent();
117 Mod, Intrinsic::amdgcn_readlane,
II.getType()));
143 LLVM_DEBUG(
dbgs() <<
"Uniform readfirstlane operand, replacing " << Cmp
144 <<
" with " << (Holds ?
"true" :
"false") <<
'\n');
145 Cmp.replaceAllUsesWith(ConstantInt::get(Cmp.getType(), Holds));
147 Cmp.eraseFromParent();
154 bool IsChanged =
false;
181class AMDGPUUniformIntrinsicCombineLegacy :
public FunctionPass {
184 AMDGPUUniformIntrinsicCombineLegacy() :
FunctionPass(ID) {}
196char AMDGPUUniformIntrinsicCombineLegacy::ID = 0;
198 AMDGPUUniformIntrinsicCombineLegacy::ID;
200bool AMDGPUUniformIntrinsicCombineLegacy::runOnFunction(
Function &
F) {
204 getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo();
209 "AMDGPU Uniform Intrinsic Combine",
false,
false)
216 return new AMDGPUUniformIntrinsicCombineLegacy();
Expand Atomic instructions
static bool runOnFunction(Function &F, bool PostInlining)
uint64_t IntrinsicInst * II
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Target-Independent Code Generator Pass Configuration Options pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
static LLVM_ABI BinaryOperator * CreateNot(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Represents analyses that only rely on functions' control flow.
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
bool isTrueWhenEqual() const
This is just a convenience.
FunctionPass class - This class is used to implement most global optimizations.
This instruction compares its operands according to the predicate given to the constructor.
A wrapper class for inspecting calls to intrinsic functions.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Target-Independent Code Generator Pass Configuration Options.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
match_combine_and< Ty... > m_CombineAnd(const Ty &...Ps)
Combine pattern matchers matching all of Ps patterns.
bool match(Val *V, const Pattern &P)
match_deferred< Value > m_Deferred(Value *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
CmpClass_match< LHS, RHS, ICmpInst, true > m_c_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
Matches an ICmp with a predicate over LHS and RHS in either order.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_AnyIntrinsic()
Matches any intrinsic call and ignore it.
is_zero< true > m_Zero()
Match any null constant or a vector with all elements equal to 0.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createAMDGPUUniformIntrinsicCombineLegacyPass()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
char & AMDGPUUniformIntrinsicCombineLegacyPassID
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.