This is an archive of the discontinued LLVM Phabricator instance.

[LV] Workaround PR49900
ClosedPublic

Authored by reames on Apr 28 2021, 2:12 PM.

Details

Summary

LoopVectorize has a fairly deeply baked in design problem where it will try to query analysis (primarily SCEV, but also ValueTracking) in the midst of mutating IR. In particular, the intermediate IR state does not represent the semantics of the original (or final) program.

Fixing this for real is hard, but all of the cases seen so far share a common symptom. In cases seen to date, the analysis being queried is the computation of the original loop's trip count. We can fix this particular instance of the issue by simply computing the trip count early, and caching it.

I want to be really clear that this is nothing but a workaround. It does nothing to fix the root issue, and at best, delays the time until we have to fix this for real. Florian and I have discussed an eventual solution in the review comments for https://reviews.llvm.org/D100663, but it's a lot of work.

Test taken from https://reviews.llvm.org/D100663.

Diff Detail

Event Timeline

reames created this revision.Apr 28 2021, 2:12 PM
reames requested review of this revision.Apr 28 2021, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2021, 2:12 PM
fhahn accepted this revision.May 4 2021, 5:48 AM

LGTM, thanks! From the comment it's clear that this is jus a work-around, but as discussed in D100663, the general solution is non-trivial.

This revision is now accepted and ready to land.May 4 2021, 5:48 AM
fhahn added a comment.May 4 2021, 5:51 AM

If possible, it would be great if the title could be tweaked to be more expressive with respect to what the patch fixes/what it does.

reames added a comment.May 5 2021, 1:07 PM

I seem to have forgotten to link the bug from the commit message. Logging it here for later reference.

https://bugs.llvm.org/show_bug.cgi?id=49900