]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: only move update_e if edge is split [PR123014]
authorTamar Christina <tamar.christina@arm.com>
Thu, 11 Dec 2025 15:51:23 +0000 (15:51 +0000)
committerTamar Christina <tamar.christina@arm.com>
Thu, 11 Dec 2025 15:51:23 +0000 (15:51 +0000)
commit8aa4ef38bd13c177c24d1d71ac172379b0ec26cb
treee6abc57d2c79d982538d5b7fdd69f9c13f14887a
parent382edf047effcd5b1ce66389742bd1b3e178ac95
vect: only move update_e if edge is split [PR123014]

This is an alternative fix for PR122959 where the issue is that in order to
maintain LOOPS_HAVE_PREHEADERS slpeel_add_loop_guard may add an empty block that
becomes the pre-header edge of the epilog loop.

If the epilog loop already had a pre-header we insert nothing and update_e  is
already pointing to the right thing.  However if we do insert the intermediate
block we have this situation

      guard block
          |
      pre-header
          |
        epilog

vect_update_ivs_after_vectorizer now needs to use the guard block to identify
the PHI nodes, but use the edge from pre-header -> epilog as the update_e.

The first fix moved update_e detection and we picked the guard pre-header ->
epilog edge and would use the pre-header block to fill in any new adjustments
needed.

This doesn't work because due to skip_epilog we have to put all adjustments in
the guard block, since the skip_epilog edge also skips the pre-header.

This patch instead addresses this in vect_update_ivs_after_vectorizer by if
you have an empty pre-header, it moves the edge down through the fall-through
edge, but keeps exit_bb as guard block.

gcc/ChangeLog:

PR tree-optimization/123014
* tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer): Detect
empty pre-header block.
(vect_do_peeling): Undo changes from PR122959.
gcc/tree-vect-loop-manip.cc