https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109507
Bug ID: 109507
Summary: Optimizer creates incorrect program
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: aran at 100acres dot us
Target Milestone: ---
Created attachment 54854
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54854&action=edit
Example program.
The attached program should print 0 and does with optimization level zero (0).
However, with optimization at any non-zero value (e.g., g, s, 1, 2) it prints
1. This is on an Intel I7-2600.
The code that the optimizer writes reduces to a single test instruction that
checks if x is less or equal to zero. However, this is incorrect for the most
negative number.
To reproduce compile the attached file with -O0 and with -O1.