public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask)
@ 2011-11-20 23:22 anlauf at gmx dot de
2011-11-21 0:51 ` [Bug fortran/51250] " dominiq at lps dot ens.fr
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: anlauf at gmx dot de @ 2011-11-20 23:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Bug #: 51250
Summary: [4.7 Regression] Bug with SUM(,dim,mask)
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: anlauf@gmx.de
The following program produces a wrong result:
program gfcbug115
implicit none
integer :: n_obstype = 2
integer :: nboxes = 1
integer :: nprocs = 1
integer :: nbox, j
integer, allocatable :: nbx(:,:), pes(:)
allocate (pes(nboxes))
allocate (nbx(n_obstype,nboxes))
nbx(:,:) = 1
do j = 1, nboxes
pes(j) = modulo (j-1, nprocs)
end do
do nbox=1, nboxes
print '(20i4)', nbox, nbx(:,nbox)
end do
do j = 0, nprocs-1
print '(i4,20l4)', j, spread (pes==j,dim=1,ncopies=n_obstype)
print '(20i4)', j, &
sum (nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype)), &
shape (sum (nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype)))
end do
end program gfcbug115
gfortran 4.7 svn rev. 181390:
1 1 1
0 T T
0 1 1
gfortran 4.6 and earlier:
1 1 1
0 T T
0 1 1 2
The latter is correct.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
@ 2011-11-21 0:51 ` dominiq at lps dot ens.fr
2011-11-21 8:07 ` burnus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-11-21 0:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-11-20
Ever Confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-11-20 23:22:08 UTC ---
Revision 180683 also gives
1 1 1
0 T T
0 1 1 2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
2011-11-21 0:51 ` [Bug fortran/51250] " dominiq at lps dot ens.fr
@ 2011-11-21 8:07 ` burnus at gcc dot gnu.org
2011-11-22 19:34 ` mikael at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-21 8:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
CC| |burnus at gcc dot gnu.org
Target Milestone|--- |4.7.0
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-21 07:46:46 UTC ---
Workaround: -Os (optimize for code size)
I would assume that it is due to Mikael's scalarizer patch set (Rev. 180842 to
Rev. 180922), cf. http://gcc.gnu.org/ml/fortran/2011-11/msg00046.html
Similar issue exists for PRODUCT, which is not surprising as they mostly share
the same code path.
(The expr->shape is correctly set in iresolve.c - but only if the shape and dim
is known at compile time, thus not in this case.)
(I couldn't quickly find the right spot in trans*.c)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
2011-11-21 0:51 ` [Bug fortran/51250] " dominiq at lps dot ens.fr
2011-11-21 8:07 ` burnus at gcc dot gnu.org
@ 2011-11-22 19:34 ` mikael at gcc dot gnu.org
2011-11-24 0:37 ` mikael at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2011-11-22 19:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikael at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |mikael at gcc dot gnu.org
|gnu.org |
--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> 2011-11-22 19:02:27 UTC ---
I will take care of this one after mid-december.
Beside the workaround proposed by Tobias, you can use a variable instead of a
constant for SUM's DIM argument.
Or you can patch gfc_inline_intrinsic_function_p (in trans-intrinsic.c) to
return false in the SUM case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
` (2 preceding siblings ...)
2011-11-22 19:34 ` mikael at gcc dot gnu.org
@ 2011-11-24 0:37 ` mikael at gcc dot gnu.org
2011-11-25 0:59 ` anlauf at gmx dot de
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2011-11-24 0:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> 2011-11-23 23:20:16 UTC ---
(In reply to comment #3)
> I will take care of this one after mid-december.
>
I couldn't help having a look.
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 2fb2d34..ee8f896 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -1087,7 +1087,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre,
stmtblock_t * post, gfc_ss * ss,
for (s = ss; s; s = s->parent)
for (n = 0; n < s->loop->dimen; n++)
{
- dim = get_scalarizer_dim_for_array_dim (ss, ss->dim[n]);
+ dim = get_scalarizer_dim_for_array_dim (ss, s->dim[n]);
/* For a callee allocated array express the loop bounds in terms
of the descriptor fields. */
This gives the following change in the dump. Then one gets the expected result.
--- comment_0.f90.003t.original.bad 2011-11-24 00:15:42.045565178 +0100
+++ comment_0.f90.003t.original.good 2011-11-24 00:12:16.409796545 +0100
@@ -473,7 +473,7 @@
S.18 = 0;
while (1)
{
- if (atmp.17.dim[1].ubound -
atmp.17.dim[1].lbound < S.18) goto L.14;
+ if (atmp.17.dim[0].ubound -
atmp.17.dim[0].lbound < S.18) goto L.14;
{
integer(kind=4) D.2013;
integer(kind=4) val.19;
@@ -608,7 +608,7 @@
__builtin_free (D.2035);
}
}
- D.2051 = atmp.23.dim[1].ubound -
atmp.23.dim[1].lbound;
+ D.2051 = atmp.23.dim[0].ubound -
atmp.23.dim[0].lbound;
atmp.24.dtype = 265;
atmp.24.dim[0].stride = 1;
atmp.24.dim[0].lbound = 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
` (3 preceding siblings ...)
2011-11-24 0:37 ` mikael at gcc dot gnu.org
@ 2011-11-25 0:59 ` anlauf at gmx dot de
2011-11-26 7:15 ` mikael at gcc dot gnu.org
2011-11-26 9:22 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gmx dot de @ 2011-11-25 0:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> 2011-11-24 22:39:10 UTC ---
(In reply to comment #4)
The patch in comment #4 works for me without regressions!
Thanks,
Harald
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
` (4 preceding siblings ...)
2011-11-25 0:59 ` anlauf at gmx dot de
@ 2011-11-26 7:15 ` mikael at gcc dot gnu.org
2011-11-26 9:22 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2011-11-26 7:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
--- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> 2011-11-25 20:18:32 UTC ---
Author: mikael
Date: Fri Nov 25 20:18:21 2011
New Revision: 181730
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181730
Log:
fortran/
PR fortran/51250
PR fortran/43829
* trans-array.c (gfc_trans_create_temp_array): Get dimension from
the right gfc_ss struct.
testsuite/
PR fortran/51250
PR fortran/43829
* gfortran.dg/inline_sum_3.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/inline_sum_3.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
` (5 preceding siblings ...)
2011-11-26 7:15 ` mikael at gcc dot gnu.org
@ 2011-11-26 9:22 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2011-11-26 9:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> 2011-11-25 21:17:12 UTC ---
Fixed.
Thanks for the report.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-11-25 21:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-20 23:22 [Bug fortran/51250] New: [4.7 Regression] Bug with SUM(,dim,mask) anlauf at gmx dot de
2011-11-21 0:51 ` [Bug fortran/51250] " dominiq at lps dot ens.fr
2011-11-21 8:07 ` burnus at gcc dot gnu.org
2011-11-22 19:34 ` mikael at gcc dot gnu.org
2011-11-24 0:37 ` mikael at gcc dot gnu.org
2011-11-25 0:59 ` anlauf at gmx dot de
2011-11-26 7:15 ` mikael at gcc dot gnu.org
2011-11-26 9:22 ` mikael at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).