Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard.
2016-07-21 Richard Biener <rguent...@suse.de> PR tree-optimization/71947 * tree-vrp.c (extract_range_from_assert): Singleton symbolic ranges have useful limit_vr information. * gcc.dg/tree-ssa/vrp102.c: New testcase. Index: gcc/tree-vrp.c =================================================================== *** gcc/tree-vrp.c (revision 238469) --- gcc/tree-vrp.c (working copy) *************** extract_range_from_assert (value_range * *** 1513,1522 **** limit_vr = (TREE_CODE (limit) == SSA_NAME) ? get_value_range (limit) : NULL; /* LIMIT's range is only interesting if it has any useful information. */ ! if (limit_vr ! && (limit_vr->type == VR_UNDEFINED ! || limit_vr->type == VR_VARYING ! || symbolic_range_p (limit_vr))) limit_vr = NULL; /* Initially, the new range has the same set of equivalences of --- 1514,1526 ---- limit_vr = (TREE_CODE (limit) == SSA_NAME) ? get_value_range (limit) : NULL; /* LIMIT's range is only interesting if it has any useful information. */ ! if (! limit_vr ! || limit_vr->type == VR_UNDEFINED ! || limit_vr->type == VR_VARYING ! || (symbolic_range_p (limit_vr) ! && ! (limit_vr->type == VR_RANGE ! && (limit_vr->min == limit_vr->max ! || operand_equal_p (limit_vr->min, limit_vr->max, 0))))) limit_vr = NULL; /* Initially, the new range has the same set of equivalences of Index: gcc/testsuite/gcc.dg/tree-ssa/vrp102.c =================================================================== *** gcc/testsuite/gcc.dg/tree-ssa/vrp102.c (revision 0) --- gcc/testsuite/gcc.dg/tree-ssa/vrp102.c (working copy) *************** *** 0 **** --- 1,18 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1" } */ + + int f(int x, int y) + { + int ret; + if (x == y) + ret = x ^ y; + else + ret = 1; + + return ret; + } + + /* We should have computed x ^ y as zero and propagated the result into the + PHI feeding the result. */ + + /* { dg-final { scan-tree-dump "ret_\[0-9\]+ = PHI <\[01\]\\\(\[0-9\]+\\\), \[01\]\\\(\[0-9\]+\\\)>" "vrp1" } } */