[all-commits] [llvm/llvm-project] 1b6574: [SeparateConstOffsetFromGEP] Reorder trivial GEP c...

Jeffrey Byrnes via All-commits all-commits at lists.llvm.org
Tue Feb 13 11:23:02 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b65742f8c71f576381fe85d5e34579b24f2d874
      https://github.com/llvm/llvm-project/commit/1b65742f8c71f576381fe85d5e34579b24f2d874
  Author: Jeffrey Byrnes <jeffrey.byrnes at amd.com>
  Date:   2024-02-13 (Tue, 13 Feb 2024)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
    M llvm/test/CodeGen/AMDGPU/machine-sink-temporal-divergence-swdev407790.ll
    M llvm/test/CodeGen/AMDGPU/splitkit-getsubrangeformask.ll
    M llvm/test/CodeGen/PowerPC/licm-remat.ll
    A llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep-inbounds.ll
    A llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll
    A llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll
    A llvm/test/Transforms/SeparateConstOffsetFromGEP/reorder-gep.ll

  Log Message:
  -----------
  [SeparateConstOffsetFromGEP] Reorder trivial GEP chains to separate constants (#73056)

In this case, a trivial GEP chain has the form:

```
%ptr = getelementptr sameType, %base, constant
%val = getelementptr sameType, %ptr, %variable
```

That is, a one-index GEP consumes another (of the same basis and result
type) one-index GEP, where the inner GEP uses a constant index and the
outer GEP uses a variable index. For chains of this type, it is trivial
to reorder them (by simply swapping the indexes). The result of doing so
is better AddrMode matching for users of the ultimate ptr produced by
GEP chain.

Future patches can extend this to support non-trivial GEP chains (e.g.
those with different basis types and/or multiple indices).




More information about the All-commits mailing list