[Bug fortran/27662] Transpose doesn't work on function return

2006-05-20 Thread pault at gcc dot gnu dot org


--- Comment #8 from pault at gcc dot gnu dot org  2006-05-20 06:23 ---
HJ

Your ISP does not like my address for some reason - it keeps bouncing my mail
to you.

Well done!  tonto-1.0/SPEC2006 now runs correctly.

Paul


-- 

pault at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-20 Thread pault at gcc dot gnu dot org


--- Comment #9 from pault at gcc dot gnu dot org  2006-05-20 20:10 ---
I have been writing to Dylan and Daniel, cc'd to you but your copies bounce. 
The upshot of the exchange is that on an Athlon1700, the spec2006 testcase runs
on tonto-1.0 in 1hour 5minutes with gfortran -O3 -ffast-math and 1hour
19minutes with ifort-9.0 -O3 (fast math built is default)...

This is very pleasing indeed; it's a tribute to your efforts and those of
various of the gang, who have worked like stink on the dependency analysis, the
integration with the backend and inlining of intrinsics.  gfortran is a bit
like a Ferarri - bad news on a cold morning but it chews up tarmac when it's
running!

My intention is to get tonto-2.1 running with gfortran.  If you have time, I'd
love you to do likewise.

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-19 Thread hjl at gcc dot gnu dot org


--- Comment #7 from hjl at gcc dot gnu dot org  2006-05-20 00:28 ---
Subject: Bug 27662

Author: hjl
Date: Sat May 20 00:28:14 2006
New Revision: 113922

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=113922
Log:
gcc/fortran/

2006-05-19  H.J. Lu  [EMAIL PROTECTED]

PR fortran/27662
* trans-array.c (gfc_conv_expr_descriptor): Don't zere the
first stride to indicate a temporary.
* trans-expr.c (gfc_conv_function_call): Likewise.

gcc/testsuite/

2006-05-19  H.J. Lu  [EMAIL PROTECTED]

PR fortran/27662
* gfortran.dg/temporary_1.f90: New file.

Added:
trunk/gcc/testsuite/gfortran.dg/temporary_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread hjl at lucon dot org


--- Comment #1 from hjl at lucon dot org  2006-05-18 18:24 ---
This testcase is derived from Tonto in SPEC CPU 2006.


-- 

hjl at lucon dot org changed:

   What|Removed |Added

OtherBugsDependingO||15502
  nThis||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread kargl at gcc dot gnu dot org


--- Comment #2 from kargl at gcc dot gnu dot org  2006-05-18 20:41 ---
Actually, transpose by itself does the right thing.  It is the
combination of matmul and transpose that is screwing up indexing.
A slightly modified version of your program gives

troutmask:kargl[290] ./z
 1.0 0.0 0.0 1.0 -- x
 1.0 0.0 0.0 1.0 -- a = test()
 1.0 0.0 0.0 1.0 -- a = transpose(test())
 1.0 0.0 0.0 1.0 -- z = matmul(x,a)
 1.0 0.0 1.0 0.0 -- z = matmul(x,transpose(test()))
Abort (core dumped)

Here the program.

program foo

 implicit none

 real(kind=kind(1.0d0)), dimension(2, 2):: x, z, a
 integer i, j

 x(1,1) = 1.d0 
 x(2,1) = 0.d0
 x(1,2) = 0.d0
 x(2,2) = 1.d0 
!
! Uncomment to see the output.
!
  print '(4F4.1,1X,A)', x(1,1), x(2,1), x(1,2), x(2,2), '-- x'
  a = test()
  print '(4F4.1,1X,A)', a(1,1), a(2,1), a(1,2), a(2,2), '-- a = test()'
  a = transpose(test())
  print '(4F4.1,1X,A)', a(1,1), a(2,1), a(1,2), a(2,2), 
   '-- a = transpose(test())'
  z = matmul(x, a)
  print '(4F4.1,1X,A)', z(1,1), z(2,1), z(1,2), z(2,2), '-- z = matmul(x,a)'
  z = matmul(x, transpose(test()))
  print '(4F4.1,1X,A)', z(1,1), z(2,1), z(1,2), z(2,2), 
   '-- z = matmul(x,transpose(test()))'

 z = matmul(x, transpose(test()))
 do i = 1, 2
   do j = 1, 2
 if (x(i,j) .ne. z(i,j)) call abort()
   end do
 end do
 close (10)

contains
 function test() result (res)
   real(kind=kind(1.0d0)), dimension(2,2) :: res
   res(1,1) = 1.d0 
   res(2,1) = 0.d0
   res(1,2) = 0.d0
   res(2,2) = 1.d0 
 end function
end


-- 

kargl at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2006-05-18 20:41:45
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread hjl at lucon dot org


--- Comment #3 from hjl at lucon dot org  2006-05-18 21:22 ---
I got

  atmp.17.dtype = 538;
  atmp.17.dim[0].stride = 2;
  atmp.17.dim[0].lbound = 0;
  atmp.17.dim[0].ubound = 1;
  atmp.17.dim[1].stride = 0; - Shouldn't it be 1?
  atmp.17.dim[1].lbound = 0;
  atmp.17.dim[1].ubound = 1;
  atmp.17.data = A.16;
  atmp.17.offset = 0;
  _gfortran_matmul_r8 (parm.13, parm.14, atmp.17);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread hjl at lucon dot org


--- Comment #4 from hjl at lucon dot org  2006-05-18 21:54 ---
Also

atmp.6.dtype = 538;
atmp.6.dim[0].stride = 1;
atmp.6.dim[0].lbound = 0;
atmp.6.dim[0].ubound = 1;
atmp.6.dim[1].stride = 2;
atmp.6.dim[1].lbound = 0;
atmp.6.dim[1].ubound = 1;
atmp.6.data = (void *) A.7;
atmp.6.offset = 0;
atmp.6.dim[0].stride = 0;  -- That causes the problem.
test (atmp.6);
atmp.8.dtype = atmp.6.dtype;
atmp.8.dim[0].stride = atmp.6.dim[1].stride;
atmp.8.dim[0].lbound = atmp.6.dim[1].lbound;
atmp.8.dim[0].ubound = atmp.6.dim[1].ubound;
atmp.8.dim[1].stride = atmp.6.dim[0].stride;
atmp.8.dim[1].lbound = atmp.6.dim[0].lbound;
atmp.8.dim[1].ubound = atmp.6.dim[0].ubound;
atmp.8.data = atmp.6.data;
atmp.8.offset = atmp.6.offset;
_gfortran_matmul_r8 (parm.4, parm.5, atmp.8);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread hjl at lucon dot org


--- Comment #5 from hjl at lucon dot org  2006-05-18 22:21 ---
There are

   2042   /* Zero the first stride to indicate a temporary.  */
   2043   tmp = gfc_conv_descriptor_stride (info-descriptor,
gfc_rank_cst[0]);
   2044   gfc_add_modify_expr (se-pre, tmp,
   2045convert (TREE_TYPE (tmp),
integer_zero_node));

in gfc_conv_function_call. Later transpose is called on it. But we never
restore the first stride.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662



[Bug fortran/27662] Transpose doesn't work on function return

2006-05-18 Thread hjl at lucon dot org


--- Comment #6 from hjl at lucon dot org  2006-05-18 23:02 ---
This hack works for the testcase. But I don't know if it is the correct fix
or not.

2006-05-17  H.J. Lu  [EMAIL PROTECTED]

PR fortran/27662
* trans-expr.c (gfc_conv_function_call) Restore the first
stride after the function call.

--- gcc/fortran/trans-expr.c.transpose  2006-04-16 11:18:33.0 -0700
+++ gcc/fortran/trans-expr.c2006-05-18 15:55:30.0 -0700
@@ -2022,6 +2022,8 @@ gfc_conv_function_call (gfc_se * se, gfc
retargs = gfc_chainon_list (retargs, se-expr);
   else if (sym-result-attr.dimension)
{
+ tree stride;
+
  gcc_assert (se-loop  info);

  /* Set the type of the array.  */
@@ -2039,14 +2041,17 @@ gfc_conv_function_call (gfc_se * se, gfc
   false, !sym-attr.pointer,
callee_alloc);
  /* Zero the first stride to indicate a temporary.  */
- tmp = gfc_conv_descriptor_stride (info-descriptor, gfc_rank_cst[0]);
- gfc_add_modify_expr (se-pre, tmp,
-  convert (TREE_TYPE (tmp), integer_zero_node));
+ stride = gfc_conv_descriptor_stride (info-descriptor,
gfc_rank_cst[0]);
+ gfc_add_modify_expr (se-pre, stride,
+  convert (TREE_TYPE (stride),
integer_zero_node));
  /* Pass the temporary as the first argument.  */
  tmp = info-descriptor;
  tmp = build_fold_addr_expr (tmp);
  retargs = gfc_chainon_list (retargs, tmp);
+
+ /* Restore the first stride after the function call.  */
+ gfc_add_modify_expr (post, stride, info-stride [0]);
}
   else if (ts.type == BT_CHARACTER)
{


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662