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

            Bug ID: 121067
           Summary: wrong code at -Os with "-fno-tree-pre
                    -fno-code-hoisting -fno-tree-dominator-opts
                    -fno-tree-fre" on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/exaGTETjn

It appears to be a recent regression as it doesn't reproduce with 15.1.


[611] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250714 (experimental) (GCC) 
[612] % 
[612] % gcctk -Os small.c; ./a.out
[613] % gcctk -Os -fno-tree-pre -fno-code-hoisting -fno-tree-dominator-opts
-fno-tree-fre small.c
[614] % ./a.out
Aborted
[615] % cat small.c
int printf(const char *, ...);
int a, b;
unsigned c;
int main() {
  int d = 2813311006;
  short e = b;
  c = 2813311006;
  d = ~d + 78 * c;
  a = ~(~d - e);
  e = 1 / (e - d);
  if (e)
    printf("%d\n", d);
  if (d < 1864213926)
    __builtin_abort();
}

Reply via email to