Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard. 2019-07-29 Richard Biener <rguent...@suse.de> PR tree-optimization/91267 * vr-values.c (vr_values::update_value_range): Add early return for effectively VARYING lattice entry. * gcc.dg/torture/pr91267.c: New testcase. Index: gcc/vr-values.c =================================================================== --- gcc/vr-values.c (revision 273792) +++ gcc/vr-values.c (working copy) @@ -202,8 +202,12 @@ vr_values::update_value_range (const_tre new_vr->intersect (&nr); } - /* Update the value range, if necessary. */ + /* Update the value range, if necessary. If we cannot allocate a lattice + entry for VAR keep it at VARYING. This happens when DOM feeds us stmts + with SSA names allocated after setting up the lattice. */ old_vr = get_lattice_entry (var); + if (!old_vr) + return false; is_new = !old_vr->equal_p (*new_vr, /*ignore_equivs=*/false); if (is_new) Index: gcc/testsuite/gcc.dg/torture/pr91267.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr91267.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr91267.c (working copy) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +void bar (void); +void baz (int); +char *qux (void); +int a, b; + +void +foo (int f, char *d) +{ + char *e; + while (d) + { + if (f) + if (e) + bar (); + baz (e - (d + a)); + b = e - d; + d = qux (); + } +}