[PATCH] D148144: [GlobalISel] Move the truncstore_merge combine to the LoadStoreOpt pass and add support for an extra case.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 09:56:38 PDT 2023


aemerson created this revision.
aemerson added reviewers: jpaquette, arsenm.
aemerson added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a reviewer: paquette.
Herald added a project: All.
aemerson requested review of this revision.
Herald added a subscriber: wdng.

If we have set of mergeable stores of shifts, but the original source value being shifted
is wider than the merged size, we should still be able to merge if we truncate first. To do this
however we need to search for stores speculatively up the block, without knowing exactly how
many stores we should see before we stop. The old algorithm has to match an exact number of
stores to fit the wide type, or it dies. The new one will try to set the wide type to however
many stores we found in the upwards block traversal and use later checks to verify if they're
a valid mergeable set.

The reason I need to move this to LoadStoreOpt is because the combiner works going top down
inside a block, which means that we end up doing partial merges because we haven't seen all
the possible stores before we mutate the MIR. In LoadStoreOpt we can go bottom up.

As a side effect of this change, we also end up doing better on an existing test case (missing_store)
since we manage to do a partial merge there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148144

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/CodeGen/GlobalISel/LoadStoreOpt.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/merge-stores-truncating.ll
  llvm/test/CodeGen/AArch64/GlobalISel/merge-stores-truncating.mir
  llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
  llvm/test/CodeGen/AArch64/GlobalISel/store-merging.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148144.512882.patch
Type: text/x-patch
Size: 60540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230412/80458fed/attachment.bin>


More information about the llvm-commits mailing list