32#include "llvm/IR/IntrinsicsAMDGPU.h"
38#define DEBUG_TYPE "amdgpu-uniform-intrinsic-combine"
50 if (
auto It = Tracker.
find(V); It != Tracker.
end())
64 case Intrinsic::amdgcn_permlane64:
65 case Intrinsic::amdgcn_readlane: {
66 Value *Src =
II.getArgOperand(0);
70 II.replaceAllUsesWith(Src);
74 case Intrinsic::amdgcn_ballot: {
75 Value *Src =
II.getArgOperand(0);
83 Value *Op0 = ICmp->getOperand(0);
84 Value *Op1 = ICmp->getOperand(1);
86 Value *OtherOp = Op0 == &
II ? Op1 : Op0;
92 Tracker[NotOp] =
true;
94 ICmp->replaceAllUsesWith(NotOp);
100 ICmp->replaceAllUsesWith(Src);
107 II.eraseFromParent();
118 bool IsChanged =
false;
143class AMDGPUUniformIntrinsicCombineLegacy :
public FunctionPass {
161char AMDGPUUniformIntrinsicCombineLegacy::ID = 0;
163 AMDGPUUniformIntrinsicCombineLegacy::ID;
165bool AMDGPUUniformIntrinsicCombineLegacy::runOnFunction(
Function &
F) {
169 getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo();
174 "AMDGPU Uniform Intrinsic Combine",
false,
false)
181 return new AMDGPUUniformIntrinsicCombineLegacy();
Expand Atomic instructions
static bool runOnFunction(Function &F, bool PostInlining)
AMD GCN specific subclass of TargetSubtarget.
uint64_t IntrinsicInst * II
#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)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
A wrapper class for inspecting calls to intrinsic functions.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
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 & preserve()
Mark an analysis as preserved.
Target-Independent Code Generator Pass Configuration Options.
A Use represents the edge between a Value definition and its users.
iterator find(const KeyT &Val)
LLVM Value Representation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool match(Val *V, const Pattern &P)
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
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.
void initializeAMDGPUUniformIntrinsicCombineLegacyPass(PassRegistry &)
char & AMDGPUUniformIntrinsicCombineLegacyPassID
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.