[all-commits] [llvm/llvm-project] 29c851: [GlobalISel] Move the truncstore_merge combine to ...

Amara Emerson via All-commits all-commits at lists.llvm.org
Wed Apr 12 16:43:27 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29c851f4e2ff9dc55146be88ae0df3d378a7be9f
      https://github.com/llvm/llvm-project/commit/29c851f4e2ff9dc55146be88ae0df3d378a7be9f
  Author: Amara Emerson <amara at apple.com>
  Date:   2023-04-12 (Wed, 12 Apr 2023)

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

  Log Message:
  -----------
  [GlobalISel] Move the truncstore_merge combine to the LoadStoreOpt pass and add support for an extra case.

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.


  Commit: 719024a0d02f3da1e08d09613c7cad5b8d6f6d26
      https://github.com/llvm/llvm-project/commit/719024a0d02f3da1e08d09613c7cad5b8d6f6d26
  Author: Amara Emerson <amara at apple.com>
  Date:   2023-04-12 (Wed, 12 Apr 2023)

  Changed paths:
    M llvm/include/llvm/CodeGen/MachineInstr.h
    M llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
    M llvm/lib/CodeGen/MachineInstr.cpp

  Log Message:
  -----------
  [GlobalISel][NFC] Add MachineInstr::getFirst[N]{Regs,LLTs}() helpers to extract regs & types.

These reduce the typing and clutter from:
Register Dst = MI.getOperand(0).getReg();
Register Src1 = MI.getOperand(1).getReg();
Register Src2 = MI.getOperand(2).getReg();
Register Src3 = MI.getOperand(3).getReg();
LLT DstTy = MRI.getType(Dst);
... etc etc

To just:
auto [Dst, Src1, Src2, Src3] = MI.getFirst4Regs();
auto [DstTy, Src1Ty, Src2Ty, Src3Ty] = MI.getFirst4LLTs();

Or even more concise:
auto [Dst, DstTy, Src1, Src1Ty, Src2, Src2Ty, Src3, Src3Ty] =
     MI.getFirst4RegLLTs();

Differential Revision: https://reviews.llvm.org/D144687


Compare: https://github.com/llvm/llvm-project/compare/4b47d875a1f9...719024a0d02f


More information about the All-commits mailing list