------- Comment #6 from rguenth at gcc dot gnu dot org 2006-04-26 11:35 ------- It looks like the cases for comparing against type min/max value inside compare_values are for value_inside_range, which does
cmp1 = compare_values (val, vr->min); if (cmp1 == -2 || cmp1 == 2) return -2; ... return (cmp1 == 0 || cmp1 == 1) && (cmp2 == -1 || cmp2 == 0); so we are interested in LE and GE compares here, which compare_values doesn't handle, but which it could give an answer for even for wrapping arithmetic. I propose to simply rely on fold here in value_inside_range, so, restructure it to something like static inline int value_inside_range (tree val, value_range_t *vr) { tree cmp1, cmp2; cmp1 = fold_binary_to_constant (GE_EXPR, TREE_TYPE (val), vr->min, val); if (!cmp1) return -2; cmp2 = fold_binary_to_constant (LE_EXPR, TREE_TYPE (val), val, vr->max); if (!cmp2) return -2; return integer_onep (cmp1) && integer_onep (cmp2); } and completely discard the -INF/+INF comparison stuff from compare_values. Does this sound reasonable? (Likewise I noticed that we can replace calls to compare_values () == 0 with operand_equal_p (), though maybe this is just canoncalization to compare_values?) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25148