This is an archive of the discontinued LLVM Phabricator instance.

Add optimization remarks to the loop unroller and vectorizer.
ClosedPublic

Authored by dnovillo on Apr 22 2014, 11:46 AM.

Details

Summary

This calls emitOptimizationRemark from the loop unroller and vectorizer
at the point where they make a positive transformation.

Diff Detail

Event Timeline

dnovillo updated this revision to Diff 8738.Apr 22 2014, 11:46 AM
dnovillo retitled this revision from to Add optimization remarks to the loop unroller and vectorizer..
dnovillo updated this object.
dnovillo edited the test plan for this revision. (Show Details)
dnovillo added a subscriber: Unknown Object (MLST).
dnovillo updated this revision to Diff 8740.Apr 22 2014, 1:30 PM
  • Add vectorization and interleave factor reporting.

Thanks for working on this!

include/llvm/Analysis/LoopInfo.h
465

Why are you looking in the pre-header first? That does not seem to make sense because the start of the preheader could be pretty far away from the start of the loop.

Maybe looking in the preheader makes sense, but you should specifically look for the *last* location somehow I'd think.

lib/Transforms/Utils/LoopUnroll.cpp
242

This message should be improved. If I unroll a loop with 5 iterations, I've not unrolled it 5 times -- then I'd have 25 iterations ;)

How about: "completely unrolled loop with N iterations".

246

Here too, maybe something like: "unrolled loop by a factor of N"

lib/Transforms/Vectorize/LoopVectorize.cpp
1201

Sounds like we're calling this "interleaving factor". The capitalization seems odd here, nothing else is capitalized.

dnovillo updated this revision to Diff 8778.Apr 23 2014, 10:06 AM
  • Review feedback.

Hal, do you think this is good enough to commit?

Thanks. Diego.

Yep, LGTM. Thanks!

zinovy.nis added inline comments.Apr 29 2014, 7:53 AM
lib/Transforms/Vectorize/LoopVectorize.cpp
1197

Your code will report loop as vectorized even if it was only unrolled.
Please see lines

InnerLoopVectorizer LB(L, SE, LI, DT, DL, TLI, VF.Width, UF);
   LB.vectorize(&LVL);
   ++LoopsVectorized;
 }

and above. Is it the desired behavior?

Good point, vectorized with VF == 1 is confusing. We should report the VF == 1 cases as just, 'unrolled with interleaving factor N'.

(We should also also say "interleave factor" or "unrolling interleave factor" in the regular case; we've decided to use the "interleave" terminology for the associated pragma).

You don't need to add metadata to

test/Transforms/LoopVectorize/X86/vectorization-remarks.ll

And if optimization remarks are only emitted in DEBUG (or RELEASE+ASSERTS) build, please add the following line in the beginning of your file. Thanks.

REQUIRES: asserts
dnovillo abandoned this revision.May 6 2014, 11:48 AM
dnovillo closed this revision.May 19 2014, 7:23 AM
dnovillo updated this revision to Diff 9544.

Closed by commit rL207528 (authored by @dnovillo).