https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66263
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 Status|UNCONFIRMED |RESOLVED Known to work| |4.7.4 Resolution|--- |DUPLICATE Known to fail| |4.8.3, 5.1.0 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed, for me: 4.7.4: 0.77s 4.8.3: 1.5s 5.1: 1.57s with -O3, time with -O2 didn't regress. Even with -fno-inline it regresses: 4.7.4 -O3 -fno-inline: 1.7s 5.1 -O3 -fno-inline: 2.3s Ok, 4.7 unrolls the for (digit = 1; digit <= N; ++digit) { if (can_put_digit(row, col, box, digit)) { put_digit(row, col, box, digit); solve(square+1); pop_digit(row, col, box, digit); } } loop, so this looks like a duplicate of PR59967. It also re-orders basic-blocks in a way that if can_put_digit returns false (which should be likely in the end) then it just falls thru to the next can_put_digit call. With inlining the non-pure call is the recursion to solve (). *** This bug has been marked as a duplicate of bug 59967 ***