This is an archive of the discontinued LLVM Phabricator instance.

[PM] Simplify the new PM interface to the loop unroller and expose two factory functions for the two modes the loop unroller is actually used in in-tree: simplified full-unrolling and the entire thing including partial unrolling.
ClosedPublic

Authored by chandlerc on Jan 19 2017, 4:14 AM.

Details

Summary

I've also wired these up to nice names so you can express both of these
being in a pipeline easily. This is a precursor to actually enabling
these parts of the O2 pipeline.

I'm happy to consider alternative names here. I'm not a huge fan of
"simple" but it is what we were using.

Depends on D28848.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc created this revision.Jan 19 2017, 4:14 AM
davide requested changes to this revision.Jan 23 2017, 7:37 PM
davide added a subscriber: davide.

I have a fundamental question about the constructors. Also, I would prefer the spelling FullUnroll instead of SimpleUnroll.

include/llvm/Transforms/Scalar/LoopUnrollPass.h
25–31 ↗(On Diff #84956)

Is it intended that you're passing false to both create() and createSimple() ?
Shouldn't create() allow the entire thing, including partial unrolling? Here you don't enable it at all.

This revision now requires changes to proceed.Jan 23 2017, 7:37 PM
chandlerc added inline comments.Jan 23 2017, 7:38 PM
include/llvm/Transforms/Scalar/LoopUnrollPass.h
25–31 ↗(On Diff #84956)

Ahem. Indeed, that was not intended. More tests are also in order here!

(This isn't heavily used yet, so it isn't that surprising that i've missed a test for this.)

chandlerc updated this revision to Diff 85561.Jan 24 2017, 4:19 AM
chandlerc edited edge metadata.

Update with more correctness and more testing!

I have a fundamental question about the constructors.

See updated patch! =D

Also, I would prefer the spelling FullUnroll instead of SimpleUnroll.

Not sure what you actually want yet...

Currently we have LoopUnrollPass::create() and LoopUnrollPass::createSimple(), and at the pipeline unroll and unroll-simple. Are you suggesting just using "full" instead of "simple" with the same structure? unroll-full makes sense, but LoopUnrollPass::createFull() seems weird. It is a less powerful pass...

include/llvm/Transforms/Scalar/LoopUnrollPass.h
25–31 ↗(On Diff #84956)

It was worse than you realize.

The flag was actually backwards so that, combined with this being false, made both of these the more generic unroller.

I've added a test that the simple unroller *just* does full unrolling and that this one *does* do partial unrolling. Sorry for getting all my flags wrong.

I have a fundamental question about the constructors.

See updated patch! =D

Also, I would prefer the spelling FullUnroll instead of SimpleUnroll.

Not sure what you actually want yet...

Currently we have LoopUnrollPass::create() and LoopUnrollPass::createSimple(), and at the pipeline unroll and unroll-simple. Are you suggesting just using "full" instead of "simple" with the same structure? unroll-full makes sense, but LoopUnrollPass::createFull() seems weird. It is a less powerful pass...

I was suggesting unroll-full for the name of the pass (and what you pass to opt, or whatever. I agree with you createFull and createSimple can stay as they are (sorry if it wasn't entirely clear to begin with)

The new patch looks fine (now that you fixed the flag), minor comments inline.

mzolotukhin added inline comments.Jan 24 2017, 12:19 PM
lib/Passes/PassRegistry.def
228 ↗(On Diff #85561)

I agree with @davide regarding the name of the pass. IMO unroll-full better reflects what the pass is doing.

lib/Transforms/Scalar/LoopUnrollPass.cpp
1124 ↗(On Diff #85561)

Do we want to use LoopUnrollPass::createSimple here? This part (and the function above) seems to be doing almost the same as we do with the new functions.

1158 ↗(On Diff #85561)

How do we use ProvidedThreshold and ProvidedThreshold now?

chandlerc updated this revision to Diff 85681.Jan 24 2017, 7:05 PM

Update with new function name based on review comments.

davide accepted this revision.Jan 24 2017, 7:10 PM

LGTM if @mzolotukhin is happy.

This revision is now accepted and ready to land.Jan 24 2017, 7:10 PM
chandlerc added inline comments.Jan 24 2017, 7:15 PM
lib/Transforms/Scalar/LoopUnrollPass.cpp
1124 ↗(On Diff #85561)

Yeah, but they need the legacy PM bits so I just didn't want to touch them right away. We could refactor this some in the future if you want.

1158 ↗(On Diff #85561)

We don't at all. It's just vestigal for the legacy PM. We now have target hooks to control threshold and flags to do debugging. That seemed sufficient to me.

mzolotukhin accepted this revision.Jan 25 2017, 5:25 PM

LGTM too!

Michael

This revision was automatically updated to reflect the committed changes.