[PATCH] D27193: MachineLoopInfo: add function findInductionRegister.

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 08:15:46 PST 2016


SjoerdMeijer added inline comments.


================
Comment at: include/llvm/CodeGen/MachineLoopInfo.h:176
+  /// IVBump is the immediate value added to R, and IVOp is the instruction
+  /// "R = R + #bump".
+  bool findInductionRegister(MachineLoop *L, unsigned &Reg, int64_t &IVBump,
----------------
qcolombet wrote:
> SjoerdMeijer wrote:
> > kparzysz wrote:
> > > qcolombet wrote:
> > > > What do we do we more general representation?
> > > > E.g., R = R * 2
> > > > Or with R = R + RuntimeConstant?
> > > > 
> > > > Basically where I am going is shouldn't we have a representation a la SCEV?
> > > Runtime constants won't work, neither will *=.  This code was meant to get the typical "+= const" patterns.
> > > 
> > > 
> > > Regarding the M-SCEV: yes, we should have it.  What's missing is the time to do it.  :)
> > > 
> > > It's been on my to-do-eventually list, and my idea was to use some sort of a common underlying representation of instructions (i.e. all add instructions for all targets would be represented as a generic "add" instruction). Now that we have GlobalISel, this groundwork is in place, we could develop some sort of a translation scheme from MIR to GIR(?), and then develop SCEV on top of that.
> > Thanks for the reviews.  Yes, I agree, the recognised loops will be simple loops, and thus the approach is not very general, but it could serve some purposes though. Or now that GlobalIsel is being developed, is this technical debt that we don't want to develop further? I haven't followed the development of GlobalIsel close enough, but is it stable enough that we could be looking into SCEVs for machine instructions/GIR?
> GlobalISel simplifies some bits by providing generic opcodes with known semantic, but, by design, GlobalISel allows to mix those with target specific opcodes, so we would still need some way to retrieve the semantic of those.
> 
> Regarding the general approach, I would say this is up to you. I think it make sense to have a SCEV like framework at the machine level, I don't see how that patch helps us toward that goal though.
> 
> I think what we lack is a way to extract semantic from the instructions. GlobalISel partially solves that. The general problem is still open.
> Regarding the general approach, I would say this is up to you.

Well, I am very much interested in your feedback. :-) What I also mean is that I don't want to have this in at all costs, or in other words, if we agree this patch is not going to help in any way then yes let's not waste time and abandon it. The way I could see this useful is that the we anyway need interfaces like this (e.g. findInductionRegister), but the implementation could different, i.e. ad-hoc at the moment, but should be done with proper MI scev analysis in the future. Perhaps this first hacky (but proven?) implementation could serve as reference when the scev analysis is developed? But again, if we think this is not the case let's abandon.
By the way, I am very interested in machine level scev analysis and think I am going to look into it soon.



https://reviews.llvm.org/D27193





More information about the llvm-commits mailing list