% gcc-tk -v Using built-in specs. COLLECT_GCC=gcc-tk COLLECT_LTO_WRAPPER=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-acdb24166d13d87c374e578d2ad5d58249171930/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --disable-bootstrap --enable-languages=c,c++ --prefix=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-acdb24166d13d87c374e578d2ad5d58249171930 Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221017 (experimental) (GCC) % % gcc-tk -w -O0 a.c && ./a.out 1 % gcc-tk -w -Os a.c && ./a.out 0 % cat a.c short a; int b[1]; int c(int p) { return (p < 0) ? 0 : 10 + ((p / 100 - 16) / 4); } void f(int n) { while (1) { int m = n; while ((m ) ) m /= 2; break; } } void g() { int h = a = 0; for (; h + a <= 0; a++) { if (b[c(a - 6)]) break; f(a); } } int main() { g(); __builtin_printf("%d\n", a); } % Compiler explorer: https://godbolt.org/z/e7sssT7cq
Started with r13-2876-g2460f7cdef7ef9c9.
Created attachment 53717 [details] patch in testing
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>: https://gcc.gnu.org/g:c9b840db504d15db01f06fe1fec38282dbafee07 commit r13-3341-gc9b840db504d15db01f06fe1fec38282dbafee07 Author: Aldy Hernandez <aldyh@redhat.com> Date: Mon Oct 17 18:56:24 2022 +0200 Make sure exported range for SSA post-dominates the DEF in set_global_ranges_from_unreachable_edges. The problem here is that we're exporting a range for an SSA range that happens on the other side of a __builtin_unreachable, but the SSA does not post-dominate the definition point. This is causing ivcanon to unroll things incorrectly. This was a snafu when converting the code from evrp. PR tree-optimization/107293 gcc/ChangeLog: * tree-ssa-dom.cc (dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): Check that condition post-dominates the definition point. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107293.c: New test.
fixed
*** Bug 107196 has been marked as a duplicate of this bug. ***