This is an archive of the discontinued LLVM Phabricator instance.

[LV] Report multiple reasons for not vectorizing under allowExtraAnalysis
ClosedPublic

Authored by Ayal on May 22 2017, 2:11 AM.

Details

Summary

Report multiple reasons for not vectorizing a loop instead of stopping and reporting the first reason only, under ORE->allowExtraAnalysis() - via Clang's -fsave-optimization-record or opt's -pass-remarks-missed.

Removed checking and reporting if we CantComputeNumberOfIterations from LoopVectorizationLegality::canVectorize(), as
LAI::canAnalyzeLoop() is doing so, called by canVectorizeMemory(). This redundancy is caught by a lit test once multiple reasons are reported. Can be committed separately.

Patch initially developed by Dror Barak.

Diff Detail

Repository
rL LLVM

Event Timeline

Ayal created this revision.May 22 2017, 2:11 AM
fhahn added inline comments.May 22 2017, 6:12 AM
lib/Transforms/Vectorize/LoopVectorize.cpp
5211 ↗(On Diff #99724)

I think the comment also needs updating, mentioning the ORE->allowExtraAnalysis() case

Ayal updated this revision to Diff 99807.May 22 2017, 1:50 PM

Fixed comment and updated documentation.

Ayal added inline comments.May 22 2017, 1:52 PM
lib/Transforms/Vectorize/LoopVectorize.cpp
5211 ↗(On Diff #99724)

OK, sure.

Additional documentation that needs updating is docs/Vectorizers.rst.

Fixed both and uploaded updated version.

hfinkel accepted this revision.May 22 2017, 1:58 PM
hfinkel added a subscriber: hfinkel.

LGTM

lib/Transforms/Vectorize/LoopVectorize.cpp
5089 ↗(On Diff #99807)

Please add a comment here explaining that we use this for the allowExtraAnalysis case where we don't early-exit.

This revision is now accepted and ready to land.May 22 2017, 1:58 PM
anemet accepted this revision.May 22 2017, 2:09 PM

This is a good idea. LGTM too.

test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
45–46 ↗(On Diff #99724)

I think this is pretty meaningless without source line info. Why don't you add new DILocation metadata with unique source line numbers specifically for the loop so that you can check them here.

This test is also weirdly structured because there is no easy way to tie back source lines for the remarks to the corresponding function. Can you reorder this while you're here, like this?:

; source code 1
; CHECK: ...

; source code 2
; CHECK: ...

etc?

anemet added inline comments.May 22 2017, 2:14 PM
docs/Vectorizers.rst
101–103 ↗(On Diff #99807)

I am curious what others think but I am not sure we want to advertise this, i.e. this is more of a bug than a feature. After PR32352 this should work even without -fsave-optimization-record.

hfinkel added inline comments.May 22 2017, 3:09 PM
docs/Vectorizers.rst
101–103 ↗(On Diff #99807)

I agree (it is more of a bug than a feature), but on the other hand, documenting it leads to fewer surprises (hopefully). We might add, "(this behavior might change in the future)" to make this clear.

anemet added inline comments.May 22 2017, 3:10 PM
docs/Vectorizers.rst
101–103 ↗(On Diff #99807)

SGTM

Ayal updated this revision to Diff 99828.May 22 2017, 3:46 PM

Thanks @anemet and @hfinkel!
Uploaded updated version addressing all comments, to be committed.

This revision was automatically updated to reflect the committed changes.