Automatic Vectorization

Hi all,

I've sent it as a reply to another thread, but it was ill placed.
Anyway, sorry about the duplication, but here it goes.

I've been looking into the loop passes and noticed
we do alias analysis and scalar evolution only, trying to clean up the
loop as far as possible.

I suppose that, if we were to define SCCs, split them into groups and
re-arranging into multiple loops, we would still do it in the IR.
Would that spoil any other pass? What passes should run
before/after such a pass?

I believe that would be a FunctionPass and registered in the
LoopDependencyAnalysis "runOnLoop()", so it can run when such pass is
called by the PassManager. Or should it be a completely separate pass
(VectorizationPass?) so we can control it from a separate command-line

Any comments appreciated before I dig in.


Reclaim your digital rights, eliminate DRM, learn more at

A separate VectorizationPass that requires dependence analysis is the
way to go.

Hi Devang,

With all the holiday break stuff I forgot about this thread. I got to
a dead end...

The docs [1] explain how to write a function pass and mention a loop
pass as a type of function pass, but the registration doesn't work the
same way, I had to do some hacking and never got it to show up in the
'opt' list.

I also got to a loop in the call (the code is quite extensive and I
still have limited time to dig in). I got that by writing a loop pass
and putting it on the pass vector it'd be called by the loop pass, but
I couldn't figure it out how to add it to the loop vector.

If I got what you saying, I should created a separate function pass
(registered the way the docs say or adding it to LinkAllPasses, I
don't know), depending on LoopDependenceAnalysis (somewhere there was
a way to determine dependency, I have to check out again), that would
do the same as LoopPass (find all loops, run a vectorization loop pass
on each).

If that's so, why not extend LoopPass and register it directly on the
vector? I imagine the dependency wouldn't be as easy but at least
there would be less duplicated code... or I just didn't understand
much of it... what's way more likely... :wink: