[PATCH] D118144: [GVN] Support chain of phi nodes in exit blocks.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 07:02:27 PST 2022


fhahn created this revision.
fhahn added reviewers: reames, spatel, lebedev.ri, mkazantsev, asbirlea.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

This patch extends to logic added in D118143 <https://reviews.llvm.org/D118143> to allow chains of phis
from the lcssa phi to the using load instruction. The intermediate phis
must be in blocks only containing the phi and an unconditional branch.
The blocks must be connected directly. This ensures that the load
instruction executes if the loop exit executes.

Such chains of phi nodes are common for rotated loops and is required to
be able to handle cases such as (https://clang.godbolt.org/z/6czGzzqbs)

  #include <vector>
  #include <algorithm>
  
  int foo(const std::vector<int> &V) {
     return *std::min_element(V.begin(), V.end());
  }

Depends on D118143 <https://reviews.llvm.org/D118143>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118144

Files:
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/test/Transforms/GVN/PRE/pre-loop-load-through-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118144.402899.patch
Type: text/x-patch
Size: 6532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220125/1c08a78a/attachment.bin>


More information about the llvm-commits mailing list