This is an archive of the discontinued LLVM Phabricator instance.

[LoopIdiom] 'left-shift until bittest' idiom: support rewriting loop as countable, allow extra cruft
ClosedPublic

Authored by lebedev.ri on Dec 7 2020, 4:40 AM.

Details

Summary

The current state of the transform is still not enough to support
my motivational pattern, because it has one more "induction variable".

I have delayed posting this patch, because originally even just rewriting
the loop as countable wasn't enough to nicely transform my motivational pattern,
because i expected that extra IV to be rewritten afterwards,
but it wasn't happening until i fixed that in D91800.

So, this patch allows the 'left-shift until bittest' loop idiom
as long as the inserted ops are cheap,
and lifts any and all extra use checks on the instructions.

Diff Detail

Event Timeline

lebedev.ri created this revision.Dec 7 2020, 4:40 AM

Rebased, NFC.

Rebased, NFC.

@craig.topper ping :) Do we have a consensus that this is the way forward?

I think this makes sense.

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
2173

I think there's something missing between "we'll" and "is"?

2227

There's an extra period at the end of this line.

lebedev.ri marked 2 inline comments as done.

@craig.topper thank you for taking a look!
Fixed up comments (this needs a rebase for tests, i didn't do that curently.)

I think this makes sense.

Aha!

This revision is now accepted and ready to land.Dec 23 2020, 11:10 AM

LGTM

Alright, thank you for the review!

I'll followup with teaching it about right-shifts,
and see if the other loop-idiom patterns can also be relaxed in this way.

Rebased, NFC.

This revision was landed with ongoing or failed builds.Dec 23 2020, 11:29 AM
This revision was automatically updated to reflect the committed changes.