public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3
@ 2021-08-03 16:22 federico.perini at gmail dot com
2021-08-03 16:26 ` [Bug fortran/101757] " federico.perini at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: federico.perini at gmail dot com @ 2021-08-03 16:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
Bug ID: 101757
Summary: Simple integer assigment fails (off-seted by -1) when
compiling with -O3
Product: gcc
Version: 7.1.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 51251
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51251&action=edit
test program
An extremely simple logical-flag-based assignment, which sets an integer to 1
if the logical is .true., and to 0 if .false., fails with gfortran 7.1.0 if
compiled with -O3. Using `WHERE`, `MERGE`, or a simple loop does not change the
result.
Test program:
program test_merge_
use iso_fortran_env
implicit none
integer, parameter :: N=10000
logical :: test(N)
integer :: i,itest(N)
do i=1,N
test(i) = mod(i,2)==0
end do
itest = merge(1,0,test)
print *, 'MERGE itest min (0) =',minval(itest),' max (1)=',maxval(itest)
where (test)
itest = 1
elsewhere
itest = 0
end where
print *, 'WHERE itest min (0) =',minval(itest),' max (1)=',maxval(itest)
do i=1,N
if (test(i)) then
itest(i) = 1
else
itest(i) = 0
endif
end do
print *, 'IFLOOP itest min (0) =',minval(itest),' max (1)=',maxval(itest)
end program test_merge_
Expected result is OK if "-O2", wrong if "-O3":
werc 1073% gfortran -O3 test_merge.f90
werc 1074% ./a.out
MERGE itest min (0) = -1 max (1)= 0
WHERE itest min (0) = -1 max (1)= 0
IFLOOP itest min (0) = -1 max (1)= 0
werc 1075% gfortran -O2 test_merge.f90
werc 1076% ./a.out
MERGE itest min (0) = 0 max (1)= 1
WHERE itest min (0) = 0 max (1)= 1
IFLOOP itest min (0) = 0 max (1)= 1
Tested OK on gfortran 9.2.0, 10.2.0, 10.3.0.
Thanks,
Federico
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/101757] Simple integer assigment fails (off-seted by -1) when compiling with -O3
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
@ 2021-08-03 16:26 ` federico.perini at gmail dot com
2021-08-03 16:40 ` federico.perini at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: federico.perini at gmail dot com @ 2021-08-03 16:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
--- Comment #1 from federico <federico.perini at gmail dot com> ---
Actually, the results are not "off-seted": whatever was to be set to 0 is
properly set; values that should be set "+1" are given "-1" instead:
itest(1)= 0 itest(2)=-1
test(1)= F test(2)= T
Federico
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/101757] Simple integer assigment fails (off-seted by -1) when compiling with -O3
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
2021-08-03 16:26 ` [Bug fortran/101757] " federico.perini at gmail dot com
@ 2021-08-03 16:40 ` federico.perini at gmail dot com
2021-08-03 17:30 ` [Bug tree-optimization/101757] [9 Regression] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: federico.perini at gmail dot com @ 2021-08-03 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
--- Comment #2 from federico <federico.perini at gmail dot com> ---
Tested on godbolt.org:
https://godbolt.org/z/sPsdE6Y3W
works on: 5.5, 6.3, all 10, all 11
error on: all 7, all 8, all 9
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101757] [9 Regression] Simple integer assigment fails (off-seted by -1) when compiling with -O3
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
2021-08-03 16:26 ` [Bug fortran/101757] " federico.perini at gmail dot com
2021-08-03 16:40 ` federico.perini at gmail dot com
@ 2021-08-03 17:30 ` pinskia at gcc dot gnu.org
2021-11-10 14:31 ` marxin at gcc dot gnu.org
2022-05-27 9:08 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 17:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |9.5
Summary|Simple integer assigment |[9 Regression] Simple
|fails (off-seted by -1) |integer assigment fails
|when compiling with -O3 |(off-seted by -1) when
| |compiling with -O3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101757] [9 Regression] Simple integer assigment fails (off-seted by -1) when compiling with -O3
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
` (2 preceding siblings ...)
2021-08-03 17:30 ` [Bug tree-optimization/101757] [9 Regression] " pinskia at gcc dot gnu.org
@ 2021-11-10 14:31 ` marxin at gcc dot gnu.org
2022-05-27 9:08 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-10 14:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Last reconfirmed| |2021-11-10
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |marxin at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master with r10-5067-gce19a48227949920 and it was introduced with
r7-5505-ga388bdc777f58251.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101757] [9 Regression] Simple integer assigment fails (off-seted by -1) when compiling with -O3
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
` (3 preceding siblings ...)
2021-11-10 14:31 ` marxin at gcc dot gnu.org
@ 2022-05-27 9:08 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101757
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|9.5 |10.0
Resolution|--- |FIXED
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 10.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-27 9:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 16:22 [Bug fortran/101757] New: Simple integer assigment fails (off-seted by -1) when compiling with -O3 federico.perini at gmail dot com
2021-08-03 16:26 ` [Bug fortran/101757] " federico.perini at gmail dot com
2021-08-03 16:40 ` federico.perini at gmail dot com
2021-08-03 17:30 ` [Bug tree-optimization/101757] [9 Regression] " pinskia at gcc dot gnu.org
2021-11-10 14:31 ` marxin at gcc dot gnu.org
2022-05-27 9:08 ` rguenth 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).