[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-25 Thread mikael at gcc dot gnu.org
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=gccview=revrev=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


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-25 Thread mikael at gcc dot gnu.org
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.


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-24 Thread anlauf at gmx dot de
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


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-23 Thread mikael at gcc dot gnu.org
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.bad2011-11-24 00:15:42.045565178 +0100
+++ comment_0.f90.003t.original.good2011-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;


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-22 Thread mikael at gcc dot gnu.org
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.


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-20 Thread dominiq at lps dot ens.fr
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


[Bug fortran/51250] [4.7 Regression] Bug with SUM(,dim,mask)

2011-11-20 Thread burnus at gcc dot gnu.org
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)