public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108920] New: Condition falsely optimized out
@ 2023-02-24 10:25 agner at agner dot org
  2023-02-24 13:06 ` [Bug c++/108920] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: agner at agner dot org @ 2023-02-24 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108920
           Summary: Condition falsely optimized out
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: agner at agner dot org
  Target Milestone: ---

Created attachment 54526
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54526&action=edit
code to reproduce error

The attached file test.cpp gives wrong code when optimized with -O2 or higher.
To reproduce error, do:

g++ -O2 -m64 -S -o t1.s test.cpp
g++ -O2 -m64 -S -DFIX -o t2.s test.cpp


The condition in line 104 in test.cpp is optimized away in t1.s

The workaround on line 73 is preventing this false optimization with -DFIX to
generate correct code in t2.s
See t2.s line 252-255

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

* [Bug c++/108920] Condition falsely optimized out
  2023-02-24 10:25 [Bug c++/108920] New: Condition falsely optimized out agner at agner dot org
@ 2023-02-24 13:06 ` rguenth at gcc dot gnu.org
  2023-02-25  0:32 ` [Bug middle-end/108920] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-02-24 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-02-24
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder if you can test a newer GCC release since we are no longer maintaining
GCC 9.3.  In particular there's also the GCC 9.5 release (the last release from
the GCC 9 series), and GCC 10.4, GCC 11.3 and GCC 12.2 (the last releases from
the three maintained release series).

Is there a way to observe the issue at runtime?  That would facilitate
bisecting.

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

* [Bug middle-end/108920] Condition falsely optimized out
  2023-02-24 10:25 [Bug c++/108920] New: Condition falsely optimized out agner at agner dot org
  2023-02-24 13:06 ` [Bug c++/108920] " rguenth at gcc dot gnu.org
@ 2023-02-25  0:32 ` pinskia at gcc dot gnu.org
  2023-02-25  6:34 ` agner at agner dot org
  2023-02-25  8:50 ` agner at agner dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-25  0:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97009,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97255

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I linked a few bugs which might be the same issue here (I have not looked into
the code otherwise) and they were both fixed in GCC 9.4.0 even.
So yes please try out GCC 9.5.0 or 10.x even.

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

* [Bug middle-end/108920] Condition falsely optimized out
  2023-02-24 10:25 [Bug c++/108920] New: Condition falsely optimized out agner at agner dot org
  2023-02-24 13:06 ` [Bug c++/108920] " rguenth at gcc dot gnu.org
  2023-02-25  0:32 ` [Bug middle-end/108920] " pinskia at gcc dot gnu.org
@ 2023-02-25  6:34 ` agner at agner dot org
  2023-02-25  8:50 ` agner at agner dot org
  3 siblings, 0 replies; 5+ messages in thread
From: agner at agner dot org @ 2023-02-25  6:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Agner Fog <agner at agner dot org> ---
It seems to work with gcc 9.4.0.
Thank you

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

* [Bug middle-end/108920] Condition falsely optimized out
  2023-02-24 10:25 [Bug c++/108920] New: Condition falsely optimized out agner at agner dot org
                   ` (2 preceding siblings ...)
  2023-02-25  6:34 ` agner at agner dot org
@ 2023-02-25  8:50 ` agner at agner dot org
  3 siblings, 0 replies; 5+ messages in thread
From: agner at agner dot org @ 2023-02-25  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

Agner Fog <agner at agner dot org> changed:

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

--- Comment #4 from Agner Fog <agner at agner dot org> ---
I am not sure I have identified the problem correctly, but there is no need to
spend more time on it since the problem disappears with version 9.4.0.

You may close this issue.

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

end of thread, other threads:[~2023-02-25  8:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 10:25 [Bug c++/108920] New: Condition falsely optimized out agner at agner dot org
2023-02-24 13:06 ` [Bug c++/108920] " rguenth at gcc dot gnu.org
2023-02-25  0:32 ` [Bug middle-end/108920] " pinskia at gcc dot gnu.org
2023-02-25  6:34 ` agner at agner dot org
2023-02-25  8:50 ` agner at agner dot 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).