]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR fortran/41212
authormatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Sep 2009 16:12:18 +0000 (16:12 +0000)
committermatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Sep 2009 16:12:18 +0000 (16:12 +0000)
* tree.h (struct tree_decl_common): Add decl_restricted_flag,
shorten decl_common_unused.
(DECL_RESTRICTED_P): New accessor.
* tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Use it
to disambiguate marked decls and restrict pointers.

fortran/
* trans.h (struct lang_type): Remove nontarget_type member.
* trans.c (gfc_add_modify): Don't access it.
* trans-decl.c (gfc_finish_var_decl): Don't allocate and set it,
instead set DECL_RESTRICTED_P on affected decls.

testsuite/
* gfortran.dg/pr41212.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151761 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/fortran/trans.c
gcc/fortran/trans.h
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr41212.f90 [new file with mode: 0644]
gcc/tree-ssa-alias.c
gcc/tree.h

index 706f3e26de94252f4f249253c08bf2b620b12de6..eaff6d9e75228809292333d2f965be70b73a15fe 100644 (file)
@@ -1,3 +1,12 @@
+2009-09-16  Michael Matz  <matz@suse.de>
+
+       PR fortran/41212
+       * tree.h (struct tree_decl_common): Add decl_restricted_flag,
+       shorten decl_common_unused.
+       (DECL_RESTRICTED_P): New accessor.
+       * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Use it
+       to disambiguate marked decls and restrict pointers.
+
 2009-09-16  Richard Henderson  <rth@redhat.com>
 
        PR middle-end/41360
index b8586c2c0bc2e930fc7b4a8a5b4d74b47dde24ec..9c9744b140e36ae64a2991ee2c054698b26aae94 100644 (file)
@@ -1,3 +1,11 @@
+2009-09-16  Michael Matz  <matz@suse.de>
+
+       PR fortran/41212
+       * trans.h (struct lang_type): Remove nontarget_type member.
+       * trans.c (gfc_add_modify): Don't access it.
+       * trans-decl.c (gfc_finish_var_decl): Don't allocate and set it,
+       instead set DECL_RESTRICTED_P on affected decls.
+
 2009-09-14  Richard Henderson  <rth@redhat.com>
 
        * f95-lang.c (gfc_init_builtin_functions): Update call to
index 6a4c3e45cc983e828f6921a4e880ea76df8aa2b7..4e72a23bd5c956aeef3201e46fbb3864d982ca26 100644 (file)
@@ -581,26 +581,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
 
   if (!sym->attr.target
       && !sym->attr.pointer
-      && !sym->attr.proc_pointer
-      /* For now, don't bother with aggregate types.  We would need
-         to adjust DECL_CONTEXT of all field decls.  */
-      && !AGGREGATE_TYPE_P (TREE_TYPE (decl)))
-    {
-      tree type = TREE_TYPE (decl);
-      if (!TYPE_LANG_SPECIFIC (type))
-       TYPE_LANG_SPECIFIC (type) = (struct lang_type *)
-         ggc_alloc_cleared (sizeof (struct lang_type));
-      if (!TYPE_LANG_SPECIFIC (type)->nontarget_type)
-       {
-         alias_set_type set = new_alias_set ();
-         type = build_distinct_type_copy (type);
-         TYPE_ALIAS_SET (type) = set;
-         TYPE_LANG_SPECIFIC (type)->nontarget_type = type;
-       }
-      else
-       type = TYPE_LANG_SPECIFIC (type)->nontarget_type;
-      TREE_TYPE (decl) = type;
-    }
+      && !sym->attr.proc_pointer)
+    DECL_RESTRICTED_P (decl) = 1;
 }
 
 
index f4a215aeeaf27fa94199b03740023c1ae332d982..136987a74885c1bd72b5d1bdc1786e10cf637cd2 100644 (file)
@@ -162,13 +162,6 @@ gfc_add_modify (stmtblock_t * pblock, tree lhs, tree rhs)
   tree t1, t2;
   t1 = TREE_TYPE (rhs);
   t2 = TREE_TYPE (lhs);
-  /* ??? This is actually backwards, we should test the "base" type
-     from which the nontarget_type was copied, but we don't have this
-     backlink.  This will do for now, it's for checking anyway.  */
-  if (TYPE_LANG_SPECIFIC (t1))
-    t1 = TYPE_LANG_SPECIFIC (t1)->nontarget_type;
-  if (TYPE_LANG_SPECIFIC (t2))
-    t2 = TYPE_LANG_SPECIFIC (t2)->nontarget_type;
   /* Make sure that the types of the rhs and the lhs are the same
      for scalar assignments.  We should probably have something
      similar for aggregates, but right now removing that check just
index 643f28b37f4f55eaa38caf386e814ca09c9a2f41..4469023499de35c10de4a990fd1f1fafece8c10b 100644 (file)
@@ -629,7 +629,6 @@ struct GTY(())      lang_type        {
   tree dataptr_type;
   tree span;
   tree base_decl[2];
-  tree nontarget_type;
 };
 
 struct GTY(()) lang_decl {
index e02dbf90d18a776f559b422c836578ce3727a09f..5730da14617dd3a1122704b9df79c05c3cdaf54a 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-16  Michael Matz  <matz@suse.de>
+
+       PR fortran/41212
+       * gfortran.dg/pr41212.f90: New test.
+
 2009-09-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/alignment9.adb: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr41212.f90 b/gcc/testsuite/gfortran.dg/pr41212.f90
new file mode 100644 (file)
index 0000000..4bdae6d
--- /dev/null
@@ -0,0 +1,34 @@
+! { dg-do run }
+! { dg-options "-O2" }
+program m
+   double precision :: y,z
+   call b(1.0d0,y,z)
+   if (ABS (z - 1.213) > 0.1) call abort
+contains
+     subroutine b( x, y, z)
+       implicit none
+       double precision :: x,y,z
+       integer :: i, k
+       double precision :: h, r
+
+       y = 1.0d0
+       z = 0.0d0
+
+       h = 0
+       DO k = 1,10
+          h = h + 1.0d0/k
+
+          r = 1
+          DO i = 1,k
+             r = (x/(2*i) ) * r
+          END DO
+
+          y = y + (-1)**k * r
+          z = z + (-1)**(k+1) * h * r
+
+          IF ( ABS(2*k/x*r) < 1d-6 ) EXIT
+       END DO
+
+       z = 2*y
+     end subroutine b
+end program m
index 9522b28c5484cb5b8caa717f205033759bcae8b7..e619190386c2cf6aa672692f5473f12da6f6e0dd 100644 (file)
@@ -208,6 +208,14 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
   if (!pi)
     return true;
 
+  /* If the decl can be used as a restrict tag and we have a restrict
+     pointer and that pointers points-to set doesn't contain this decl
+     then they can't alias.  */
+  if (DECL_RESTRICTED_P (decl)
+      && TYPE_RESTRICT (TREE_TYPE (ptr))
+      && pi->pt.vars_contains_restrict)
+    return bitmap_bit_p (pi->pt.vars, DECL_UID (decl));
+
   return pt_solution_includes (&pi->pt, decl);
 }
 
index 70650489dd9ca4aba4e3a75d707a148dac392cec..09ce8fa125c0957fe53ea5c448c50131d6e6d5d7 100644 (file)
@@ -1306,6 +1306,15 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
   (TREE_CHECK3 (NODE, VAR_DECL, PARM_DECL, \
                RESULT_DECL)->decl_common.decl_by_reference_flag)
 
+/* In a RESULT_DECL, PARM_DECL and VAR_DECL, means that this decl
+   can be used as restricted tag to disambiguate against other restrict
+   pointers.  Used by fortran to capture something like non-addressability
+   (which it isn't really because the middle-end does take addresses of
+   such variables).  */
+#define DECL_RESTRICTED_P(NODE) \
+  (TREE_CHECK3 (NODE, VAR_DECL, PARM_DECL, \
+               RESULT_DECL)->decl_common.decl_restricted_flag)
+
 /* In a CALL_EXPR, means that the call is the jump from a thunk to the
    thunked-to function.  */
 #define CALL_FROM_THUNK_P(NODE) (CALL_EXPR_CHECK (NODE)->base.protected_flag)
@@ -2646,8 +2655,10 @@ struct GTY(()) tree_decl_common {
   unsigned gimple_reg_flag : 1;
   /* In VAR_DECL, PARM_DECL and RESULT_DECL, this is DECL_BY_REFERENCE.  */
   unsigned decl_by_reference_flag : 1;
+  /* In VAR_DECL, PARM_DECL and RESULT_DECL, this is DECL_RESTRICTED_P.  */
+  unsigned decl_restricted_flag : 1;
   /* Padding so that 'off_align' can be on a 32-bit boundary.  */
-  unsigned decl_common_unused : 4;
+  unsigned decl_common_unused : 3;
 
   /* DECL_OFFSET_ALIGN, used only for FIELD_DECLs.  */
   unsigned int off_align : 8;