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

             Bug #: 50577
           Summary: IPA-PTA context insensitivity confuses pure-const
                    analysis
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: rgue...@gcc.gnu.org


For gcc.c-torture/execute/20000412-2.c, slightly changed to

static int f(int a,int *y)
{
  int x = a;

  if (a==0)
    return *y;

  return f(a-1,&x);
}

int main(int argc,char **argv)
{
  if (f (100, (int *) 0) != 1)
    abort ();
  exit (0);
}

IPA-PTA computes that in f(), y points to { 0, x }, and when the late
local pure-const pass comes along it sees f():

  scanning: D.2734_4 = *y_3(D);
    Indirect ref to local memory is OK

making f() const.  That causes RTL DSE to delete the store x = a.

This triggers with

Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c      (revision 179378)
+++ tree-ssa-structalias.c      (working copy)
@@ -6010,11 +6043,13 @@ pt_solution_includes_global (struct pt_s
   if (pt->ipa_escaped)
     return pt_solution_includes_global (&ipa_escaped_pt);

+#if 0
   /* ???  This predicate is not correct for the IPA-PTA solution
      as we do not properly distinguish between unit escape points
      and global variables.  */
   if (cfun->gimple_df->ipa_pta)
     return true;
+#endif

   return false;
 }

only (obviously).

Reply via email to