[PATCH] D114832: [SROA] Improve SROA to prevent generating redundant coalescing operations.

Mingming Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 09:28:06 PST 2021


luna added a comment.

In D114832#3164711 <https://reviews.llvm.org/D114832#3164711>, @luna wrote:

> In D114832#3163500 <https://reviews.llvm.org/D114832#3163500>, @lebedev.ri wrote:
>
>> That's a lot of complexity. It sounds like we are missing some cleanup transforms in some other passes?
>> Can you please post a standalone example of the "bad" codegen (via a godbolt link) that you are trying to avoid?
>
> To compare the LLVM and GCC codegen, tail call is generated in GCC but not LLVM.
>
> - (LLVM) https://godbolt.org/z/qTY6MfMGa
> - (GCC) https://godbolt.org/z/srh5fG6nW
>
> `test_struct_of_two_int` (from llvm/test/Transforms/SROA/alloca-struct.ll) shows the diff in IR level before and after this change, and run clang with this patch (`clang -S -O3 file.cpp`) would generate a tail call.

I dig a little bit on how GCC SROA works, and the findings are

1. this [1] writeup also mentions two RPs which avoid creating unnecessary or harmfully excessive statements when aggregates are used as a whole. The relevant PR are PR 40744 and PR 44423, mentioned in xi) of 2nd section.
2. The implementation (https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/tree-sra.c#L2435-L2472) has analysis of scalar/whole usage

[1] https://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=jambor.pdf


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114832/new/

https://reviews.llvm.org/D114832



More information about the llvm-commits mailing list