http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49073
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org |gnu.org | --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-20 09:47:43 UTC --- Created attachment 24297 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24297 gcc46-pr49073.patch Untested fix. While I can imagine a testcase where the dominated_by_p CDI_DOMINATORS check isn't sufficient, e.g. when a loop is entered in the middle as well, as and_var_* and or_var_* immediately give up if the def stmt isn't a GIMPLE_ASSIGN and I believe we need a GIMPLE_PHI in that case, it should hopefully be enough this way. Just for completeness, here is what I've been trying with -O2 -fno-tree-vrp: extern void abort (void); int c; volatile int v; __attribute__((noinline, noclone)) int foo (int x) { int a[] = { 1, 2, 3, 4, 5, 6, 7 }, d = 1, i = 1; _Bool f = 0; if (x == -1000) goto lab; do { v++; lab: d = a[i]; if (f && d == 4) { ++c; break; } i++; f = (d == 3); } while (d < 7); if (c != 1) abort (); return 0; } int main () { foo (v); return 0; }