https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66652
Bug ID: 66652 Summary: try_transform_to_exit_first_loop_alt generates incorrect loop Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- This testcase fails on trunk: ... $ cat libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c /* { dg-do run } */ /* { dg-options "-O2 -ftree-parallelize-loops=2" } */ #include <stdio.h> #include <stdlib.h> #include <limits.h> unsigned int __attribute__((noclone,noinline)) f (unsigned int n, unsigned int sum) { unsigned int i; i = UINT_MAX; do { sum += i % 13; i++; } while (i < n - 1); return sum; } int main (void) { unsigned int actual = f (0, 12); unsigned int expected = 4294967290; if (actual != expected) abort (); return 0; } ... try_transform_to_exit_first_loop_alt changes the loop into this, and the loop is never entered: ... i = UINT_MAX; while (i < n) { sum += i % 13; i++; } ...