public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/96890] New: Wrong answer with intrinsic IALL
@ 2020-09-02  1:19 zhen.xu@compiler-dev.com
  2020-09-02 21:17 ` [Bug libfortran/96890] " anlauf at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-02  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96890
           Summary: Wrong answer with intrinsic IALL
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhen.xu@compiler-dev.com
  Target Milestone: ---

I got wrong answer with iall, only when all 3 parameters ARRAY/DIM/MASK are all
present and the rank of array >1.

---------------------------test code-----------------------
program test_f90_intrinsics
  integer :: i, j, k
  integer, dimension(2) :: ia1
  integer, dimension(2,2) :: ia2
  integer, dimension(2,2,2) :: ia3
  integer, dimension(2,2,2,2) :: ia4
  logical, dimension(2) :: mask1
  logical, dimension(2, 2) :: mask2
  logical, dimension(2, 2, 2) :: mask3
  logical, dimension(2, 2, 2, 2) :: mask4

  data ia1 /  1,  2 /
  data ia2 /  1,  2,  3, 4 /
  data ia3 /  1,  2,  3, 4,  5,  6,  7, 8 /
  data ia4 /  1,  2,  3, 4,  5,  6,  7, 8, &
    9, 10, 11, 12, 13, 14, 15, 16 /

  data mask1 / .true., .false. /
  data mask2 / .true., .false., .true., .false. /
  data mask3 / .true., .false., .true., .false., &
    .true., .false., .true., .false. /
  data mask4 / .true., .false., .true., .false., &
    .true., .false., .true., .false., .true., &
    .false., .true., .false., .true., .false., &
    .true., .false. /


  print *, '---------test 1-----------'
  print *, iall(ia2, 2, mask2)

  print *, '---------test 2-----------'
  print *, iall(ia3, 2, mask3)

  print *, '---------test 3-----------'
  print *, iall(ia4, 2, mask4)

end
-----------------------------------------------------------

With gfortran I got wrong result:
---------test 1-----------
          0           0
---------test 2-----------
          0           0           0           0
---------test 3-----------
          0           0           0           0           0           0        
  0           0


The expected result(checked with ifort) should be:
---------test 1-----------
           1           -1
---------test 2-----------
           1           -1            5           -1
---------test 3-----------
           1           -1            5           -1            9           -1
          13           -1

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
@ 2020-09-02 21:17 ` anlauf at gcc dot gnu.org
  2020-09-03  4:56 ` kargl at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-02 21:17 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |libfortran
             Status|UNCONFIRMED                 |NEW
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2020-09-02
     Ever confirmed|0                           |1
           Priority|P3                          |P4

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

Obvious fix:

diff --git a/libgfortran/m4/iall.m4 b/libgfortran/m4/iall.m4
index df57367c100..8f3b7741486 100644
--- a/libgfortran/m4/iall.m4
+++ b/libgfortran/m4/iall.m4
@@ -35,7 +35,7 @@ ARRAY_FUNCTION(0,
 `  result &= *src;')

 MASKED_ARRAY_FUNCTION(0,
-`  result = 0;',
+`  result = ('rtype_name`) -1;',
 `  if (*msrc)
     result &= *src;')

and regenerating the iall_i*.c files.

How does one do this BTW?

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
  2020-09-02 21:17 ` [Bug libfortran/96890] " anlauf at gcc dot gnu.org
@ 2020-09-03  4:56 ` kargl at gcc dot gnu.org
  2020-09-03 14:32 ` anlauf at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-09-03  4:56 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to anlauf from comment #1)
> Confirmed.
> 
> Obvious fix:
> 
> diff --git a/libgfortran/m4/iall.m4 b/libgfortran/m4/iall.m4
> index df57367c100..8f3b7741486 100644
> --- a/libgfortran/m4/iall.m4
> +++ b/libgfortran/m4/iall.m4
> @@ -35,7 +35,7 @@ ARRAY_FUNCTION(0,
>  `  result &= *src;')
>  
>  MASKED_ARRAY_FUNCTION(0,
> -`  result = 0;',
> +`  result = ('rtype_name`) -1;',
>  `  if (*msrc)
>      result &= *src;')
>  
> and regenerating the iall_i*.c files.
> 
> How does one do this BTW?

At one point, you did it by using --maintainer-mode with configure.
With the move to git and other changes, I don't know if this has
changed.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
  2020-09-02 21:17 ` [Bug libfortran/96890] " anlauf at gcc dot gnu.org
  2020-09-03  4:56 ` kargl at gcc dot gnu.org
@ 2020-09-03 14:32 ` anlauf at gcc dot gnu.org
  2020-09-03 14:40 ` sgk at troutmask dot apl.washington.edu
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-03 14:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> At one point, you did it by using --maintainer-mode with configure.
> With the move to git and other changes, I don't know if this has
> changed.

Well, --enable-maintainer-mode exists, but then I hit for libgomp:

WARNING: 'aclocal-1.16' is missing on your system.

% aclocal --version
aclocal (GNU automake) 1.15.1

Giving up for someone else to take it up.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (2 preceding siblings ...)
  2020-09-03 14:32 ` anlauf at gcc dot gnu.org
@ 2020-09-03 14:40 ` sgk at troutmask dot apl.washington.edu
  2020-09-03 15:07 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-09-03 14:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Sep 03, 2020 at 02:32:32PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96890
> 
> --- Comment #3 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #2)
> > At one point, you did it by using --maintainer-mode with configure.
> > With the move to git and other changes, I don't know if this has
> > changed.
> 
> Well, --enable-maintainer-mode exists, but then I hit for libgomp:
> 

Yes, that's the option.

> WARNING: 'aclocal-1.16' is missing on your system.
> 
> % aclocal --version
> aclocal (GNU automake) 1.15.1

Yep. This is a pain of --enable-maintainer-mode, it 
runs the autotools over the src hierarchy.  There is
supposedly another way to regenerate the libgfortran
source from the m4 files, but I cannot remember it.

> 
> Giving up for someone else to take it up.
> 

Ping Thomas.  I recall seeing that he recently was
asking about --enable-maintainer-mode in a git 
world.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (3 preceding siblings ...)
  2020-09-03 14:40 ` sgk at troutmask dot apl.washington.edu
@ 2020-09-03 15:07 ` anlauf at gcc dot gnu.org
  2020-09-03 18:33 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-03 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #4)
> Ping Thomas.  I recall seeing that he recently was
> asking about --enable-maintainer-mode in a git 
> world.

Hacking the Makfile in x86_64-pc-linux-gnu/libgfortran/Makefile
and manually activating the dependency

$(i_iall_c): m4/iall.m4 $(I_M4_DEPS1)
        $(M4) -Dfile=$@ -I$(srcdir)/m4 iall.m4 > $@

does the job, too.

Ugh.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (4 preceding siblings ...)
  2020-09-03 15:07 ` anlauf at gcc dot gnu.org
@ 2020-09-03 18:33 ` cvs-commit at gcc dot gnu.org
  2020-09-03 18:51 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-03 18:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:8eeeecbcc17041fdfd3ccc928161ae86e7f9b456

commit r11-3000-g8eeeecbcc17041fdfd3ccc928161ae86e7f9b456
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Sep 3 20:33:14 2020 +0200

    PR fortran/96890 - Wrong answer with intrinsic IALL

    The IALL intrinsic would always return 0 when the DIM and MASK arguments
    were present since the initial value of repeated BIT-AND operations was
    set to 0 instead of -1.

    libgfortran/ChangeLog:

            * m4/iall.m4: Initial value for result should be -1.
            * generated/iall_i1.c (miall_i1): Generated.
            * generated/iall_i16.c (miall_i16): Likewise.
            * generated/iall_i2.c (miall_i2): Likewise.
            * generated/iall_i4.c (miall_i4): Likewise.
            * generated/iall_i8.c (miall_i8): Likewise.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/iall_masked.f90: New test.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (5 preceding siblings ...)
  2020-09-03 18:33 ` cvs-commit at gcc dot gnu.org
@ 2020-09-03 18:51 ` anlauf at gcc dot gnu.org
  2020-09-08 20:20 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-03 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org

--- Comment #7 from anlauf at gcc dot gnu.org ---
Fixed on master.

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (6 preceding siblings ...)
  2020-09-03 18:51 ` anlauf at gcc dot gnu.org
@ 2020-09-08 20:20 ` cvs-commit at gcc dot gnu.org
  2020-09-09 19:39 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-08 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:19c2bd56876302aebb2bdc20b376395931cd5041

commit r10-8718-g19c2bd56876302aebb2bdc20b376395931cd5041
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Sep 3 20:33:14 2020 +0200

    PR fortran/96890 - Wrong answer with intrinsic IALL

    The IALL intrinsic would always return 0 when the DIM and MASK arguments
    were present since the initial value of repeated BIT-AND operations was
    set to 0 instead of -1.

    libgfortran/ChangeLog:

            * m4/iall.m4: Initial value for result should be -1.
            * generated/iall_i1.c (miall_i1): Generated.
            * generated/iall_i16.c (miall_i16): Likewise.
            * generated/iall_i2.c (miall_i2): Likewise.
            * generated/iall_i4.c (miall_i4): Likewise.
            * generated/iall_i8.c (miall_i8): Likewise.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/iall_masked.f90: New test.

    (cherry picked from commit 8eeeecbcc17041fdfd3ccc928161ae86e7f9b456)

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (7 preceding siblings ...)
  2020-09-08 20:20 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 19:39 ` cvs-commit at gcc dot gnu.org
  2020-09-09 19:43 ` cvs-commit at gcc dot gnu.org
  2020-09-09 19:44 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-09 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:32f34977d60cafce47e10e601d7ccc7bbfbfabb9

commit r9-8854-g32f34977d60cafce47e10e601d7ccc7bbfbfabb9
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Sep 3 20:33:14 2020 +0200

    PR fortran/96890 - Wrong answer with intrinsic IALL

    The IALL intrinsic would always return 0 when the DIM and MASK arguments
    were present since the initial value of repeated BIT-AND operations was
    set to 0 instead of -1.

    libgfortran/ChangeLog:

            * m4/iall.m4: Initial value for result should be -1.
            * generated/iall_i1.c (miall_i1): Generated.
            * generated/iall_i16.c (miall_i16): Likewise.
            * generated/iall_i2.c (miall_i2): Likewise.
            * generated/iall_i4.c (miall_i4): Likewise.
            * generated/iall_i8.c (miall_i8): Likewise.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/iall_masked.f90: New test.

    (cherry picked from commit 8eeeecbcc17041fdfd3ccc928161ae86e7f9b456)

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (8 preceding siblings ...)
  2020-09-09 19:39 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 19:43 ` cvs-commit at gcc dot gnu.org
  2020-09-09 19:44 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-09 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:b8c7eae4be6fccfe24ed36d618c0f2d67256e993

commit r8-10441-gb8c7eae4be6fccfe24ed36d618c0f2d67256e993
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Sep 3 20:33:14 2020 +0200

    PR fortran/96890 - Wrong answer with intrinsic IALL

    The IALL intrinsic would always return 0 when the DIM and MASK arguments
    were present since the initial value of repeated BIT-AND operations was
    set to 0 instead of -1.

    libgfortran/ChangeLog:

            * m4/iall.m4: Initial value for result should be -1.
            * generated/iall_i1.c (miall_i1): Generated.
            * generated/iall_i16.c (miall_i16): Likewise.
            * generated/iall_i2.c (miall_i2): Likewise.
            * generated/iall_i4.c (miall_i4): Likewise.
            * generated/iall_i8.c (miall_i8): Likewise.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/iall_masked.f90: New test.

    (cherry picked from commit 8eeeecbcc17041fdfd3ccc928161ae86e7f9b456)

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

* [Bug libfortran/96890] Wrong answer with intrinsic IALL
  2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
                   ` (9 preceding siblings ...)
  2020-09-09 19:43 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 19:44 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-09 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #11 from anlauf at gcc dot gnu.org ---
Fixed on all open branches.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2020-09-09 19:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02  1:19 [Bug fortran/96890] New: Wrong answer with intrinsic IALL zhen.xu@compiler-dev.com
2020-09-02 21:17 ` [Bug libfortran/96890] " anlauf at gcc dot gnu.org
2020-09-03  4:56 ` kargl at gcc dot gnu.org
2020-09-03 14:32 ` anlauf at gcc dot gnu.org
2020-09-03 14:40 ` sgk at troutmask dot apl.washington.edu
2020-09-03 15:07 ` anlauf at gcc dot gnu.org
2020-09-03 18:33 ` cvs-commit at gcc dot gnu.org
2020-09-03 18:51 ` anlauf at gcc dot gnu.org
2020-09-08 20:20 ` cvs-commit at gcc dot gnu.org
2020-09-09 19:39 ` cvs-commit at gcc dot gnu.org
2020-09-09 19:43 ` cvs-commit at gcc dot gnu.org
2020-09-09 19:44 ` anlauf 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).