summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch168
1 files changed, 168 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch
new file mode 100644
index 0000000000..7f0518a1bd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0355-2011-05-26-Paul-Thomas-pault-gcc.gnu.org.patch
@@ -0,0 +1,168 @@
1From a5c09be2d509aeba1efb986f8996d4847883cc5a Mon Sep 17 00:00:00 2001
2From: pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Thu, 26 May 2011 20:49:07 +0000
4Subject: [PATCH] 2011-05-26 Paul Thomas <pault@gcc.gnu.org>
5 Thomas Koenig <tkoenig@gcc.gnu.org>
6
7 PR fortran/48955
8 * trans-expr.c (gfc_trans_assignment_1): GFC_REVERSE_NOT_SET
9 changed to GFC_ENABLE_REVERSE.
10 * trans-array.c (gfc_init_loopinfo): GFC_CANNOT_REVERSE changed
11 to GFC_INHIBIT_REVERSE.
12 * gfortran.h : Enum gfc_reverse is now GFC_ENABLE_REVERSE,
13 GFC_FORWARD_SET, GFC_REVERSE_SET and GFC_INHIBIT_REVERSE.
14 * dependency.c (gfc_dep_resolver): Change names for elements of
15 gfc_reverse as necessary. Change the logic so that forward
16 dependences are remembered as well as backward ones. When both
17 have appeared, force a temporary.
18
192011-05-26 Thomas Koenig <tkoenig@gcc.gnu.org>
20
21 PR fortran/48955
22 * gfortran.dg/dependency_40.f90 : New test.
23
24
25
26git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174308 138bc75d-0d04-0410-961f-82ee72b054a4
27
28index 77e8df7..58cfb65 100644
29--- a/gcc/fortran/dependency.c
30+++ b/gcc/fortran/dependency.c
31@@ -1793,7 +1793,7 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
32
33 /* Now deal with the loop reversal logic: This only works on
34 ranges and is activated by setting
35- reverse[n] == GFC_CAN_REVERSE
36+ reverse[n] == GFC_ENABLE_REVERSE
37 The ability to reverse or not is set by previous conditions
38 in this dimension. If reversal is not activated, the
39 value GFC_DEP_BACKWARD is reset to GFC_DEP_OVERLAP. */
40@@ -1801,25 +1801,34 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
41 && lref->u.ar.dimen_type[n] == DIMEN_RANGE)
42 {
43 /* Set reverse if backward dependence and not inhibited. */
44- if (reverse && reverse[n] != GFC_CANNOT_REVERSE)
45+ if (reverse && reverse[n] == GFC_ENABLE_REVERSE)
46 reverse[n] = (this_dep == GFC_DEP_BACKWARD) ?
47 GFC_REVERSE_SET : reverse[n];
48
49- /* Inhibit loop reversal if dependence not compatible. */
50- if (reverse && reverse[n] != GFC_REVERSE_NOT_SET
51- && this_dep != GFC_DEP_EQUAL
52- && this_dep != GFC_DEP_BACKWARD
53- && this_dep != GFC_DEP_NODEP)
54+ /* Set forward if forward dependence and not inhibited. */
55+ if (reverse && reverse[n] == GFC_ENABLE_REVERSE)
56+ reverse[n] = (this_dep == GFC_DEP_FORWARD) ?
57+ GFC_FORWARD_SET : reverse[n];
58+
59+ /* Flag up overlap if dependence not compatible with
60+ the overall state of the expression. */
61+ if (reverse && reverse[n] == GFC_REVERSE_SET
62+ && this_dep == GFC_DEP_FORWARD)
63+ {
64+ reverse[n] = GFC_INHIBIT_REVERSE;
65+ this_dep = GFC_DEP_OVERLAP;
66+ }
67+ else if (reverse && reverse[n] == GFC_FORWARD_SET
68+ && this_dep == GFC_DEP_BACKWARD)
69 {
70- reverse[n] = GFC_CANNOT_REVERSE;
71- if (this_dep != GFC_DEP_FORWARD)
72- this_dep = GFC_DEP_OVERLAP;
73+ reverse[n] = GFC_INHIBIT_REVERSE;
74+ this_dep = GFC_DEP_OVERLAP;
75 }
76
77 /* If no intention of reversing or reversing is explicitly
78 inhibited, convert backward dependence to overlap. */
79- if (this_dep == GFC_DEP_BACKWARD
80- && (reverse == NULL || reverse[n] == GFC_CANNOT_REVERSE))
81+ if ((reverse == NULL && this_dep == GFC_DEP_BACKWARD)
82+ || (reverse != NULL && reverse[n] == GFC_INHIBIT_REVERSE))
83 this_dep = GFC_DEP_OVERLAP;
84 }
85
86diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
87index 165bd2f..f20a29b 100644
88--- a/gcc/fortran/gfortran.h
89+++ b/gcc/fortran/gfortran.h
90@@ -578,10 +578,10 @@ gfc_fcoarray;
91
92 typedef enum
93 {
94- GFC_REVERSE_NOT_SET,
95+ GFC_ENABLE_REVERSE,
96+ GFC_FORWARD_SET,
97 GFC_REVERSE_SET,
98- GFC_CAN_REVERSE,
99- GFC_CANNOT_REVERSE
100+ GFC_INHIBIT_REVERSE
101 }
102 gfc_reverse;
103
104diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
105index 3d4a52a..b64e10d 100644
106--- a/gcc/fortran/trans-array.c
107+++ b/gcc/fortran/trans-array.c
108@@ -2223,7 +2223,7 @@ gfc_init_loopinfo (gfc_loopinfo * loop)
109 for (n = 0; n < GFC_MAX_DIMENSIONS; n++)
110 {
111 loop->order[n] = n;
112- loop->reverse[n] = GFC_CANNOT_REVERSE;
113+ loop->reverse[n] = GFC_INHIBIT_REVERSE;
114 }
115
116 loop->ss = gfc_ss_terminator;
117diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
118index 1d678e6..ade7e54 100644
119--- a/gcc/fortran/trans-expr.c
120+++ b/gcc/fortran/trans-expr.c
121@@ -6067,8 +6067,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
122 /* Calculate the bounds of the scalarization. */
123 gfc_conv_ss_startstride (&loop);
124 /* Enable loop reversal. */
125- for (n = 0; n < loop.dimen; n++)
126- loop.reverse[n] = GFC_REVERSE_NOT_SET;
127+ for (n = 0; n < GFC_MAX_DIMENSIONS; n++)
128+ loop.reverse[n] = GFC_ENABLE_REVERSE;
129 /* Resolve any data dependencies in the statement. */
130 gfc_conv_resolve_dependencies (&loop, lss, rss);
131 /* Setup the scalarizing loops. */
132new file mode 100644
133index 0000000..b7bd4f9
134--- /dev/null
135+++ b/gcc/testsuite/gfortran.dg/dependency_40.f90
136@@ -0,0 +1,29 @@
137+! { dg-do run }
138+! PR 48955 - missing array temporary when there was both a forward
139+! and a backward dependency.
140+! Test case slightly modified from the original one by Kacper Kowalik.
141+program ala
142+ implicit none
143+
144+ integer, parameter :: n = 6
145+ real, dimension(n), parameter :: result = [1.,10.,30.,90.,270., 243.];
146+ real, dimension(n) :: v0, v1
147+ character(len=80) :: line1, line2
148+
149+ v0 = [1.0, 3.0, 9.0, 27.0, 81.0, 243.0]
150+ v1 = v0
151+
152+ v1(2:n-1) = v1(1:n-2) + v1(3:n)
153+ if (any(v1 /= result)) call abort
154+ v1 = v0
155+ v1(2:n-1) = v0(1:n-2) + v0(3:n)
156+ if (any(v1 /= result)) call abort
157+
158+ v1 = v0
159+ v1(2:n-1) = v1(3:n) + v1(1:n-2)
160+ if (any(v1 /= result)) call abort
161+ v1 = v0
162+ v1(2:n-1) = v0(3:n) + v0(1:n-2)
163+ if (any(v1 /= result)) call abort
164+
165+end program ala
166--
1671.7.0.4
168