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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |alias
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is a dup of another PR which I can't find right now.  GCC handles
pointer-to-integer casts just fine.  What it doesn't is creating alias
relationship
by relational tests (! n) but at the same time it sometimes propagates
conditional equivalences (that's not the issue in your case I think).

As said in that PR an incomplete fix would be to do sth like

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 251997)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -4954,6 +4954,19 @@ find_func_aliases (struct function *fn,
            make_escape_constraint (rhsop);
        }
     }
+  else if (gcond *cond = dyn_cast <gcond *> (t))
+    {
+      if ((gimple_cond_code (cond) == EQ_EXPR
+          || gimple_cond_code (cond) == NE_EXPR)
+         && TREE_CODE (gimple_cond_rhs (cond)) == SSA_NAME)
+       {
+         auto_vec<ce_s> rhs1c;
+         auto_vec<ce_s> rhs2c;
+         get_constraint_for_rhs (gimple_cond_lhs (cond), &rhs1c);
+         get_constraint_for_rhs (gimple_cond_rhs (cond), &rhs2c);
+         process_all_all_constraints (rhs1c, rhs2c);
+       }
+    }
   /* Handle escapes through return.  */
   else if (gimple_code (t) == GIMPLE_RETURN
           && gimple_return_retval (as_a <greturn *> (t)) != NULL_TREE)

the effect on the number of constraints and optimization is unknown.

Incomplete because the above doesn't handle other ways of relating things.
The compare might be in an external function and thus not visible to GCC
at all.  Which means we must assume that all pointers that escaped the
current function might actually point to the same thing if a function
call happens (and the result is in any way used in a conditional).

You can workaround GCCs "deficiency" by using -fno-tree-pta.

Reply via email to