public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
@ 2014-07-11 16:38 dominiq at lps dot ens.fr
  2014-07-11 16:42 ` [Bug fortran/61780] " dominiq at lps dot ens.fr
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-11 16:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

            Bug ID: 61780
           Summary: [4.8/4.9/4.10 Regression] Wrong code when shifting
                    elements of a multidimensional array
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dominiq at lps dot ens.fr
                CC: pault at gcc dot gnu.org, tkoenig at gcc dot gnu.org

>From https://groups.google.com/forum/#!topic/comp.lang.fortran/mfS-BB2X-90, the
following code gives a wrong result at run time

program prgm3 
    implicit none 
    integer, parameter :: n = 10, k = 3 
    integer :: i, j 
    integer, dimension(n,n) :: y 
    integer :: res1(n), res2(n)

1   format(10i5) 

!initialize 
    do i=1,n 
        do j=1,n 
            y(i,j) = n*i + j 
        end do 
    end do 
    res2 = y(k,:) 

!shift right 
    y(k,4:n) = y(k,3:n-1) 
    y(k,3) = 0 
    res1 = y(k,:)
    y(k,:) = res2
    y(k,n:4:-1) = y(k,n-1:3:-1) 
    y(k,3) = 0 
    res2 = y(k,:) 
    print *, res1
    print *, res2
    if (any(res1 /= res2)) call abort () 

end program prgm3 

Revision r174295 (2011-05-26) is OK, r174338 (2011-05-27) is not, likely
r174302 (pr48955).


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
@ 2014-07-11 16:42 ` dominiq at lps dot ens.fr
  2014-07-12 11:43 ` mikael at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-11 16:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-07-11
      Known to work|                            |4.6.0
     Ever confirmed|0                           |1
      Known to fail|                            |4.10.0, 4.8.3, 4.9.0


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
  2014-07-11 16:42 ` [Bug fortran/61780] " dominiq at lps dot ens.fr
@ 2014-07-12 11:43 ` mikael at gcc dot gnu.org
  2014-07-12 12:39 ` pault at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-07-12 11:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
This sets loop reversal in dependency.c:
          /* Set reverse if backward dependence and not inhibited.  */
          if (reverse && reverse[n] == GFC_ENABLE_REVERSE)
            reverse[n] = (this_dep == GFC_DEP_BACKWARD) ?
                     GFC_REVERSE_SET : reverse[n];

However, the 'n' used indexes over array ref dimension, so in the case at hand
the second element is flagged as GFC_REVERSE_SET.
But the 'reverse' array is used later on using scalarizer dimensions, and as
y(k,4:n) and y(k,3:n-1) are one-dimension arrays, only the first element of
'reverse' is ever looked at.


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
  2014-07-11 16:42 ` [Bug fortran/61780] " dominiq at lps dot ens.fr
  2014-07-12 11:43 ` mikael at gcc dot gnu.org
@ 2014-07-12 12:39 ` pault at gcc dot gnu.org
  2014-07-12 15:18 ` paul.richard.thomas at gmail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-12 12:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 33111
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33111&action=edit
Patch for the PR

The loop reversal mechanism was missing the element before the reversed loop.
In consequence loop.reverse[1] was being set instead of loop.reverse[0], which
corresponds to the loop dimension.

It regtests with dg.exp=gfortran.dg/dep* .  I am regtesting the whole suite
now.

I will commit to trunk as 'obvious' if all is well.

Cheers

Paul


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (2 preceding siblings ...)
  2014-07-12 12:39 ` pault at gcc dot gnu.org
@ 2014-07-12 15:18 ` paul.richard.thomas at gmail dot com
  2014-07-12 19:09 ` pault at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paul.richard.thomas at gmail dot com @ 2014-07-12 15:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #3 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> ---
Dear Mikael,

I didn't see your posting, which was about an hour before mine.  At
least we came to the same conclusion!

Thanks

Paul

On 12 July 2014 13:43, mikael at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780
>
> Mikael Morin <mikael at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |mikael at gcc dot gnu.org
>
> --- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
> This sets loop reversal in dependency.c:
>           /* Set reverse if backward dependence and not inhibited.  */
>           if (reverse && reverse[n] == GFC_ENABLE_REVERSE)
>             reverse[n] = (this_dep == GFC_DEP_BACKWARD) ?
>                      GFC_REVERSE_SET : reverse[n];
>
> However, the 'n' used indexes over array ref dimension, so in the case at hand
> the second element is flagged as GFC_REVERSE_SET.
> But the 'reverse' array is used later on using scalarizer dimensions, and as
> y(k,4:n) and y(k,3:n-1) are one-dimension arrays, only the first element of
> 'reverse' is ever looked at.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (3 preceding siblings ...)
  2014-07-12 15:18 ` paul.richard.thomas at gmail dot com
@ 2014-07-12 19:09 ` pault at gcc dot gnu.org
  2014-07-13 12:52 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-12 19:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sat Jul 12 19:09:11 2014
New Revision: 212486

URL: https://gcc.gnu.org/viewcvs?rev=212486&root=gcc&view=rev
Log:
2014-07-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * dependency.c (gfc_dep_resolver): Index the 'reverse' array so
    that elements are skipped. This then correctly aligns 'reverse'
    with the scalarizer loops.

2014-07-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * gfortran.dg/dependency_44.f90 : New test

Added:
    trunk/gcc/testsuite/gfortran.dg/dependency_44.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/61780] [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (4 preceding siblings ...)
  2014-07-12 19:09 ` pault at gcc dot gnu.org
@ 2014-07-13 12:52 ` mikael at gcc dot gnu.org
  2014-07-14 10:42 ` [Bug fortran/61780] [4.8/4.9 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-07-13 12:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to paul.richard.thomas@gmail.com from comment #3)
> Dear Mikael,
> 
> I didn't see your posting, which was about an hour before mine.  At
> least we came to the same conclusion!
> 
Yes, that's good. :-)
Thanks for the fix.


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

* [Bug fortran/61780] [4.8/4.9 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (5 preceding siblings ...)
  2014-07-13 12:52 ` mikael at gcc dot gnu.org
@ 2014-07-14 10:42 ` rguenth at gcc dot gnu.org
  2014-07-14 13:15 ` paul.richard.thomas at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-14 10:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.10.0
   Target Milestone|---                         |4.8.4
            Summary|[4.8/4.9/4.10 Regression]   |[4.8/4.9 Regression] Wrong
                   |Wrong code when shifting    |code when shifting elements
                   |elements of a               |of a multidimensional array
                   |multidimensional array      |
      Known to fail|4.10.0                      |


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

* [Bug fortran/61780] [4.8/4.9 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (6 preceding siblings ...)
  2014-07-14 10:42 ` [Bug fortran/61780] [4.8/4.9 " rguenth at gcc dot gnu.org
@ 2014-07-14 13:15 ` paul.richard.thomas at gmail dot com
  2014-07-19 13:50 ` pault at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paul.richard.thomas at gmail dot com @ 2014-07-14 13:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #6 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> ---
Dear Richie,

Thanks for doing that.  I was going to do 4.8 as soon as I had a
moment and would have changed the summary then. As it happens, I was
distracted by other activities (rewiring the kitchen....).

Cheers

Paul

On 14 July 2014 12:42, rguenth at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780
>
> Richard Biener <rguenth at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>       Known to work|                            |4.10.0
>    Target Milestone|---                         |4.8.4
>             Summary|[4.8/4.9/4.10 Regression]   |[4.8/4.9 Regression] Wrong
>                    |Wrong code when shifting    |code when shifting elements
>                    |elements of a               |of a multidimensional array
>                    |multidimensional array      |
>       Known to fail|4.10.0                      |
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.


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

* [Bug fortran/61780] [4.8/4.9 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (7 preceding siblings ...)
  2014-07-14 13:15 ` paul.richard.thomas at gmail dot com
@ 2014-07-19 13:50 ` pault at gcc dot gnu.org
  2014-07-19 14:31 ` pault at gcc dot gnu.org
  2014-07-19 14:32 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-19 13:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sat Jul 19 13:49:40 2014
New Revision: 212846

URL: https://gcc.gnu.org/viewcvs?rev=212846&root=gcc&view=rev
Log:
2014-07-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * dependency.c (gfc_dep_resolver): Index the 'reverse' array so
    that elements are skipped. This then correctly aligns 'reverse'
    with the scalarizer loops.

2014-07-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * gfortran.dg/dependency_44.f90 : New test

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/dependency_44.f90
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/dependency.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/61780] [4.8/4.9 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (8 preceding siblings ...)
  2014-07-19 13:50 ` pault at gcc dot gnu.org
@ 2014-07-19 14:31 ` pault at gcc dot gnu.org
  2014-07-19 14:32 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-19 14:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sat Jul 19 14:31:06 2014
New Revision: 212847

URL: https://gcc.gnu.org/viewcvs?rev=212847&root=gcc&view=rev
Log:
2014-07-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * dependency.c (gfc_dep_resolver): Index the 'reverse' array so
    that elements are skipped. This then correctly aligns 'reverse'
    with the scalarizer loops.

2014-07-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61780
    * gfortran.dg/dependency_44.f90 : New test

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/dependency_44.f90
Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/dependency.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/61780] [4.8/4.9 Regression] Wrong code when shifting elements of a multidimensional array
  2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
                   ` (9 preceding siblings ...)
  2014-07-19 14:31 ` pault at gcc dot gnu.org
@ 2014-07-19 14:32 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-19 14:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61780

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on 4.8, 4.9 and trunk.

Thanks for the report

Paul


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

end of thread, other threads:[~2014-07-19 14:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-11 16:38 [Bug fortran/61780] New: [4.8/4.9/4.10 Regression] Wrong code when shifting elements of a multidimensional array dominiq at lps dot ens.fr
2014-07-11 16:42 ` [Bug fortran/61780] " dominiq at lps dot ens.fr
2014-07-12 11:43 ` mikael at gcc dot gnu.org
2014-07-12 12:39 ` pault at gcc dot gnu.org
2014-07-12 15:18 ` paul.richard.thomas at gmail dot com
2014-07-12 19:09 ` pault at gcc dot gnu.org
2014-07-13 12:52 ` mikael at gcc dot gnu.org
2014-07-14 10:42 ` [Bug fortran/61780] [4.8/4.9 " rguenth at gcc dot gnu.org
2014-07-14 13:15 ` paul.richard.thomas at gmail dot com
2014-07-19 13:50 ` pault at gcc dot gnu.org
2014-07-19 14:31 ` pault at gcc dot gnu.org
2014-07-19 14:32 ` pault 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).