public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108008] New: Compiler mis-optimization with posix_memalign
@ 2022-12-07 14:06 hahnjo at hahnjo dot de
  2022-12-07 14:43 ` [Bug c++/108008] " amonakov at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: hahnjo at hahnjo dot de @ 2022-12-07 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108008
           Summary: Compiler mis-optimization with posix_memalign
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hahnjo at hahnjo dot de
  Target Milestone: ---

Created attachment 54033
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54033&action=edit
init.cpp

Consider the attached example, reduced from some real code, and also available
on Compiler Explorer: https://godbolt.org/z/x4Gsjo7rT

The expectation is that sameZ[i] = true if zPlanes[i] == zPlanes[i + 1] which
should be the case for i = 1. However, when compiling the code with GCC 11.2.0
or 12.2.0 and -std=c++17 -O3, the output is sameZ = 0 for all three iterations
of the second loop. The problem disappears when changing anything in the
slightest manner: compiling with -O2, using -std=gnu++17, using a different
allocation function, commenting out one of the other two statements in the
first loop, using the unconditional assignment to sameZ[i], or removing the
exit(1).

Could this be a bug in the optimizer?

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

end of thread, other threads:[~2023-01-10  8:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 14:06 [Bug c++/108008] New: Compiler mis-optimization with posix_memalign hahnjo at hahnjo dot de
2022-12-07 14:43 ` [Bug c++/108008] " amonakov at gcc dot gnu.org
2022-12-07 22:12 ` [Bug tree-optimization/108008] " dhsbz at chaw dot com
2022-12-07 22:24 ` pinskia at gcc dot gnu.org
2022-12-07 22:37 ` pinskia at gcc dot gnu.org
2022-12-07 22:48 ` pinskia at gcc dot gnu.org
2022-12-07 22:58 ` pinskia at gcc dot gnu.org
2022-12-07 23:05 ` [Bug tree-optimization/108008] [12 Regression] " pinskia at gcc dot gnu.org
2022-12-07 23:05 ` pinskia at gcc dot gnu.org
2022-12-08  8:44 ` [Bug tree-optimization/108008] [12 Regression] wrong code with -O3 and posix_memalign amonakov at gcc dot gnu.org
2022-12-12  7:38 ` amonakov at gcc dot gnu.org
2022-12-27 14:22 ` marxin at gcc dot gnu.org
2022-12-27 14:23 ` [Bug tree-optimization/108008] [12 Regression] wrong code with -O3 and posix_memalign since r12-4526-gd8edfadfc7a9795b marxin at gcc dot gnu.org
2023-01-09 12:48 ` rguenth at gcc dot gnu.org
2023-01-09 15:06 ` marxin at gcc dot gnu.org
2023-01-10  8:00 ` 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).