[PATCH] D158147: [RFC][GlobalISel] convergence control tokens and intrinsics

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 01:47:54 PDT 2023


sameerds added a subscriber: cdevadas.
sameerds added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:122
 
-  if (isa<GIntrinsic>(MI))
+  if (auto *GI = dyn_cast<GIntrinsic>(&MI)) {
+    auto ID = GI->getIntrinsicID();
----------------
sameerds wrote:
> arsenm wrote:
> > sameerds wrote:
> > > arsenm wrote:
> > > > Wait, why is this here? Generic intrinsics shouldn't reach the legalizer, they should go through G_* instruction wrappers. If your intention was to default legalize to erase, those should be just in the default lower action
> > > I don't understand, mostly because I am quite unfamiliar with the backend. But in GlobalISel.cpp, the legalizer comes before selection. So this definitely hits the legalizer? By "default lower action", you mean somewhere in `InstructionSelect::runOnMachineFunction()` before it calls the target-specific virtual function `InstructionSelector::select()`?
> > The legalizer shouldn't need to specially intercept intrinsics. A generic intrinsic should not pass the IRTranslator. These should be swapped to new G_* instructions which the ordinary legalizer can express rules. The default lower action for them can be to just erase (or we can let these pass to selection)
> > The legalizer shouldn't need to specially intercept intrinsics. A generic intrinsic should not pass the IRTranslator.
> 
> That is confusing still. Isn't `MachineIRBuilder::buildIntrinsic()` how LLVM IR intrinsics get translated to G_INTRINSIC instances in GMIR?
> 
> > These should be swapped to new G_* instructions which the ordinary legalizer can express rules. The default lower action for them can be to just erase (or we can let these pass to selection)
> 
> What I am looking for is a place that is common to all targets, where the convergence control intrinsics can be erased just before or during selection. Until that point, the G_INTRINSIC instances of the convergence control intrinsics is how tokens are produced in GMIR. The legalizer is very close to such a point. Why is it that the legalizer can express rules for G_* opcodes but not generic intrinsics?
> 
> Separately, I don't think there is value in creating new G_* opcodes for these intrinsics (yet).
> That is confusing still. 
> 
> What I am looking for is a place that is common to all targets, where the convergence control intrinsics can be erased just before or during selection. Until that point, the G_INTRINSIC instances of the convergence control intrinsics is how tokens are produced in GMIR. The legalizer is very close to such a point. Why is it that the legalizer can express rules for G_* opcodes but not generic intrinsics?

Never mind! I spent some time looking at how GlobalISel works with help from @cdevadas , and I think I have some idea of what to do with tokens. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158147/new/

https://reviews.llvm.org/D158147



More information about the llvm-commits mailing list