https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93586
Bug ID: 93586 Summary: wrong code at -O1 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: qrzhang at gatech dot edu Target Milestone: --- The master branch version of gcc miscompiles the code at -O1 and above. It seems to be a recent regression. gcc-9 works fine. Bisection points to: commit ede31f6ffe73357705e95016046e77c7e3d6ad13 Author: Jan Hubicka <hubi...@ucw.cz> Date: Tue Oct 1 21:46:09 2019 +0200 $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.0.1 20200204 (experimental) [master revision 5f0653a8b75:037d7906159:5bc9d2f5ed4c39a7cad74db34e2bb125e012fa60] (GCC) $ gcc-trunk abc.c && ./a.out 0 $ gcc-9 -O1 abc.c && ./a.out 0 $ gcc-trunk -O1 abc.c && ./a.out -1 $ cat abc.c int printf(const char *, ...); short a; long b; int main() { char c[][10][1] = {7, 0, 5, 5}; for (; b <= 3; b++) { a = 0; for (; a >= 0; a--) if (c[a][b][a]) break; } printf("%d\n", a); }