[LLVMdev] Rotated loop identification
Michele Scandale
michele.scandale at gmail.com
Fri Feb 8 00:49:17 PST 2013
On 02/08/2013 06:56 AM, Andrew Trick wrote:
> There's been talk of adding metata do the branch that terminates the loop latch block. What llvm calls the "latch" is just a unique backward branch to the loop header and not necessarilly even a loop exit.
>
> I'm not sure how you would interpret that metadata, since the branch exit may be rewritten (just like the loop guard). For example, the indvars pass may convert it into a != test.
>
> As long as this is brainstorming time, I actually like the idea of an llvm.invariant intrinsic that the optimizers know to ignore. I like it for other purposes, but would happen to work for you as a temporary workaround. It could take one or two IR values (as metadata operands) and a metadata language describing the invariant, such as a relational operator and optional constant. In your case, you want to know that the loop counter's starting value is less than its limit, so you could conveniently plop one of those in the loop preheader. The invariant would only go away if no one else used the value, which in your case would make sense (e.g. if the loop test were rewritten in terms of %b, you probably wouldn't need the invariant any more).
>
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121210/158601.html
>
I read the post you suggested. If I understood correctly the idea I like it very
much. Just to better understand, when you say <<< It would be generally useful
to model an intrinsic that is free and not a strong use but does have control
dependence. That's what I call a meta-intrinsic. >>> you mean that this class of
intrinsics cannot be removed because they have no uses and the can't be moved
freely, e.g. hoisted from a loop?
Indeed, if they handle a value (they are users), that value would never be
eliminated if the only user is the meta-intrinsic itself? Maybe this kind of
behaviour must be a parameter respect to the semantic you need to implement (At
the end, if the intrinsic is the only user and during lowering is simply
eliminated all the values used can be checked to be dead and deleted in that case).
IMHO this is like a property that an intrinsic can have or not and the proposed
llvm.invariant intrinsic is a particular intrinsic that has this property and
whose semantic is to describe invariant facts (the metadata language you mentioned).
Thanks again.
Best regards,
Michele Scandale
More information about the llvm-dev
mailing list