-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[AMDGPU] Enable "amdgpu-uniform-intrinsic-combine" pass in pipeline. #162819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9259485
d92fd81
920ffc4
388b593
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,13 +141,73 @@ static bool runUniformIntrinsicCombine(Module &M, ModuleAnalysisManager &AM) { | |
for (User *U : make_early_inc_range(F.users())) { | ||
auto *II = cast<IntrinsicInst>(U); | ||
Function *ParentF = II->getFunction(); | ||
if (ParentF->hasFnAttribute(Attribute::OptimizeNone)) | ||
continue; | ||
const auto &UI = FAM.getResult<UniformityInfoAnalysis>(*ParentF); | ||
IsChanged |= optimizeUniformIntrinsic(*II, UI, Tracker); | ||
} | ||
} | ||
return IsChanged; | ||
} | ||
|
||
// Legacy PM version | ||
static bool runUniformIntrinsicCombine(Module &M, ModulePass &P) { | ||
bool IsChanged = false; | ||
ValueMap<const Value *, bool> Tracker; | ||
|
||
for (Function &F : M) { | ||
switch (F.getIntrinsicID()) { | ||
case Intrinsic::amdgcn_permlane64: | ||
case Intrinsic::amdgcn_readfirstlane: | ||
case Intrinsic::amdgcn_readlane: | ||
case Intrinsic::amdgcn_ballot: | ||
break; | ||
default: | ||
continue; | ||
} | ||
|
||
for (User *U : make_early_inc_range(F.users())) { | ||
auto *II = cast<IntrinsicInst>(U); | ||
Function *ParentF = II->getFunction(); | ||
if (ParentF->hasFnAttribute(Attribute::OptimizeNone)) | ||
continue; | ||
auto &UI = P.getAnalysis<UniformityInfoWrapperPass>(*ParentF) | ||
.getUniformityInfo(); | ||
IsChanged |= optimizeUniformIntrinsic(*II, UI, Tracker); | ||
} | ||
} | ||
return IsChanged; | ||
} | ||
|
||
namespace { | ||
class AMDGPUUniformIntrinsicCombineLegacy : public ModulePass { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This belongs with the base support PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its ok to have separately. Initially, it was part of the base PR. after reviews I dropped it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should have gone there, and the IR test needs both new and old PM run lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OPM is really not required as such, as both the pipeline OPT supports NPM by default, and very soon backend will also be default NPM. This is just for temporary until we do not have NPM support in LLC. |
||
public: | ||
static char ID; | ||
AMDGPUUniformIntrinsicCombineLegacy() : ModulePass(ID) { | ||
initializeAMDGPUUniformIntrinsicCombineLegacyPass( | ||
*PassRegistry::getPassRegistry()); | ||
} | ||
|
||
private: | ||
bool runOnModule(Module &M) override; | ||
void getAnalysisUsage(AnalysisUsage &AU) const override { | ||
AU.setPreservesCFG(); | ||
AU.addRequired<UniformityInfoWrapperPass>(); | ||
AU.addRequired<TargetPassConfig>(); | ||
} | ||
}; | ||
} // namespace | ||
|
||
char AMDGPUUniformIntrinsicCombineLegacy::ID = 0; | ||
char &llvm::AMDGPUUniformIntrinsicCombineLegacyPassID = | ||
AMDGPUUniformIntrinsicCombineLegacy::ID; | ||
|
||
bool AMDGPUUniformIntrinsicCombineLegacy::runOnModule(Module &M) { | ||
if (skipModule(M)) | ||
return false; | ||
return runUniformIntrinsicCombine(M, *this); | ||
} | ||
|
||
PreservedAnalyses | ||
AMDGPUUniformIntrinsicCombinePass::run(Module &M, ModuleAnalysisManager &AM) { | ||
if (!runUniformIntrinsicCombine(M, AM)) | ||
|
@@ -157,3 +217,14 @@ AMDGPUUniformIntrinsicCombinePass::run(Module &M, ModuleAnalysisManager &AM) { | |
PA.preserve<UniformityInfoAnalysis>(); | ||
return PA; | ||
} | ||
|
||
INITIALIZE_PASS_BEGIN(AMDGPUUniformIntrinsicCombineLegacy, DEBUG_TYPE, | ||
"AMDGPU Uniform Intrinsic Combine", false, false) | ||
INITIALIZE_PASS_DEPENDENCY(UniformityInfoWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) | ||
INITIALIZE_PASS_END(AMDGPUUniformIntrinsicCombineLegacy, DEBUG_TYPE, | ||
"AMDGPU Uniform Intrinsic Combine", false, false) | ||
|
||
ModulePass *llvm::createAMDGPUUniformIntrinsicCombineLegacyPass() { | ||
return new AMDGPUUniformIntrinsicCombineLegacy(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still running on optnone functions, another issue with doing this as a module pass
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a simple check over
ParentF->hasFnAttribute(Attribute::OptimizeNone)
should be sufficient here?