> This patch fixes the specific problem in the test case by skipping over > equivalences that would rewrite to exactly the same expression as on the > current iteration. But, it's not clear that there can't also be cycles > of length > 1. I don't see much point in getting fancy here (I assume > that if this were a common problem it would have been reported and fixed > long before now) so I just added a simple limit on the number of > iterations to be sure the outer loop always terminates.
Sure, but we don't like arbitrary numbers in the compiler like + int maxiter = 16; and adding a --param for it would be overkill, so let's drop the cap. > 2011-12-12 Sandra Loosemore <san...@codesourcery.com> > Tom de Vries <t...@codesourcery.com> > > gcc/ > * cse.c (find_comparison_args): Add cap on number of iterations > to avoid infinite loop in case of cycles. Avoid obvious case > that would result in a circular rewrite. OK everywhere without the cap and with the same test on ARG2: /* If it's the same comparison we're already looking at, skip it. */ if (COMPARISON_P (p->exp) && XEXP (p->exp, 0) == arg1 && XEXP (p->exp, 1) == arg2) continue; One could imagine a zero being loaded in a register and ARG1 compared with the register earlier. > gcc/testsuite/ > * gcc.dg/cse-bug.c: New testcase. If a testcase doesn't need fancy options, it must go in gcc.c-torture/compile. -- Eric Botcazou