diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2019-06-13 09:46:00 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2019-06-13 09:46:00 +0000 |
commit | fa8ba8b84cf4f1caf581b09d808d6e57b1ff2843 (patch) | |
tree | 974fdf46b52abb2f7b4de4981329e8f625215904 /gcc/tree-vrp.c | |
parent | a7b183bf22c7c57fc0d8851f84db6fff694ba5f8 (diff) | |
download | gcc-fa8ba8b84cf4f1caf581b09d808d6e57b1ff2843.zip gcc-fa8ba8b84cf4f1caf581b09d808d6e57b1ff2843.tar.gz gcc-fa8ba8b84cf4f1caf581b09d808d6e57b1ff2843.tar.bz2 |
Revamp value_range::may_contain_p.
From-SVN: r272238
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 065152a..dc7f825 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -287,18 +287,7 @@ value_range::set_varying () bool value_range_base::may_contain_p (tree val) const { - if (varying_p ()) - return true; - - if (undefined_p ()) - return true; - - if (m_kind == VR_ANTI_RANGE) - { - int res = value_inside_range (val, min (), max ()); - return res == 0 || res == -2; - } - return value_inside_range (val, min (), max ()) != 0; + return value_inside_range (val) != 0; } void @@ -1118,40 +1107,38 @@ compare_values (tree val1, tree val2) } -/* Return 1 if VAL is inside value range MIN <= VAL <= MAX, - 0 if VAL is not inside [MIN, MAX], +/* Return 1 if VAL is inside value range. + 0 if VAL is not inside value range. -2 if we cannot tell either way. Benchmark compile/20001226-1.c compilation time after changing this function. */ int -value_inside_range (tree val, tree min, tree max) +value_range_base::value_inside_range (tree val) const { int cmp1, cmp2; - cmp1 = operand_less_p (val, min); + if (varying_p ()) + return 1; + + if (undefined_p ()) + return 0; + + cmp1 = operand_less_p (val, m_min); if (cmp1 == -2) return -2; if (cmp1 == 1) - return 0; + return m_kind != VR_RANGE; - cmp2 = operand_less_p (max, val); + cmp2 = operand_less_p (m_max, val); if (cmp2 == -2) return -2; - return !cmp2; -} - - -/* Return TRUE if *VR includes the value X. */ - -bool -range_includes_p (const value_range_base *vr, HOST_WIDE_INT x) -{ - if (vr->varying_p () || vr->undefined_p ()) - return true; - return vr->may_contain_p (build_int_cst (vr->type (), x)); + if (m_kind == VR_RANGE) + return !cmp2; + else + return !!cmp2; } /* Value range wrapper for wide_int_range_set_zero_nonzero_bits. |