[llvm-dev] canonical form loops

Sjoerd Meijer via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 27 09:38:51 PDT 2020

Hi Eli,

Thanks for commenting. From your reply I understand it would probably be better not to add more logic to indvars. I see that this has the advantage of this pass not making any changes where this is possibly undesired. For the same reason, LoopSimplify, possibly another candidate for this, would not be a good idea. Thus a more focused approach is a new pass run just before the vectoriser, or very similar a helper added to LoopUtils invoked from the vectoriser, to bring loops in a canonical form.

From: Eli Friedman <efriedma at quicinc.com>
Sent: 26 March 2020 22:07
To: Sjoerd Meijer <Sjoerd.Meijer at arm.com>; llvm-dev <llvm-dev at lists.llvm.org>
Subject: RE: [llvm-dev] canonical form loops

LLVM used to rewrite the induction variable in indvars, but we stopped doing it a long time ago.  If I recall correctly, it made the generated code worse in some cases, without any clear benefit.


From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Sjoerd Meijer via llvm-dev
Sent: Thursday, March 26, 2020 1:56 PM
To: llvm-dev at lists.llvm.org
Subject: [EXT] [llvm-dev] canonical form loops


Quick question to see if I haven't missed anything: I would like convert counting down loops, i.e. loops with a constant -1 step value, to counting up loops, because the vectoriser is able to better deal with these loops (see e.g. D76838 that I was discussing today with Ayal). It looks like LoopSimplifyCFG and IndVarSimplify don't do this. So was just curious if I haven't missed anything here or in another pass I haven't yet considered. I was perhaps also expecting this to be the canonical form of loops, but couldn't find any evidence of that in [1] or in source-code.

The obvious follow-up question is if there would be any objections to adding this to e.g. LoopSimplifyCFG, and adding LoopSimplifyCFG to the optimisation pipeline just before the vectoriser.



[1] https://llvm.org/docs/LoopTerminology.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200327/dffb75c4/attachment.html>

More information about the llvm-dev mailing list