[llvm-dev] canonical form loops

Eli Friedman via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 26 15:07:36 PDT 2020


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.

-Eli

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

Hello,

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.

Cheers,
Sjoerd.

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


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


More information about the llvm-dev mailing list