diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2019-10-03 08:08:50 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2019-10-03 08:08:50 +0000 |
commit | 38a734350fd787da1b4bcf9b4e0a99ed2adb5eae (patch) | |
tree | 4f5d0ec3eca5f40efce5cb8725875e0f0d1cf2d0 /gcc/range.cc | |
parent | 0a8c8f4d6578fac21adc0e156861c4b47bed4418 (diff) | |
download | gcc-38a734350fd787da1b4bcf9b4e0a99ed2adb5eae.zip gcc-38a734350fd787da1b4bcf9b4e0a99ed2adb5eae.tar.gz gcc-38a734350fd787da1b4bcf9b4e0a99ed2adb5eae.tar.bz2 |
Makefile.in (OBJS): Add range.o and range-op.o.
* Makefile.in (OBJS): Add range.o and range-op.o.
Remove wide-int-range.o.
* function-tests.c (test_ranges): New.
(function_tests_c_tests): Call test_ranges.
* ipa-cp.c (ipa_vr_operation_and_type_effects): Call
range_fold_unary_expr instead of extract_range_from_unary_expr.
* ipa-prop.c (ipa_compute_jump_functions_for_edge): Same.
* range-op.cc: New file.
* range-op.h: New file.
* range.cc: New file.
* range.h: New file.
* selftest.h (range_tests): New prototype.
* ssa.h: Include range.h.
* tree-vrp.c (value_range_base::value_range_base): New
constructors.
(value_range_base::singleton_p): Do not call
ranges_from_anti_range until sure we will need to.
(value_range_base::type): Rename gcc_assert to
gcc_checking_assert.
(vrp_val_is_max): New argument.
(vrp_val_is_min): Same.
(wide_int_range_set_zero_nonzero_bits): Move from
wide-int-range.cc.
(extract_range_into_wide_ints): Remove.
(extract_range_from_multiplicative_op): Remove.
(extract_range_from_pointer_plus_expr): Abstract POINTER_PLUS code
from extract_range_from_binary_expr.
(extract_range_from_plus_minus_expr): Abstract PLUS/MINUS code
from extract_range_from_binary_expr.
(extract_range_from_binary_expr): Remove.
(normalize_for_range_ops): New.
(range_fold_binary_expr): New.
(range_fold_unary_expr): New.
(value_range_base::num_pairs): New.
(value_range_base::lower_bound): New.
(value_range_base::upper_bound): New.
(value_range_base::upper_bound): New.
(value_range_base::contains_p): New.
(value_range_base::invert): New.
(value_range_base::union_): New.
(value_range_base::intersect): New.
(range_compatible_p): New.
(value_range_base::operator==): New.
(determine_value_range_1): Call range_fold_*expr instead of
extract_range_from_*expr.
* tree-vrp.h (class value_range_base): Add new constructors.
Add methods for union_, intersect, operator==, contains_p,
num_pairs, lower_bound, upper_bound, invert.
(vrp_val_is_min): Add handle_pointers argument.
(vrp_val_is_max): Same.
(extract_range_from_unary_expr): Remove.
(extract_range_from_binary_expr): Remove.
(range_fold_unary_expr): New.
(range_fold_binary_expr): New.
* vr-values.c (vr_values::extract_range_from_binary_expr): Call
range_fold_binary_expr instead of extract_range_from_binary_expr.
(vr_values::extract_range_basic): Same.
(vr_values::extract_range_from_unary_expr): Call
range_fold_unary_expr instead of extract_range_from_unary_expr.
* wide-int-range.cc: Remove.
* wide-int-range.h: Remove.
From-SVN: r276504
Diffstat (limited to 'gcc/range.cc')
-rw-r--r-- | gcc/range.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/gcc/range.cc b/gcc/range.cc new file mode 100644 index 0000000..5e4d904 --- /dev/null +++ b/gcc/range.cc @@ -0,0 +1,89 @@ +/* Misc range functions. + Copyright (C) 2017-2019 Free Software Foundation, Inc. + Contributed by Aldy Hernandez <aldyh@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "tree.h" +#include "gimple.h" +#include "gimple-pretty-print.h" +#include "fold-const.h" +#include "ssa.h" +#include "range.h" + +value_range_base +range_intersect (const value_range_base &r1, const value_range_base &r2) +{ + value_range_base tmp (r1); + tmp.intersect (r2); + return tmp; +} + +value_range_base +range_invert (const value_range_base &r1) +{ + value_range_base tmp (r1); + tmp.invert (); + return tmp; +} + +value_range_base +range_union (const value_range_base &r1, const value_range_base &r2) +{ + value_range_base tmp (r1); + tmp.union_ (r2); + return tmp; +} + +value_range_base +range_zero (tree type) +{ + return value_range_base (build_zero_cst (type), build_zero_cst (type)); +} + +value_range_base +range_nonzero (tree type) +{ + return value_range_base (VR_ANTI_RANGE, + build_zero_cst (type), build_zero_cst (type)); +} + +value_range_base +range_positives (tree type) +{ + unsigned prec = TYPE_PRECISION (type); + signop sign = TYPE_SIGN (type); + return value_range_base (type, wi::zero (prec), wi::max_value (prec, sign)); +} + +value_range_base +range_negatives (tree type) +{ + unsigned prec = TYPE_PRECISION (type); + signop sign = TYPE_SIGN (type); + value_range_base r; + if (sign == UNSIGNED) + r.set_undefined (); + else + r = value_range_base (type, wi::min_value (prec, sign), + wi::minus_one (prec)); + return r; +} |