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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Robbert from comment #5)
> (In reply to Richard Biener from comment #4)
> > as the address is not "live" after that.
> Why doesn't gcc consider casting a pointer to an integer as making it
> "live"? The concrete representation of address has escaped, which means
> anything can happen to the storage it points to.

Because it isn't stored anywhere, you only performed the implicit
no-op assignment to i via the comparison.

PTA could certainly be told to add an effective

  i = (uintptr_t)&x

constraint when seeing an equality compare.  I'm not sure how pessimizing
that would be to code (and the validity of the testcase is disputed).

Sth like

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 222076)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -4771,6 +4771,19 @@ find_func_aliases (struct function *fn,
              || DECL_EXTERNAL (lhsop) || TREE_PUBLIC (lhsop)))
        make_escape_constraint (rhsop);
     }
+  else if (gimple_code (t) == GIMPLE_COND)
+    {
+      /* On one path both EQ and NE perform an equality relation
+         and thus code may consider pointer equivalence.  */
+      if (gimple_cond_code (t) == EQ_EXPR
+         || gimple_cond_code (t) == NE_EXPR)
+       {
+         get_constraint_for (gimple_cond_lhs (t), &lhsc);
+         get_constraint_for (gimple_cond_rhs (t), &rhsc);
+         process_all_all_constraints (lhsc, rhsc);
+         process_all_all_constraints (rhsc, lhsc);
+       }
+    }
   /* Handle escapes through return.  */
   else if (gimple_code (t) == GIMPLE_RETURN
           && gimple_return_retval (as_a <greturn *> (t)) != NULL_TREE)

which fixes the testcase (but is incomplete - equivalences built on
gimple assignment RHS need to be considered as well).

It's hard to "conservatively" catch all implicit equivalences (inline
asms, function calls), so I don't think that is a workable solution.
A conservative solution would basically mean to disable most PTA in
practice.

Reply via email to