[llvm] [InstCombine] Extend folding of aggregate construction to cases when source aggregates are partially available (PR #100828)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 11:26:29 PDT 2024
weiguozhi wrote:
> * Looking at https://github.com/dtcxzyw/llvm-opt-benchmark/pull/1288/files, a significant number of the transforms look non-profitable. This transforms is reasonable if it actually drops extractelement + insertelement pairs, but if you just move insertelements to a predecessor while converting scalar phis into aggregate phis, I think that's a loss, because optimizations generally have troubles with aggregate SSA values. I think this happens mostly if the other phi operands are constants.
The original code removes fully redundant insertvalue, this patch enhances it to remove partial redundant insertvalue, so it actually drop redundant insertvalue. Avoiding constant aggregate sounds reasonable, I added code to check it.
> * BFI in InstCombine -- wat? It looks like it's currently only used in SLC. Let's not use it in InstCombine proper.
Deleted.
> * To protect against cycles you probably want to check isBackEdge() instead, which was recently added.
Thanks for the info. Currently I restrict it to UseBB == OrigBB && succ_size(Pred) == 1, it can already avoid cycles.
> * `succ_size(Pred) != 1` => This should probably explicitly check for an unconditional branch, so you don't need to deal with the weird edge cases? (Like say, a single-successor callbr with aggregate return).
Changed it to checking for unconditional branch.
https://github.com/llvm/llvm-project/pull/100828
More information about the llvm-commits
mailing list