public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division
@ 2022-09-21 21:41 hiraditya at msn dot com
  2022-09-21 21:46 ` [Bug tree-optimization/107005] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hiraditya at msn dot com @ 2022-09-21 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107005
           Summary: gcc not exploiting undefined behavior to optimize away
                    the result of division
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

#include <limits.h>
int main() { return INT_MIN / -1; }

gcc -O2

main:
        mov     eax, -2147483648
        ret


clang -O2

main:                                   # @main
        ret



https://godbolt.org/z/Tjxx3KGdK

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

* [Bug tree-optimization/107005] gcc not exploiting undefined behavior to optimize away the result of division
  2022-09-21 21:41 [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division hiraditya at msn dot com
@ 2022-09-21 21:46 ` pinskia at gcc dot gnu.org
  2022-09-21 21:47 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-21 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That is because GCC constants folds INT_MIN / -1 into INT_MIN.

GCC warns about this code for this expression while clang does not ...

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

* [Bug tree-optimization/107005] gcc not exploiting undefined behavior to optimize away the result of division
  2022-09-21 21:41 [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division hiraditya at msn dot com
  2022-09-21 21:46 ` [Bug tree-optimization/107005] " pinskia at gcc dot gnu.org
@ 2022-09-21 21:47 ` pinskia at gcc dot gnu.org
  2022-09-22  6:53 ` rguenth at gcc dot gnu.org
  2022-09-22 20:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-21 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Even ICC warns ....

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

* [Bug tree-optimization/107005] gcc not exploiting undefined behavior to optimize away the result of division
  2022-09-21 21:41 [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division hiraditya at msn dot com
  2022-09-21 21:46 ` [Bug tree-optimization/107005] " pinskia at gcc dot gnu.org
  2022-09-21 21:47 ` pinskia at gcc dot gnu.org
@ 2022-09-22  6:53 ` rguenth at gcc dot gnu.org
  2022-09-22 20:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-22  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder what's the point of the clang result?  I'd say it's quite bad QOI.

So I think there's nothing to fix here.

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

* [Bug tree-optimization/107005] gcc not exploiting undefined behavior to optimize away the result of division
  2022-09-21 21:41 [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division hiraditya at msn dot com
                   ` (2 preceding siblings ...)
  2022-09-22  6:53 ` rguenth at gcc dot gnu.org
@ 2022-09-22 20:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-22 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107011 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2022-09-22 20:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 21:41 [Bug tree-optimization/107005] New: gcc not exploiting undefined behavior to optimize away the result of division hiraditya at msn dot com
2022-09-21 21:46 ` [Bug tree-optimization/107005] " pinskia at gcc dot gnu.org
2022-09-21 21:47 ` pinskia at gcc dot gnu.org
2022-09-22  6:53 ` rguenth at gcc dot gnu.org
2022-09-22 20:04 ` pinskia 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).