From 7c428aa29d75ef163c334cf3974f87b3630d8b8b Mon Sep 17 00:00:00 2001 From: Renlin Li Date: Thu, 28 Jul 2016 11:21:53 +0000 Subject: [PATCH] [PATCH] Revert Revert r238497 because of PR 71961. This patch reverts the change for PR 71902 since it causes 178.gagel miscompile in spec2000 as reported in PR 71961 which was observed in x86_64, aarch64, powerpc64. gcc/fortran/ChangeLog: 2016-07-28 Renlin Li Revert 2016-07-19 Thomas Koenig PR fortran/71902 * dependency.c (gfc_check_dependency): Use dep_ref. Handle case if identical is true and two array element references differ. (gfc_dep_resovler): Move most of the code to dep_ref. (dep_ref): New function. * frontend-passes.c (realloc_string_callback): Name temporary variable "realloc_string". gcc/testsuite/ChangeLog: 2016-07-28 Renlin Li Revert 2016-07-19 Thomas Koenig PR fortran/71902 * gfortran.dg/dependency_47.f90: New test. From-SVN: r238815 --- gcc/fortran/ChangeLog | 13 +++++ gcc/fortran/dependency.c | 79 +++++------------------------ gcc/fortran/frontend-passes.c | 2 +- gcc/testsuite/ChangeLog | 8 +++ gcc/testsuite/gfortran.dg/dependency_47.f90 | 15 ------ 5 files changed, 36 insertions(+), 81 deletions(-) delete mode 100644 gcc/testsuite/gfortran.dg/dependency_47.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0847e64..5baf398 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,16 @@ +2016-07-28 Renlin Li + + Revert + 2016-07-19 Thomas Koenig + + PR fortran/71902 + * dependency.c (gfc_check_dependency): Use dep_ref. Handle case + if identical is true and two array element references differ. + (gfc_dep_resovler): Move most of the code to dep_ref. + (dep_ref): New function. + * frontend-passes.c (realloc_string_callback): Name temporary + variable "realloc_string". + 2016-07-26 Steven G. Kargl PR fortran/71862 diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index a873dbe..f117de0 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -54,8 +54,6 @@ enum gfc_dependency static gfc_dependency check_section_vs_section (gfc_array_ref *, gfc_array_ref *, int); -static gfc_dependency dep_ref (gfc_ref *, gfc_ref *, gfc_reverse *); - /* Returns 1 if the expr is an integer constant value 1, 0 if it is not or def if the value could not be determined. */ @@ -1318,33 +1316,13 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *expr2, bool identical) return 0; } + if (identical) + return 1; + /* Identical and disjoint ranges return 0, overlapping ranges return 1. */ if (expr1->ref && expr2->ref) - { - gfc_dependency dep; - dep = dep_ref (expr1->ref, expr2->ref, NULL); - switch (dep) - { - case GFC_DEP_EQUAL: - return identical; - - case GFC_DEP_FORWARD: - return 0; - - case GFC_DEP_BACKWARD: - return 1; - - case GFC_DEP_OVERLAP: - return 1; - - case GFC_DEP_NODEP: - return 0; - - default: - gcc_unreachable(); - } - } + return gfc_dep_resolver (expr1->ref, expr2->ref, NULL); return 1; @@ -2074,39 +2052,11 @@ ref_same_as_full_array (gfc_ref *full_ref, gfc_ref *ref) 2 : array references are overlapping but reversal of one or more dimensions will clear the dependency. 1 : array references are overlapping. - 0 : array references are identical or can be handled in a forward loop. */ + 0 : array references are identical or not overlapping. */ int gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) { - enum gfc_dependency dep; - dep = dep_ref (lref, rref, reverse); - switch (dep) - { - case GFC_DEP_EQUAL: - return 0; - - case GFC_DEP_FORWARD: - return 0; - - case GFC_DEP_BACKWARD: - return 2; - - case GFC_DEP_OVERLAP: - return 1; - - case GFC_DEP_NODEP: - return 0; - - default: - gcc_unreachable(); - } -} - - -static gfc_dependency -dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) -{ int n; int m; gfc_dependency fin_dep; @@ -2129,22 +2079,21 @@ dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) /* The two ranges can't overlap if they are from different components. */ if (lref->u.c.component != rref->u.c.component) - return GFC_DEP_NODEP; + return 0; break; case REF_SUBSTRING: /* Substring overlaps are handled by the string assignment code if there is not an underlying dependency. */ - - return fin_dep == GFC_DEP_ERROR ? GFC_DEP_NODEP : fin_dep; + return (fin_dep == GFC_DEP_OVERLAP) ? 1 : 0; case REF_ARRAY: if (ref_same_as_full_array (lref, rref)) - return GFC_DEP_EQUAL; + return 0; if (ref_same_as_full_array (rref, lref)) - return GFC_DEP_EQUAL; + return 0; if (lref->u.ar.dimen != rref->u.ar.dimen) { @@ -2155,7 +2104,7 @@ dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) fin_dep = gfc_full_array_ref_p (lref, NULL) ? GFC_DEP_EQUAL : GFC_DEP_OVERLAP; else - return GFC_DEP_OVERLAP; + return 1; break; } @@ -2199,7 +2148,7 @@ dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) /* If any dimension doesn't overlap, we have no dependency. */ if (this_dep == GFC_DEP_NODEP) - return GFC_DEP_NODEP; + return 0; /* Now deal with the loop reversal logic: This only works on ranges and is activated by setting @@ -2266,7 +2215,7 @@ dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) /* Exactly matching and forward overlapping ranges don't cause a dependency. */ if (fin_dep < GFC_DEP_BACKWARD) - return fin_dep == GFC_DEP_ERROR ? GFC_DEP_NODEP : fin_dep; + return 0; /* Keep checking. We only have a dependency if subsequent references also overlap. */ @@ -2284,7 +2233,7 @@ dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) /* Assume the worst if we nest to different depths. */ if (lref || rref) - return GFC_DEP_OVERLAP; + return 1; - return fin_dep; + return fin_dep == GFC_DEP_OVERLAP; } diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index d333c68..a543ab2 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -185,7 +185,7 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, current_code = c; inserted_block = NULL; changed_statement = NULL; - n = create_var (expr2, "realloc_string"); + n = create_var (expr2, "trim"); co->expr2 = n; return 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6123f10..343293c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-07-28 Renlin Li + + Revert + 2016-07-19 Thomas Koenig + + PR fortran/71902 + * gfortran.dg/dependency_47.f90: New test. + 2016-07-28 Martin Liska PR gcov-profile/68025 diff --git a/gcc/testsuite/gfortran.dg/dependency_47.f90 b/gcc/testsuite/gfortran.dg/dependency_47.f90 deleted file mode 100644 index eebc910..0000000 --- a/gcc/testsuite/gfortran.dg/dependency_47.f90 +++ /dev/null @@ -1,15 +0,0 @@ -! { dg-do compile } -! Make sure there is only one instance of a temporary variable here. -! { dg-options "-fdump-tree-original" } - -SUBROUTINE prtdata(ilen) - INTEGER :: ilen - character(len=ilen), allocatable :: cline(:) - allocate(cline(2)) - cline(1) = 'a' - cline(1)(2:3) = cline(1)(1:2) - cline(2) = cline(1) - print *,c -END SUBROUTINE prtdata -! { dg-final { scan-tree-dump-not "__var_2" "original" } } -! { dg-final { scan-tree-dump-times "__var_1" 3 "original" } } -- 2.7.4