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

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).