https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61481
--- Comment #3 from Craig Schroeder <cas43 at cs dot stanford.edu> --- Created attachment 32930 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32930&action=edit More practical (but more complex) example I am trying to optimize an auto-differentiation utility. The example above was the result of simplifying a very complex program down to a simple one that exhibits many of the same problems. Auto-differentiation frequently produces calculations that are trivial or unused, but shaving those computations out in the code would be quite difficult. Attached is portion of an application of it, stripped down to the routines that are actually used and with some unneeded templatization removed. As in the simpler example, the relative order of loop unrolling and sccp seems to be the source of problem. After flattening, there are three loops, with no nested loops. None are unrolled during prog.cpp.058t.cunrolli. All three are unrolled during prog.cpp.118t.cunroll, but that is too late for the prog.cpp.103t.sccp step.