Bug 56286 - vectorizer does not keep loop-closed SSA up-to-date
Summary: vectorizer does not keep loop-closed SSA up-to-date
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: compile-time-hog, FIXME, wrong-code
Depends on:
Blocks: vectorizer
  Show dependency treegraph
 
Reported: 2013-02-11 12:45 UTC by Richard Biener
Modified: 2025-01-17 08:36 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-01-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2013-02-11 12:45:00 UTC
The vectorizer relies on the bug that cfgcleaup for no changed bbs from
fix_loop_structure rewrites the whole function into loop-closed-SSA again.

Loop-closed PHI node creation in vect_create_epilog_for_reduction does
not handle outer loop uses of the reduction result properly (those uses
are not yet vectorized).  For example gcc.dg/pr50133.c.
Comment 1 Richard Biener 2013-02-11 12:55:06 UTC
This blocks fixing of tree-ssa-loop-manip.c:find_uses_to_rename

   /* ??? If CHANGED_BBS is empty we rewrite the whole function -- why?  */
   if (changed_bbs && !bitmap_empty_p (changed_bbs))
     {
       EXECUTE_IF_SET_IN_BITMAP (changed_bbs, 0, index, bi)

which can be a major resource hog.  Also relying on that bug is broken,
without checking we can end up generating wrong-code this way.

Incremental betterness can be achieved by

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       (revision 195938)
+++ gcc/tree-vect-stmts.c       (working copy)
@@ -5834,46 +5834,6 @@ vect_transform_stmt (gimple stmt, gimple
        }
     }
 
-  /* Handle inner-loop stmts whose DEF is used in the loop-nest that
-     is being vectorized, but outside the immediately enclosing loop.  */
-  if (vec_stmt
...
-           }
-       }
-    }
-
   /* Handle stmts whose DEF is used outside the loop-nest that is
      being vectorized.  */


But still

FAIL: gcc.dg/vect/no-scevccp-outer-22.c (internal compiler error)
FAIL: gcc.dg/vect/no-scevccp-outer-22.c (test for excess errors)
WARNING: gcc.dg/vect/no-scevccp-outer-22.c compilation failed to produce executable
FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c (internal compiler error)
FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c (test for excess errors)
WARNING: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c compilation failed to produce executable
FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c scan-tree-dump-times vect "OUTER LOOP VECTORIZED." 1
Comment 2 Richard Biener 2014-06-24 10:42:24 UTC
Note the ??? is now moved to tree-vectorizer.c:

  if (num_vectorized_loops > 0)
    {
      /* If we vectorized any loop only virtual SSA form needs to be updated.
         ???  Also while we try hard to update loop-closed SSA form we fail
         to properly do this in some corner-cases (see PR56286).  */
      rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_only_virtuals);
      return TODO_cleanup_cfg;
Comment 3 Andrew Pinski 2024-03-09 23:42:17 UTC
The fixme is still there:
      /* If we vectorized any loop only virtual SSA form needs to be updated.
         ???  Also while we try hard to update loop-closed SSA form we fail
         to properly do this in some corner-cases (see PR56286).  */
      rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_only_virtuals);
      ret |= TODO_cleanup_cfg;