[Bug tree-optimization/103029] [12 regression] gcc.dg/vect/pr82436.c ICEs on r12-4818

luoxhu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 2 06:04:13 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103029

--- Comment #3 from luoxhu at gcc dot gnu.org ---
This hack could restore the previous phi order to put nondfs phi args before
dfs_edge args.  But I am not sure whether this is the correct direction.  At
least  it proves that the phi order matters for later vectorizer code.


diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 455c3ef8db9..2ca256c15fa 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify-me.h"
 #include "tree-ssa-loop-manip.h"
 #include "dumpfile.h"
+#include "ssa.h"

 static void copy_loops_to (class loop **, int,
                           class loop *);
@@ -1577,6 +1578,41 @@ lv_adjust_loop_entry_edge (basic_block first_head,
basic_block second_head,
   e1->probability = then_prob;
   e->probability = else_prob;

+  edge le, dfs = NULL, nondfs = NULL;
+  edge_iterator ei;
+
+  if (EDGE_COUNT (e1->dest->preds) > 1)
+  {
+    FOR_EACH_EDGE (le, ei, e1->dest->preds)
+      {
+       if (le->flags & EDGE_DFS_BACK)
+         dfs = le;
+       else
+         nondfs = le;
+      }
+    if (dfs && nondfs && dfs->dest_idx < nondfs->dest_idx)
+      {
+       gphi_iterator psi;
+       gphi *phi;
+       tree dfsdef, nondfsdef;
+       for (psi = gsi_start_phis (e1->dest); !gsi_end_p (psi); gsi_next
(&psi))
+         {
+           phi = psi.phi ();
+           dfsdef = PHI_ARG_DEF (phi, dfs->dest_idx);
+           nondfsdef = PHI_ARG_DEF (phi, nondfs->dest_idx);
+           SET_PHI_ARG_DEF (phi, dfs->dest_idx, nondfsdef);
+           SET_PHI_ARG_DEF (phi, nondfs->dest_idx, dfsdef);
+         }
+
+       EDGE_PRED (e1->dest, dfs->dest_idx) = nondfs;
+       EDGE_PRED (e1->dest, nondfs->dest_idx) = dfs;
+
+       unsigned int temp = nondfs->dest_idx;
+       nondfs->dest_idx = dfs->dest_idx;
+       dfs->dest_idx = temp;
+      }
+  }
+


More information about the Gcc-bugs mailing list