[584] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/11.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.1 20210416 (experimental) [master revision 89c863488bc:10ed13839be:76c7e7d6b003a17d183d0571bf9b34c691819d25] (GCC) [585] % [585] % gcctk -O1 -S -o O1.s small.c [586] % gcctk -O3 -S -o O3.s small.c [587] % [587] % wc O1.s O3.s 84 185 1140 O1.s 120 254 1768 O3.s 204 439 2908 total [588] % [588] % grep foo O1.s [589] % grep foo O3.s call foo [590] % [590] % cat small.c extern void foo(void); int a, b, d, *c = &a, e, k; static int f(int *h, int i, int **l) { for (b = 0; b < 1; b++) { int *f = &d; for (; d < 1; d++) f = c; if (f != &a) __builtin_abort(); if (k) *c = 0; } *c = 0; return **l; } int main() { int *j = &b; if (!f(j, e, &j)) foo(); return 0; }
dom3 manages to optimize it with -O1 but it gets different input with -O3.
Looks to be fixed in GCC 12.3.0 and GCC 13.1.0 .
(In reply to Andrew Pinski from comment #2) > Looks to be fixed in GCC 12.3.0 and GCC 13.1.0 . A change in PRE which causes the IR to be different and allowed to be optimized away in DOM3