Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard.
2018-03-05 Richard Biener <rguent...@suse.de> PR tree-optimization/84650 * tree-ssa-loop-im.c (pass_lim::execute): Reset the SCEV cache if executed in the loop pipeline. * gcc.dg/graphite/pr84650.c: New testcase. Index: gcc/tree-ssa-loop-im.c =================================================================== --- gcc/tree-ssa-loop-im.c (revision 258124) +++ gcc/tree-ssa-loop-im.c (working copy) @@ -2616,6 +2616,8 @@ pass_lim::execute (function *fun) if (!in_loop_pipeline) loop_optimizer_finalize (); + else + scev_reset (); return todo; } Index: gcc/testsuite/gcc.dg/graphite/pr84650.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/pr84650.c (nonexistent) +++ gcc/testsuite/gcc.dg/graphite/pr84650.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgraphite-identity -fno-tree-copy-prop --param lim-expensive=3" } */ + +unsigned int dj; + +void +np (void) +{ + const unsigned int uw = 2; + unsigned int eu; + + for (eu = 0; eu < uw; ++eu) + { + for (dj = 0; dj < uw; ++dj) + ; + eu -= !!(dj - uw - 1); + } +}