This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR24378 fix (vectorizer)


Applying loop versioning in the vectorizer creates a situation where the
loop exit block has two predecessors (i.e. - after loop versionig, both
loop versions share the same basic block). The following transformations in
the vectorizer work under the assumption that the exit block has only one
predecessor. Specifically, the transformation of reductions, which
generates code (the reduction epilog) at the loop exit block end up
creating bad phis (with missing arguments). This patch fixes this up by
creating a new exit-block for the loop right after loop versioning takes
place, appropriately updating the loop-exit phis for loop-closed-ssa-form.
So, after loop versioning we have:

==============================
loop1:
      n_58 += ....
      if ... goto loop1 else goto exit
loop2:
      n_90 += ....
      if ... goto loop2 else goto exit
exit:
      n_99 = phi (n_58, n_90)
==============================

And after fixing up the exit block for loop1 we have:

==============================
loop1:
      n_58 += ....
      if ... goto loop1 else goto new_exit
loop2:
      n_90 += ....
      if ... goto loop2 else goto exit
new_exit:
      n_100 = phi (n_58)
exit:
      n_99 = phi (n_100, n_90)
==============================

Bootstrapped with vectorization enabled on powerpc-linux, tested on the
vectorizer testcases.
Thanks to Eric Botcazou for analyzing the problem, an testing and
bootstrapping it on  SPARC 32-bit and 64-bit.

ok for mainline?

thanks,
dorit

Changelog:

      * tree-vect-transform.c (vect_transform_loop): Create
single-predecessor
basic-block after loop-versioning.

Patch:

(See attached file: versioning_fix.txt)

Attachment: versioning_fix.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]