public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
@ 2022-05-11  7:05 federico.perini at gmail dot com
  2022-05-11  7:51 ` [Bug fortran/105558] simple 8-bit " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: federico.perini at gmail dot com @ 2022-05-11  7:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105558
           Summary: simple 8-byte integer calculation fails with -O3 /
                    march=core-avx2 on some gfortran 8/9/10 versions
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

Created attachment 52950
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52950&action=edit
integer(1) test program

Hi gcc/gfortran team, 

I have two routines that encode and decode two integer(1) IDs (in [1:6] and
[1:32] respectively) to a unique 8-byte integer(1), for 192 possible cases. 

The example that fails should behave like

encode(1, 32) returns 77
decode(77) returns [1, 32]

but returns either [-5, 33] or sometimes [3,71]

With -O3, there are both versions and architectures of gfortran that either
work or not. On godbolt (https://godbolt.org/z/5GboahWs1), this is what I see: 


gfortran | -O3 -mtune=generic | -O3 -march=core-avx2 |
  12.1   |                OK  |                   OK |
  11.3   |                OK  |                   OK |
  11.2   |                OK  |                   OK |
  11.1   |                OK  |                   OK |
  10.3   |                OK  |                ERROR |
  10.2   |                OK  |                ERROR |
  10.1   |                OK  |                ERROR |
   9.4   |                OK  |                ERROR |
   9.3   |                OK  |                ERROR |
   9.2   |                OK  |                ERROR |
   9.1   |                OK  |                ERROR |
   8.5   |             ERROR  |                ERROR |
   8.4   |             ERROR  |                ERROR |
   8.3   |             ERROR  |                ERROR |
   8.2   |             ERROR  |                ERROR |
   8.1   |             ERROR  |                ERROR |
   7.3   |                OK  |                   OK |
   7.2   |                OK  |                   OK |
   7.1   |                OK  |                   OK |
   6.3   |                OK  |                   OK |
   5.5   |                OK  |                   OK |


Also note that: 
- problem is with int8 only; all is OK with int16,int32,int64
- no problems with -O2.

I'm attaching the code here as well, 
thank you,

Federico

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

* [Bug fortran/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
@ 2022-05-11  7:51 ` rguenth at gcc dot gnu.org
  2022-05-11  8:15 ` federico.perini at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-11  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-05-11
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Can I ask you to see whether -O3 -fno-tree-vectorize avoids the issue and
whether -O3 -fno-vect-cost-model makes the issue appear in more versions?  It
could be that this is a resolved issue that awaits backporting of a fix (or
where backporting is too difficult).

I can confirm the -O3 -march=core-avx2 failure with GCC 10 and success with GCC
11.

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

* [Bug fortran/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
  2022-05-11  7:51 ` [Bug fortran/105558] simple 8-bit " rguenth at gcc dot gnu.org
@ 2022-05-11  8:15 ` federico.perini at gmail dot com
  2022-05-11  8:17 ` federico.perini at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: federico.perini at gmail dot com @ 2022-05-11  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from federico <federico.perini at gmail dot com> ---
Ok so we have: 

gfortran | [...] -fno-tree-vectorize | [...] -fno-vect-cost-model
    10.3 |                        OK |                     ERROR
     9.3 |                        OK |                     ERROR 
     8.3 |                        OK |                     ERROR

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

* [Bug fortran/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
  2022-05-11  7:51 ` [Bug fortran/105558] simple 8-bit " rguenth at gcc dot gnu.org
  2022-05-11  8:15 ` federico.perini at gmail dot com
@ 2022-05-11  8:17 ` federico.perini at gmail dot com
  2022-07-15 10:45 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: federico.perini at gmail dot com @ 2022-05-11  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from federico <federico.perini at gmail dot com> ---
-fno-vect-cost model also does not change behavior on gcc 11/7/6/5 (all OK)

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

* [Bug fortran/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
                   ` (2 preceding siblings ...)
  2022-05-11  8:17 ` federico.perini at gmail dot com
@ 2022-07-15 10:45 ` marxin at gcc dot gnu.org
  2022-10-27  4:57 ` [Bug tree-optimization/105558] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-15 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
           Keywords|needs-bisection             |

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master with r11-3718-g91ae6930ed4a87d7.

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

* [Bug tree-optimization/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
                   ` (3 preceding siblings ...)
  2022-07-15 10:45 ` marxin at gcc dot gnu.org
@ 2022-10-27  4:57 ` pinskia at gcc dot gnu.org
  2022-10-27  4:58 ` [Bug tree-optimization/105558] [10 Regression] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-27  4:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #4)
> Fixed on master with r11-3718-g91ae6930ed4a87d7.

If anything that just made the issue latent I suspect.

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

* [Bug tree-optimization/105558] [10 Regression] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
                   ` (4 preceding siblings ...)
  2022-10-27  4:57 ` [Bug tree-optimization/105558] " pinskia at gcc dot gnu.org
@ 2022-10-27  4:58 ` pinskia at gcc dot gnu.org
  2023-07-07 10:00 ` [Bug tree-optimization/105558] " rguenth at gcc dot gnu.org
  2023-11-07  6:19 ` tkoenig at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-27  4:58 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|simple 8-bit integer        |[10 Regression] simple
                   |calculation fails with -O3  |8-bit integer calculation
                   |/ march=core-avx2 on some   |fails with -O3 /
                   |gfortran 8/9/10 versions    |march=core-avx2 on some
                   |                            |gfortran 8/9/10 versions
      Known to work|                            |7.3.0
      Known to fail|                            |8.1.0
   Target Milestone|---                         |10.5
           Keywords|                            |needs-bisection

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Would be interesting to find what patch broke this and what patch fixed the
-mtune=generic case.

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

* [Bug tree-optimization/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
                   ` (5 preceding siblings ...)
  2022-10-27  4:58 ` [Bug tree-optimization/105558] [10 Regression] " pinskia at gcc dot gnu.org
@ 2023-07-07 10:00 ` rguenth at gcc dot gnu.org
  2023-11-07  6:19 ` tkoenig at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10 Regression] simple      |simple 8-bit integer
                   |8-bit integer calculation   |calculation fails with -O3
                   |fails with -O3 /            |/ march=core-avx2 on some
                   |march=core-avx2 on some     |gfortran 8/9/10 versions
                   |gfortran 8/9/10 versions    |
      Known to fail|                            |10.5.0
   Target Milestone|10.5                        |---

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
We don't know the failure mode and the identified fix isn't likely the fix. 
Leaving open as non-regression.

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

* [Bug tree-optimization/105558] simple 8-bit integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions
  2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
                   ` (6 preceding siblings ...)
  2023-07-07 10:00 ` [Bug tree-optimization/105558] " rguenth at gcc dot gnu.org
@ 2023-11-07  6:19 ` tkoenig at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-11-07  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> Would be interesting to find what patch broke this and what patch fixed the
> -mtune=generic case.

It is not easy bisecting with old compilers - compilation issues keep
coming up on more modern systems, and sometimes newer compilers do
not compile older compilers...

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

end of thread, other threads:[~2023-11-07  6:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  7:05 [Bug fortran/105558] New: simple 8-byte integer calculation fails with -O3 / march=core-avx2 on some gfortran 8/9/10 versions federico.perini at gmail dot com
2022-05-11  7:51 ` [Bug fortran/105558] simple 8-bit " rguenth at gcc dot gnu.org
2022-05-11  8:15 ` federico.perini at gmail dot com
2022-05-11  8:17 ` federico.perini at gmail dot com
2022-07-15 10:45 ` marxin at gcc dot gnu.org
2022-10-27  4:57 ` [Bug tree-optimization/105558] " pinskia at gcc dot gnu.org
2022-10-27  4:58 ` [Bug tree-optimization/105558] [10 Regression] " pinskia at gcc dot gnu.org
2023-07-07 10:00 ` [Bug tree-optimization/105558] " rguenth at gcc dot gnu.org
2023-11-07  6:19 ` tkoenig 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).