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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ok, so given we can't have PRE do as good as predcom and a "cost model" for PRE
is out of the question for GCC 7 the following dumbs down PRE again.  It does
so in the very much simplest way rather than trying to block this only during
elimination / insertion.  This should be definitely revisited for GCC 8.

Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c  (revision 246026)
+++ gcc/tree-ssa-pre.c  (working copy)
@@ -1468,10 +1468,20 @@ phi_translate_1 (pre_expr expr, bitmap_s
                   leader for it.  */
                if (constant->kind != CONSTANT)
                  {
-                   unsigned value_id = get_expr_value_id (constant);
-                   constant = find_leader_in_sets (value_id, set1, set2);
-                   if (constant)
-                     return constant;
+                   /* Do not allow simplifications to non-constants over
+                      backedges as this will likely result in a loop PHI node
+                      to be inserted and increased register pressure.
+                      See PR77498 - this avoids doing predcoms work in
+                      a less efficient way.  */
+                   if (find_edge (pred, phiblock)->flags & EDGE_DFS_BACK)
+                     ;
+                   else
+                     {
+                       unsigned value_id = get_expr_value_id (constant);
+                       constant = find_leader_in_sets (value_id, set1, set2);
+                       if (constant)
+                         return constant;
+                     }
                  }
                else
                  return constant;

Reply via email to