This is an archive of the discontinued LLVM Phabricator instance.

[ScopInfo] Make memset etc. affine where possible.
ClosedPublic

Authored by efriedma on Oct 17 2016, 3:37 PM.

Details

Summary

We don't actually check whether a MemoryAccess is affine in very many places, but one important one is in checks for aliasing.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma updated this revision to Diff 74922.Oct 17 2016, 3:37 PM
efriedma retitled this revision from to [ScopInfo] Generate runtime alias check for non-affine memory references..
efriedma updated this object.
efriedma added a reviewer: jdoerfert.
efriedma set the repository for this revision to rL LLVM.
efriedma added subscribers: llvm-commits, pollydev.
efriedma updated this revision to Diff 74926.Oct 17 2016, 3:40 PM

Delete outdated comment.

jdoerfert edited edge metadata.Oct 18 2016, 1:30 AM

While I agree with the commit message, I am not aware of any real benefit this will provide us given that we only leverage the constant range ScalarEvolution range analysis. If we would use a better one, e.g., along the lines of https://reviews.llvm.org/D20230, I think this patch does make sense.

This opinion was basically written down in the code:

// Check if we have non-affine accesses left, if so bail out as we cannot
// generate a good access range yet.

We ran into a case similar to the included testcase, where we need to generate a runtime alias check with a memset in order to vectorize a loop. (memset isn't really non-affine, but we currently model it that way.)

We ran into a case similar to the included testcase, where we need to generate a runtime alias check with a memset in order to vectorize a loop. (memset isn't really non-affine, but we currently model it that way.)

Why don't we then treat a memset/memcpy/memmove with affine length as affine access instead?
E.g. replace the "false" in ScopBuilder.cpp line 279 and 300 with "LengthIsAffine"?

I assumed there was some reason we were treating the memset as non-affine... if there isn't, I'm happy to change it.

You also have to adjust the call location to

buildMemIntrinsicAccessRelation

but I think this is the best way to go.

efriedma updated this revision to Diff 75087.Oct 18 2016, 4:18 PM
efriedma retitled this revision from [ScopInfo] Generate runtime alias check for non-affine memory references. to [ScopInfo] Make memset etc. affine where possible..
efriedma updated this object.
efriedma edited edge metadata.
jdoerfert accepted this revision.Nov 1 2016, 10:51 AM
jdoerfert edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Nov 1 2016, 10:51 AM
This revision was automatically updated to reflect the committed changes.