https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87465
Bug ID: 87465 Summary: Loop removal regression Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: david.bolvansky at gmail dot com Target Milestone: --- void Test() { int c = 0; int in[4] = {4,3,4,4}; for (unsigned i = 0; i < 4; i++) { for (unsigned j = 0; j < i; j++) { if (in[i] == in[j]) break; else ++c; } } printf("test %d", c); } GCC 7.3: Test(): mov esi, 1 mov edi, OFFSET FLAT:.LC0 xor eax, eax jmp printf GCC 8+ is unable to simplify it as 7.3 (no loops are removed). Godbolt: https://godbolt.org/z/tDAuug