public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37749]  New: ICE on array section with vector subscript
@ 2008-10-06 14:04 jakub at gcc dot gnu dot org
  2008-10-06 19:48 ` [Bug fortran/37749] " burnus at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-06 14:04 UTC (permalink / raw)
  To: gcc-bugs

subroutine subr (m, n, a, b, c, d, p)
  implicit none
  integer m, n
  real a(m,n), b(m,n), c(n,n), d(m,n)
  integer p(n)
  d = a(:,p) - matmul(b, c)
end subroutine

  implicit none
  integer i
  real a(3,2), b(3,2), c(2,2), d(3,2)
  integer p(2)
  a = reshape ((/(i, i = 1, 6)/), (/3, 2/))
  b = 1
  c = 2
  p = 2
  call subr (3, 2, a, b, c, d, p)
  if (any (d .ne. reshape ((/(mod (i + 2, 3), i = 1, 6)/), (/3, 2/)))) call
abort
end

ICEs because a loop bound (loop->to[0]) hasn't been set.


-- 
           Summary: ICE on array section with vector subscript
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
@ 2008-10-06 19:48 ` burnus at gcc dot gnu dot org
  2008-10-29 21:00 ` mikael dot morin at tele2 dot fr
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-10-06 19:48 UTC (permalink / raw)
  To: gcc-bugs



-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.1.3 4.2.2 4.3.0 4.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-06 19:47:31
               date|                            |


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
  2008-10-06 19:48 ` [Bug fortran/37749] " burnus at gcc dot gnu dot org
@ 2008-10-29 21:00 ` mikael dot morin at tele2 dot fr
  2008-10-29 21:06 ` mikael dot morin at tele2 dot fr
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mikael dot morin at tele2 dot fr @ 2008-10-29 21:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mikael dot morin at tele2 dot fr  2008-10-29 20:59 -------
Reduced case:

subroutine subr (m, n, a, b, c, d, p)
  implicit none
  integer m, n
  real a(m,n), b(m,n), c(n,n), d(m,n)
  integer p(n)
  d = a(:,p) - matmul(b, c)
end subroutine


The problem is with a(:,p) - matmul(b,c)

It arises because:
(1) gfc_conv_loop_setup chooses matmul's ss to setup the loop bounds. 
    This explains why -matmul(b,c) + a(:,p) works.
(2) The loop->to are asserted to be NULL in gfc_conv_loop_setup
    (GFC_SS_FUNCTION case)
(3) gfc_add_ss_loop_code for the second dimension of a(:,p) calls
    gfc_set_loop_bounds_from_array_spec which sets the second dimension of
    the loop.to
(4) in the loop setting the descriptor in gfc_trans_create_temp_array, 
    in the first iteration, (n = 0), loop.to is NULL, and the size is set to
    NULL. 
(5) In the next iteration, (n = 1), loop.to != NULL, and the loop follows
    the normal path. The size however was set to NULL (condition (4)).


(4) and (5) explain why it works with a(q,:) - matmul(b,c)


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
  2008-10-06 19:48 ` [Bug fortran/37749] " burnus at gcc dot gnu dot org
  2008-10-29 21:00 ` mikael dot morin at tele2 dot fr
@ 2008-10-29 21:06 ` mikael dot morin at tele2 dot fr
  2008-10-30 11:13 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mikael dot morin at tele2 dot fr @ 2008-10-29 21:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mikael dot morin at tele2 dot fr  2008-10-29 21:06 -------
Created an attachment (id=16585)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16585&action=view)
proposed patch, regression tested

This patch solves the problem by going through all the loop dimensions in
gfc_trans_create_temp_array to look for a NULL loop->to before the actual loop
execution and set size to NULL if one is found (it solves conditions (4) and
(5)).


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-10-29 21:06 ` mikael dot morin at tele2 dot fr
@ 2008-10-30 11:13 ` pault at gcc dot gnu dot org
  2008-10-30 20:50 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-10-30 11:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2008-10-30 11:13 -------
(In reply to comment #2)
> Created an attachment (id=16585)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16585&action=view) [edit]
> proposed patch, regression tested
> 
> This patch solves the problem by going through all the loop dimensions in
> gfc_trans_create_temp_array to look for a NULL loop->to before the actual loop
> execution and set size to NULL if one is found (it solves conditions (4) and
> (5)).
> 
Mikael,

I was going to suggest that you look at this PR, since you have clearly
attacked  the scalarizer.  Same question as before - do you have commit rights?

Paul


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-10-30 11:13 ` pault at gcc dot gnu dot org
@ 2008-10-30 20:50 ` pault at gcc dot gnu dot org
  2008-11-01 19:48 ` pault at gcc dot gnu dot org
  2008-11-01 19:49 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-10-30 20:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2008-10-30 20:47 -------
Subject: Bug 37749

Author: pault
Date: Thu Oct 30 20:45:09 2008
New Revision: 141467

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141467
Log:
2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37903
        * trans-array.c (gfc_trans_create_temp_array): If n is less
        than the temporary dimension, assert that loop->from is
        zero (reverts to earlier versions). If there is at least one
        null loop->to[n], it is a callee allocated array so set the
        size to NULL and break.
        (gfc_trans_constant_array_constructor): Set the offset to zero.
        (gfc_trans_array_constructor): Remove loop shifting around the
        temporary creation.
        (gfc_conv_loop_setup): Prefer zero-based descriptors if
        possible.  Calculate the translation from loop variables to
        array indices if an array constructor.

2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37749
        * trans-array.c (gfc_trans_create_temp_array): If size is NULL
        use the array bounds for loop->to.

2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37903
        * gfortran.dg/vector_subscript_4.f90: New test.

2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37749
        * gfortran.dg/vector_subscript__5.f90: New test.

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


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-10-30 20:50 ` pault at gcc dot gnu dot org
@ 2008-11-01 19:48 ` pault at gcc dot gnu dot org
  2008-11-01 19:49 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-01 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2008-11-01 19:47 -------
Subject: Bug 37749

Author: pault
Date: Sat Nov  1 19:45:41 2008
New Revision: 141521

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141521
Log:
2008-11-01  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37903
        * trans-array.c (gfc_trans_create_temp_array): If n is less
        than the temporary dimension, assert that loop->from is
        zero (reverts to earlier versions). If there is at least one
        null loop->to[n], it is a callee allocated array so set the
        size to NULL and break.
        (gfc_trans_constant_array_constructor): Set the offset to zero.
        (gfc_trans_array_constructor): Remove loop shifting around the
        temporary creation.
        (gfc_conv_loop_setup): Prefer zero-based descriptors if
        possible.  Calculate the translation from loop variables to
        array indices if an array constructor.

2008-11-01  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37749
        * trans-array.c (gfc_trans_create_temp_array): If size is NULL
        use the array bounds for loop->to.

2008-11-01  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37903
        * gfortran.dg/vector_subscript_4.f90: New test.

2008-11-01  Mikael Morin  <mikael.morin@tele2.fr>

        PR fortran/37749
        * gfortran.dg/vector_subscript__5.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/vector_subscript_4.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/vector_subscript_5.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/trans-array.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/37749] ICE on array section with vector subscript
  2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-11-01 19:48 ` pault at gcc dot gnu dot org
@ 2008-11-01 19:49 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-01 19:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2008-11-01 19:47 -------
Jakub,

Thanks for the report - fixed by Mikael on trunk and 4.3.

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=37749


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-01 19:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-06 14:04 [Bug fortran/37749] New: ICE on array section with vector subscript jakub at gcc dot gnu dot org
2008-10-06 19:48 ` [Bug fortran/37749] " burnus at gcc dot gnu dot org
2008-10-29 21:00 ` mikael dot morin at tele2 dot fr
2008-10-29 21:06 ` mikael dot morin at tele2 dot fr
2008-10-30 11:13 ` pault at gcc dot gnu dot org
2008-10-30 20:50 ` pault at gcc dot gnu dot org
2008-11-01 19:48 ` pault at gcc dot gnu dot org
2008-11-01 19:49 ` pault at gcc dot gnu dot 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).