This is an archive of the discontinued LLVM Phabricator instance.

[LAA] Prune dependencies with distance large than access implied by trip count

Authored by reames on Aug 15 2022, 3:35 PM.



When we have a dependency with a dependence distance which can only be hit on an iteration beyond the actual trip count of the loop, we can ignore that dependency when analyzing said loop. We already had this code, but had restricted it solely to unknown dependence distances. This change applies it to all dependence distances.

Without this code, we relied on the vectorizer reducing VF such that our infeasible dependence was respected. This usually worked out to about the same result, but not always. For fixed length vectorization, this could mean a smaller VF than optimal being chosen or additional runtime checks. For scalable vectorization - where the bounds on access implied by VF are broader - we could often not find a feasible VF at all.

Diff Detail

Event Timeline

reames created this revision.Aug 15 2022, 3:35 PM
reames requested review of this revision.Aug 15 2022, 3:35 PM

ping! This is a pretty trivial patch, can I get an LGTM?

fhahn accepted this revision.Aug 25 2022, 1:58 PM

LGTM, thanks! I was looking into generalizing this a bit further independently to avoid regressions for another patch: D132703. It also covers the change in safe-dep-distance.ll but should be good as follow-up.


It might be good to also have a test that just uses -passes=print-access-info, but once D132703 goes in this should be covered in general anyways by a dedicated LAA test.

This revision is now accepted and ready to land.Aug 25 2022, 1:58 PM
reames added inline comments.Aug 25 2022, 2:26 PM

JFYI, the name of the printer here is non-idiomatic. I'd tried to find this, and fallen back on the vectorizer test when it didn't come up easily in greps.

I'd expect this to be: -passes="print<loop-access>" or -passes="print<loop-access-info>".

But yes, your follow on does add LAA test coverage directly, so we can leave as is.

fhahn added inline comments.Aug 25 2022, 3:06 PM

Yeah this is something I wanted to change for a bit. I’ll fix that tomorrow

dewen added a subscriber: dewen.Aug 24 2023, 6:48 PM