Page MenuHomePhabricator

[SelectionDAG] Avoid aliasing analysis if the object size is unknown.
ClosedPublic

Authored by HsiangKai on Nov 19 2020, 5:22 PM.

Details

Summary

If the size of memory access is unknown, do not use it to analysis. One example of unknown size memory access is to load/store scalable vector objects on the stack.

Diff Detail

Event Timeline

HsiangKai created this revision.Nov 19 2020, 5:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 19 2020, 5:22 PM
HsiangKai requested review of this revision.Nov 19 2020, 5:22 PM
HsiangKai updated this revision to Diff 306576.Nov 19 2020, 5:57 PM

clang format.

Thanks, could you please add a unit test for this ?

niravd requested changes to this revision.Nov 20 2020, 6:42 AM
This revision now requires changes to proceed.Nov 20 2020, 6:42 AM
niravd added inline comments.Nov 20 2020, 6:44 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
103

This is too aggressive. We can still determine that a two addresses are non-aliasing even if one is unknown size. (e.g. FrameIndex vs. Global)

HsiangKai added inline comments.Nov 22 2020, 7:30 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
103

The checking is under the condition that BasePtr0.equalBaseIndex(BasePtr1, ...) equals true. It would not be the case you considered.

HsiangKai updated this revision to Diff 306984.Nov 23 2020, 1:32 AM

Add unit tests.

niravd added inline comments.Nov 23 2020, 6:10 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
103

What about the case where equalBaseIndex returns true, and the lowered addressed access has a known size smaller than the difference? In that case, we should be able to determine that they are do not alias.

HsiangKai added inline comments.Nov 23 2020, 7:20 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
103

I doubt there is a such scenario to share the same base between fixed and scalable types. I could add an assertion here.

HsiangKai added inline comments.Nov 23 2020, 11:07 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
103

I could not exclude the case that one fixed object is fixed length type and another fixed object is scalable vector type. Sorry for that. I will update the patch.

dmgreen added a subscriber: nikic.Nov 23 2020, 11:51 PM
niravd accepted this revision.Nov 24 2020, 6:31 AM

LGTM modulo minor nit. Thanks!

llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
105

nit: These bools are single use and can be inlined.

This revision is now accepted and ready to land.Nov 24 2020, 6:31 AM