This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/29391] LBOUND(TRANSPOSE(I)) doesn't work



------- Comment #6 from fxcoudert at gcc dot gnu dot org  2006-10-11 07:26 -------
With the following patch:

Index: trans-array.c
===================================================================
--- trans-array.c       (revision 117560)
+++ trans-array.c       (working copy)
@@ -661,10 +661,12 @@
       gfc_add_modify_expr (pre, tmp, size);

       tmp = gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n]);
-      gfc_add_modify_expr (pre, tmp, gfc_index_zero_node);
+      gfc_add_modify_expr (pre, tmp, gfc_index_one_node);

       tmp = gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]);
-      gfc_add_modify_expr (pre, tmp, loop->to[n]);
+      gfc_add_modify_expr (pre, tmp,
+                          fold_build2 (PLUS_EXPR, gfc_array_index_type,
+                                       loop->to[n], gfc_index_one_node));

       tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
                         loop->to[n], gfc_index_one_node);
@@ -787,11 +789,17 @@

       gfc_add_modify_expr (&se->pre,
                           gfc_conv_descriptor_lbound (dest, dest_index),
-                          gfc_conv_descriptor_lbound (src, src_index));
+                          gfc_index_one_node);

       gfc_add_modify_expr (&se->pre,
                           gfc_conv_descriptor_ubound (dest, dest_index),
-                          gfc_conv_descriptor_ubound (src, src_index));
+                          fold_build2 (PLUS_EXPR, gfc_array_index_type,
+                               gfc_index_one_node,
+                               fold_build2 (MINUS_EXPR, gfc_array_index_type,
+                                            gfc_conv_descriptor_ubound
+                                              (src, src_index),
+                                            gfc_conv_descriptor_lbound
+                                              (src, src_index))));

       if (!loop->to[n])
         {

I get all intrinsics that work through temporaries working right:
  integer :: i(-1:1,-1:1) = 0
  integer :: j(-1:2) = 0

  ! Was already working
  write(*,*) lbound(i(-1:1,-1:1)), ubound(i(-1:1,-1:1))
  write(*,*) lbound(i(:,:)), ubound(i(:,:))
  write(*,*) lbound(i(0:,-1:)), ubound(i(0:,-1:))
  write(*,*) lbound(i(:0,:1)), ubound(i(:0,:1))

  ! Fixed
  write(*,*) lbound(transpose(i)), ubound(transpose(i))
  write(*,*) lbound(reshape(i,(/2,2/))), ubound(reshape(i,(/2,2/)))
  write(*,*) lbound(cshift(i,-1)), ubound(cshift(i,-1))
  write(*,*) lbound(eoshift(i,-1)), ubound(eoshift(i,-1))
  write(*,*) lbound(spread(i,1,2)), ubound(spread(i,1,2))
  write(*,*) lbound(maxloc(i)), ubound(maxloc(i))
  write(*,*) lbound(minloc(i)), ubound(minloc(i))
  write(*,*) lbound(maxval(i,2)), ubound(maxval(i,2))
  write(*,*) lbound(minval(i,2)), ubound(minval(i,2))
  write(*,*) lbound(any(i==1,2)), ubound(any(i==1,2))
  write(*,*) lbound(count(i==1,2)), ubound(count(i==1,2))
  write(*,*) lbound(merge(i,i,.true.)), ubound(merge(i,i,.true.))
  write(*,*) lbound(lbound(i)), ubound(lbound(i))
  write(*,*) lbound(ubound(i)), ubound(ubound(i))
  write(*,*) lbound(shape(i)), ubound(shape(i))

  ! Still not working
  write(*,*) lbound(product(i,2)), ubound(product(i,2))
  write(*,*) lbound(sum(i,2)), ubound(sum(i,2))
  write(*,*) lbound(matmul(i,i)), ubound(matmul(i,i))
  write(*,*) lbound(pack(i,.true.)), ubound(pack(i,.true.))
  write(*,*) lbound(unpack(j,(/.true./),(/2/))), &
             ubound(unpack(j,(/.true./),(/2/))) 

end


So I only have PRODUCT, SUM, MATMUL, PACK and UNPACK to work on.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]