[PATCH] D35741: Add MemorySSA alternative to AliasSetTracker in LICM.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 15:38:30 PDT 2017


asbirlea created this revision.
Herald added subscribers: Prazek, mzolotukhin, mehdi_amini.

[Work in progress]
This is the first iteration for adding MemorySSA as an alternative to the AliasSetTracker in LICM.
I'm also using this to list several issues I came across, and get feedback on best ways to address them.
At the end of the day, doing such a replacement may require major rewrites to LICM, this patch
still tries to fit into the pattern that already exists in LICM, that, for promotion in particular,
is not ideal for using MemorySSA.

Issues:

- Adding MemorySSA as a loop dependency
  - This patch adds MemorySSA as a dependency to all loop passes. It is added as a required pass that gets

invalidated if used in LICM. The ideal scenario is to have all loop passes preserve MemorySSA.

- MemorySSA is used by default in LICM in this patch, simply for testing purposes.
- Patch updates tests to reflect MemorySSA pass being run/invalidated:

  		test/Other/loop-pm-invalidation.ll
  		test/Other/new-pass-manager.ll
  		test/Other/pass-pipelines.ll

  - Patch does *not* update "unittests/Transforms/Scalar/LoopPassManagerTest.cpp" (fails)
- For hoist/sink, it is possible to get "less than perfect" results, due to the fact that we intentionally allow

some imprecision, by using getDefiningAccess instead of getClobberingAccess. MemorySSA has a cap on the number of
stores/phis it will walk past when optimizing Uses (memssa-check-limit).

  - See "BIG NOTE" in LICM.cpp.
- In order to keep the promotion mechanism the same, we use MemorySSA to create some alias sets.
  - Changing the promotion mechanism will require some major changes, I'm not sure this is the path to go on now.
  - We still face a performance penalty if we allow full sets to be created. This time, we cannot rely on the

imprecision approach used for hoist/sink. See the follow up to BIG NOTE in MemorySSAAliasSets.h
	There is *no cap* set in this patch.

- Creating sets queries AliasAnalysis. From discussions with dberlin, I think this can be avoided and

the same info be cached inside MemorySSA.

- [refactor] Move LICM:collectChildrenInLoop to Utils and reuse in MemorySSAAliasSets.h to avoid recursion.

This is required to avoid blowing up stack (https://reviews.llvm.org/D35609).


https://reviews.llvm.org/D35741

Files:
  include/llvm/Analysis/LoopAnalysisManager.h
  include/llvm/Analysis/MemorySSAAliasSets.h
  include/llvm/Support/Debug.h
  include/llvm/Transforms/Scalar/LoopPassManager.h
  include/llvm/Transforms/Utils/LoopUtils.h
  lib/Analysis/LoopAnalysisManager.cpp
  lib/Analysis/MemorySSA.cpp
  lib/Transforms/Scalar/LICM.cpp
  lib/Transforms/Scalar/LoopDistribute.cpp
  lib/Transforms/Scalar/LoopLoadElimination.cpp
  lib/Transforms/Scalar/LoopSink.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Other/loop-pm-invalidation.ll
  test/Other/new-pass-manager.ll
  test/Other/pass-pipelines.ll
  unittests/Transforms/Scalar/LoopPassManagerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35741.107731.patch
Type: text/x-patch
Size: 60219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170721/471c1ad3/attachment.bin>


More information about the llvm-commits mailing list