------- Comment #10 from rguenth at gcc dot gnu dot org  2009-06-02 15:21 
-------
C testcase:

struct X { int type; int pos; };
int foo(struct X *a, struct X *b)
{
again:
  if (a->type == 0)
    goto out;
  if (b->type == 1)
    goto out;
  ({ struct X *tmp = a; a = b; b = tmp; });
  goto again;

out:
  return a->pos + b->pos;
}

"fix":

@@ -1734,6 +1767,19 @@ phi_translate_1 (pre_expr expr, bitmap_s
            if (TREE_CODE (def) == SSA_NAME)
              def = VN_INFO (def)->valnum;

+           /* If we translated the name to one defined by a PHI node
+              in the same basic-block punt.  This hints at cyclic
+              PHI nodes like
+              <bb 3>:
+                # this_2 = PHI <this_45(D)(2), s_4(4)>
+                # s_4 = PHI <s_39(D)(2), this_2(4)>
+              which can cause antic computation to never finis.  */
+           if (TREE_CODE (def) == SSA_NAME
+               && (def_stmt = SSA_NAME_DEF_STMT (def)) != NULL
+               && gimple_code (def_stmt) == GIMPLE_PHI
+               && gimple_bb (def_stmt) == phiblock)
+             return NULL;
+
            /* Handle constant. */
            if (is_gimple_min_invariant (def))
              return get_or_alloc_expr_for_constant (def);


Danny - any opinions here?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dberlin at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40321

Reply via email to