summaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
AgeCommit message (Collapse)Author
2019-03-13PR tree-optimization/89662 - -Warray-bounds ICE on void* arithmeticMartin Sebor
gcc/ChangeLog: PR tree-optimization/89662 * tree-vrp.c (vrp_prop::check_mem_ref): Avoid assuming every type has a size. gcc/testsuite/ChangeLog: PR tree-optimization/89662 * gcc.dg/Warray-bounds-41.c: New test. From-SVN: r269655
2019-03-08re PR tree-optimization/89550 (Spurious array-bounds warning when using ↵Jakub Jelinek
__PRETTY_FUNCTION__ as a string_view) PR tree-optimization/89550 * builtins.c (c_strlen): Only set TREE_NO_WARNING if warning_at returned true. Formatting fixes. (expand_builtin_strnlen): Formatting fixes. * tree-vrp.c (vrp_prop::check_mem_ref): Only set TREE_NO_WARNING if warning_at returned true. * tree-cfg.c (pass_warn_function_return::execute): Likewise. c-family/ * c-common.c (c_common_truthvalue_conversion): Only set TREE_NO_WARNING if warning_at returned true. * c-warn.c (overflow_warning, warn_logical_operator): Likewise. c/ * c-decl.c (finish_function): Only set TREE_NO_WARNING if warning_at returned true. (c_write_global_declarations_1): Only set TREE_NO_WARNING if pedwarn or warning returned true. cp/ * semantics.c (maybe_convert_cond): Only set TREE_NO_WARNING if warning_at returned true. * decl2.c (c_parse_final_cleanups): Likewise. * typeck.c (convert_for_assignment): Likewise. * decl.c (finish_function): Likewise. From-SVN: r269485
2019-02-01re PR tree-optimization/89143 (comparison of abs(i) against excessive ↵Jakub Jelinek
constant less than UXXX_MAX no longer folded) PR tree-optimization/89143 * wide-int-range.h (wide_int_range_absu): Declare. * wide-int-range.cc (wide_int_range_absu): New function. * tree-vrp.c (extract_range_from_unary_expr): Handle ABSU_EXPR. * gcc.dg/tree-ssa/vrp121.c: New test. From-SVN: r268445
2019-01-01Update copyright years.Jakub Jelinek
From-SVN: r267494
2018-12-17Add a loop versioning passRichard Sandiford
This patch adds a pass that versions loops with variable index strides for the case in which the stride is 1. E.g.: for (int i = 0; i < n; ++i) x[i * stride] = ...; becomes: if (stepx == 1) for (int i = 0; i < n; ++i) x[i] = ...; else for (int i = 0; i < n; ++i) x[i * stride] = ...; This is useful for both vector code and scalar code, and in some cases can enable further optimisations like loop interchange or pattern recognition. The pass gives a 7.6% improvement on Cortex-A72 for 554.roms_r at -O3 and a 2.4% improvement for 465.tonto. I haven't found any SPEC tests that regress. Sizewise, there's a 10% increase in .text for both 554.roms_r and 465.tonto. That's obviously a lot, but in tonto's case it's because the whole program is written using assumed-shape arrays and pointers, so a large number of functions really do benefit from versioning. roms likewise makes heavy use of assumed-shape arrays, and that improvement in performance IMO justifies the code growth. The next biggest .text increase is 4.5% for 548.exchange2_r. I did see a small (0.4%) speed improvement there, but although both 3-iteration runs produced stable results, that might still be noise. There was a slightly larger (non-noise) improvement for a 256-bit SVE model. 481.wrf and 521.wrf_r .text grew by 2.8% and 2.5% respectively, but without any noticeable improvement in performance. No other test grew by more than 2%. Although the main SPEC beneficiaries are all Fortran tests, the benchmarks we use for SVE also include some C and C++ tests that benefit. Using -frepack-arrays gives the same benefits in many Fortran cases. The problem is that using that option inappropriately can force a full array copy for arguments that the function only reads once, and so it isn't really something we can turn on by default. The new pass is supposed to give most of the benefits of -frepack-arrays without the risk of unnecessary repacking. The patch therefore enables the pass by default at -O3. 2018-12-17 Richard Sandiford <richard.sandiford@arm.com> Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> Kyrylo Tkachov <kyrylo.tkachov@arm.com> gcc/ * doc/invoke.texi (-fversion-loops-for-strides): Document (loop-versioning-group-size, loop-versioning-max-inner-insns) (loop-versioning-max-outer-insns): Document new --params. * Makefile.in (OBJS): Add gimple-loop-versioning.o. * common.opt (fversion-loops-for-strides): New option. * opts.c (default_options_table): Enable fversion-loops-for-strides at -O3. * params.def (PARAM_LOOP_VERSIONING_GROUP_SIZE) (PARAM_LOOP_VERSIONING_MAX_INNER_INSNS) (PARAM_LOOP_VERSIONING_MAX_OUTER_INSNS): New parameters. * passes.def: Add pass_loop_versioning. * timevar.def (TV_LOOP_VERSIONING): New time variable. * tree-ssa-propagate.h (substitute_and_fold_engine::substitute_and_fold): Add an optional block parameter. * tree-ssa-propagate.c (substitute_and_fold_engine::substitute_and_fold): Likewise. When passed, only walk blocks dominated by that block. * tree-vrp.h (range_includes_p): Declare. (range_includes_zero_p): Turn into an inline wrapper around range_includes_p. * tree-vrp.c (range_includes_p): New function, generalizing... (range_includes_zero_p): ...this. * tree-pass.h (make_pass_loop_versioning): Declare. * gimple-loop-versioning.cc: New file. gcc/testsuite/ * gcc.dg/loop-versioning-1.c: New test. * gcc.dg/loop-versioning-10.c: Likewise. * gcc.dg/loop-versioning-11.c: Likewise. * gcc.dg/loop-versioning-2.c: Likewise. * gcc.dg/loop-versioning-3.c: Likewise. * gcc.dg/loop-versioning-4.c: Likewise. * gcc.dg/loop-versioning-5.c: Likewise. * gcc.dg/loop-versioning-6.c: Likewise. * gcc.dg/loop-versioning-7.c: Likewise. * gcc.dg/loop-versioning-8.c: Likewise. * gcc.dg/loop-versioning-9.c: Likewise. * gfortran.dg/loop_versioning_1.f90: Likewise. * gfortran.dg/loop_versioning_2.f90: Likewise. * gfortran.dg/loop_versioning_3.f90: Likewise. * gfortran.dg/loop_versioning_4.f90: Likewise. * gfortran.dg/loop_versioning_5.f90: Likewise. * gfortran.dg/loop_versioning_6.f90: Likewise. * gfortran.dg/loop_versioning_7.f90: Likewise. * gfortran.dg/loop_versioning_8.f90: Likewise. From-SVN: r267197
2018-12-11re PR tree-optimization/88444 (ICE: tree check: expected ssa_name, have ↵Jakub Jelinek
integer_cst in live_on_edge, at tree-vrp.c:468; or ICE: tree check: expected ssa_name, have integer_cst in get_value_range, at vr-values.c:84) PR tree-optimization/88444 * tree-vrp.c (register_edge_assert_for_2): Only register assertions for conversions if rhs1 is a SSA_NAME. * gcc.dg/pr88444.c: New test. From-SVN: r267026
2018-12-07re PR tree-optimization/88367 (-fno-delete-null-pointer-checks doesn't work ↵Jakub Jelinek
properly) PR c/88367 * tree-vrp.c (extract_range_from_binary_expr): For POINTER_PLUS_EXPR with -fno-delete-null-pointer-checks, set_nonnull only if the pointer is non-NULL and offset is known to have most significant bit clear. * vr-values.c (vr_values::vrp_stmt_computes_nonzero): For ADDR_EXPR of MEM_EXPR, return true if the MEM_EXPR has non-zero offset with most significant bit clear. If offset does have most significant bit set and -fno-delete-null-pointer-checks, don't return true even if the base pointer is non-NULL. * gcc.dg/tree-ssa/pr88367.c: New test. From-SVN: r266878
2018-12-04re PR tree-optimization/88301 (Optimization regression with undefined ↵Richard Biener
unsigned overflow) 2018-12-04 Richard Biener <rguenther@suse.de> PR tree-optimization/88301 * tree-vrp.c (register_edge_assert_for_2): Fix sign-conversion issues in last commit. From-SVN: r266773
2018-12-03re PR tree-optimization/88301 (Optimization regression with undefined ↵Richard Biener
unsigned overflow) 2018-12-03 Richard Biener <rguenther@suse.de> PR tree-optimization/88301 * tree-vrp.c (register_edge_assert_for_2): Handle conversions that do not change the value by registering the same assert for the operand. * gcc.dg/tree-ssa/evrp13.c: New testcase. From-SVN: r266739
2018-11-30re PR tree-optimization/88274 (ICE in check, at tree-vrp.c:188)Richard Biener
2018-11-30 Richard Biener <rguenther@suse.de> PR tree-optimization/88274 * tree-vrp.c (ranges_from_anti_range): Fix handling of TYPE_MIN/MAX_VALUE. From-SVN: r266659
2018-11-16re PR tree-optimization/88011 (r266028 causes a bunch of go failures)Richard Biener
2018-11-16 Richard Biener <rguenther@suse.de> PR tree-optimization/88011 * tree-vrp.c (extract_range_from_binary_expr): Fix error in replacing set_value_range_to_undefined and set_value_range_to_varying with method calls. From-SVN: r266205
2018-11-14* gimple-ssa-evrp-analyze.cAldy Hernandez
(evrp_range_analyzer::record_ranges_from_incoming_edge): Rename ignore_equivs_equal_p to equal_p. * ipa-cp.c (meet_with_1): Use equal_p instead of ignore_equivs_equal_p. * ipa-prop.c (ipa_vr_ggc_hash_traits::equal): Same. * tree-vrp.c (value_range::ignore_equivs_equal_p): Remove. (value_range::operator==): Remove. (value_range::operator!=): Remove. (vrp_prop::visit_stmt): Use equal_p. * tree-vrp.h (value_range): Remove operator==, operator!=, ignore_equivs_equal_p. * vr-values.c (update_value_range): Use equal_p. From-SVN: r266150
2018-11-13tree-vrp.c (value_range_base::dump): Dump type.Aldy Hernandez
* tree-vrp.c (value_range_base::dump): Dump type. Do not use INF nomenclature for 1-bit types. (dump_value_range): Group all variants to common dumping code. (debug): New overloaded functions for value_ranges. (value_range_base::dump): Remove no argument version. (value_range::dump): Same. testsuite/ * gcc.dg/tree-ssa/pr64130.c: Adjust for new value_range pretty printer. * gcc.dg/tree-ssa/vrp92.c: Same. From-SVN: r266077
2018-11-13tree-ssanames.h (set_range_info): Use value_range_base.Richard Biener
2018-11-13 Richard Biener <rguenther@suse.de> * tree-ssanames.h (set_range_info): Use value_range_base. (get_range_info): Likewise. * tree-ssanames.c (set_range_info): Likewise. (get_range_info): Likewise. * tree-vrp.c (value_range_base::union_helper): Split out common parts of value_range[_base]::union_. (value_range_base::union_): Update. (value_range::union_): Likewise. (determine_value_range_1): Use value_range_base. (determine_value_range): Likewise. * tree-vrp.h (value_range_base::union_helper): Move ... (value_range::union_helper): ... from here. From-SVN: r266061
2018-11-122018-11=12 Richard Biener <rguenther@suse.de>Richard Biener
* tree-vrp.h (value_range[_base]::set): Make public. Provide overload for single value. (value_range[_base]::set_nonnull): New. (value_range[_base]::set_null): Likewise. (value_range): Document bitmap copying behavior, mark copy constructor and assignment operator deleted. (value_range::move): New. (value_range::set_and_canonicalize): Default bitmap to zero. (set_value_range_to_nonnull): Remove. (set_value_range_to_null): Likewise. (set_value_range): Likewise. (set_value_range_to_value): Likewise. (extract_range_from_unary_expr): Work on value_range_base. (extract_range_from_binary_expr_1): Likewise. Rename to... (extract_range_from_binary_expr): ... this. * tree-vrp.c (value_range::update): Clear equiv bitmap if required. (value_range::move): New, move equiv bitmap. (value_range_base::set_undefined): Avoid assignment. (value_range::set_undefined): Likewise. (value_range_base::set_varying): Likewise. (value_range::set_varying): Likewise. (set_value_range): Remove. (value_range_base::set): New overload for value. (value_range::set): Likewise. (set_value_range_to_nonnull): Remove. (value_range_base::set_nonnull): New. (value_range::set_nonnull): Likewise. (set_value_range_to_null): Remove. (value_range_base::set_null): New. (value_range::set_null): Likewise. (range_is_null): Work on value_range_base. (range_is_nonnull): Likewise. (ranges_from_anti_range): Likewise. (extract_range_into_wide_ints): Likewise. (extract_range_from_multiplicative_op): Likewise. (extract_range_from_binary_expr): Likewise. Update for API changes. (extract_range_from_unary_expr): Likewise. Remove OBJ_TYPE_REF handling. (value_range::intersect_helper): Avoid copy and assignment. (value_range::union_helper): Likewise. (determine_value_range_1): Adjust. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Avoid assignment by using move. (evrp_range_analyzer::record_ranges_from_stmt): Avoid assignment. * tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): Likewise. * tree-ssanames.c (get_range_info): Likewise. * vr-values.h (vr_values::get_vr_for_comparison): Adjust API. * vr-values.c (vr_values::get_value_range): Adjust. (vr_values::update_value_range): Likewise. (symbolic_range_based_on_p): Work on value_range_base. (vr_values::extract_range_from_binary_expr): Use value_range_base. (vr_values::extract_range_from_unary_expr): Likewise. (vr_values::extract_range_from_cond_expr): Avoid assignment. (vr_values::extract_range_from_comparison): Adjust. (vr_values::check_for_binary_op_overflow): Use value_range_base. (vr_values::extract_range_basic): Adjust. (vr_values::adjust_range_with_scev): Likewise. (vr_values::vrp_visit_assignment_or_call): Likewise. (vr_values::get_vr_for_comparison): Change API to avoid assignment and copy construction. (vr_values::compare_name_with_value): Adjust accordingly. (vr_values::compare_names): Likewise. (vr_values::extract_range_from_phi_node): Avoid assignment and bogus in-place modify of equiv bitmap. (vr_values::simplify_bit_ops_using_ranges): Use value_range_base. * ipa-prop.c (ipa_compute_jump_functions_for_edge): Adjust for extract_range_from_unary_expr API change. * ipa-cp.c (ipa_vr_operation_and_type_effects): Likewise. From-SVN: r266030
2018-11-12tree-vrp.h (value_range_base::symbolic_p, [...]): Move from value_range.Richard Biener
2018-11-12 Richard Biener <rguenther@suse.de> * tree-vrp.h (value_range_base::symbolic_p, value_range_base::constant_p, value_range_base::zero_p, value_range_base::singleton_p): Move from value_range. (value_range::dump): Add. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Use set_varying. * ipa-cp.c (ipcp_vr_lattice::print): Use dump_value_range. * tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): Use set_varying. * tree-vrp.c (value_range::symbolic_p): Move to value_range_base. (value_range::constant_p): Likewise. (value_range::singleton_p): Likewise. (value_range_base::dump): Add. (set_value_range_to_undefined): Remove. (set_value_range_to_varying): Likewise. (range_int_cst_p): Take value_range_base argument. (range_int_cst_singleton_p): Likewise. (value_range_constant_singleton): Likewise. (vrp_set_zero_nonzero_bits): Likewise. (extract_range_from_multiplicative_op): Use set_varying. (extract_range_from_binary_expr_1): Likewise. Use set_undefined. (extract_range_from_unary_expr): Likewise. (dump_value_range_base): Change to overload of dump_value_range. (vrp_prop::vrp_initialize): Use set_varying and set_undefined. (vrp_prop::visit_stmt): Likewise. (value_range::intersect_helper): Likewise. (value_range::union_helper): Likewise. (determine_value_range_1): Likewise. From-SVN: r266028
2018-11-12tree-vrp.c (set_value_range_to_nonnull): Clear equiv.Richard Biener
2018-11-12 Richard Biener <rguenther@suse.de> * tree-vrp.c (set_value_range_to_nonnull): Clear equiv. (set_value_range_to_null): Likewise. * vr-values.c (vr_values::extract_range_from_comparison): Clear equiv for constant singleton ranges. From-SVN: r266027
2018-11-11tree-vrp.h (class value_range_base): New base class for value_range ↵Richard Biener
containing all but the m_equiv member. 2018-11-11 Richard Biener <rguenther@suse.de> * tree-vrp.h (class value_range_base): New base class for value_range containing all but the m_equiv member. (dump_value_range_base): Add. (range_includes_zero_p): Work on value_range_base. * tree-vrp.c (value_range_base::set): Split out base handling from... (value_range::set): this. (value_range::set_equiv): New. (value_range_base::value_range_base): New constructors. (value_range_base::check): Split out base handling from... (value_range::check): this. (value_range::equal_p): Refactor in terms of ignore_equivs_equal_p which is now member of the base. (value_range_base::set_undefined): New. (value_range_base::set_varying): Likewise. (value_range_base::dump):Split out base handling from... (value_range::dump): this. (value_range_base::set_and_canonicalize): Split out base handling from... (value_range::set_and_canonicalize): this. (value_range_base::union_): New. * ipa-prop.h (struct ipa_jump_func): Use value_range_base * for m_vr. * ipa-cp.c (class ipcp_vr_lattice): Use value_range_base instead of value_range everywhere. (ipcp_vr_lattice::print): Use dump_value_range_base. (ipcp_vr_lattice::meet_with): Adjust. (ipcp_vr_lattice::meet_with_1): Likewise. (ipa_vr_operation_and_type_effects): Likewise. (propagate_vr_across_jump_function): Likewise. * ipa-prop.c (struct ipa_vr_ggc_hash_traits): Likewise. (ipa_get_value_range): Likewise. (ipa_set_jfunc_vr): Likewise. (ipa_compute_jump_functions_for_edge): Likewise. From-SVN: r266011
2018-11-09tree-vrp.c (value_range::check): Do not access internals directly.Aldy Hernandez
* tree-vrp.c (value_range::check): Do not access internals directly. (value_range::singleton_p): Same. (value_range::type): Same. (vrp_finalize): Use value_range API. From-SVN: r265955
2018-11-09* tree-vrp.c (may_contain_p): Do not access m_min/m_max directly.Aldy Hernandez
From-SVN: r265954
2018-11-09gimple-fold.c (size_must_be_zero_p): Use value_range API instead of ↵Aldy Hernandez
performing ad-hoc calculations. * gimple-fold.c (size_must_be_zero_p): Use value_range API instead of performing ad-hoc calculations. * tree-ssanames.c (set_range_info): New overloaded function accepting value_range &. (get_range_info): Same. * tree-ssanames.h (set_range_info_raw): Remove. (set_range_info): New prototype. (get_range_info): Same. * tree-vrp.h (value_range::null_p): Rename to zero_p. * tree-vrp.c (value_range::null_p): Same. From-SVN: r265952
2018-10-23tree-vrp.c (add_assert_info): Guard dump_printf with dump_enabled_p.Richard Biener
2018-10-23 Richard Biener <rguenther@suse.de> * tree-vrp.c (add_assert_info): Guard dump_printf with dump_enabled_p. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_incoming_edge): Use value_range::ignore_equivs_equal_p. From-SVN: r265422
2018-10-222018-10-22 Richard Biener <rguenther@suse.de>Richard Biener
* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_incoming_edge): Be smarter about what ranges to use. * tree-vrp.c (add_assert_info): Dump here. (register_edge_assert_for_2): Instead of here at multiple but not all places. * gcc.dg/tree-ssa/evrp12.c: New testcase. * gcc.dg/predict-6.c: Adjust. * gcc.dg/tree-ssa/vrp33.c: Disable EVRP. * gcc.dg/tree-ssa/vrp02.c: Likewise. * gcc.dg/tree-ssa/cunroll-9.c: Likewise. From-SVN: r265391
2018-10-22re PR bootstrap/87640 (internal compiler error: in check, at tree-vrp.c:155)Richard Biener
2018-10-22 Richard Biener <rguenther@suse.de> PR tree-optimization/87640 * tree-vrp.c (set_value_range_with_overflow): Decompose incomplete result. (extract_range_from_binary_expr_1): Adjust. * gcc.dg/torture/pr87640.c: New testcase. From-SVN: r265375
2018-10-17bitmap.c (bitmap_head::dump): New.Aldy Hernandez
* bitmap.c (bitmap_head::dump): New. * bitmap.h (bitmap_head): Add dump(). * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Adjust for value_range API. (evrp_range_analyzer::set_ssa_range_info): Same. (evrp_range_analyzer::record_ranges_from_phis): Same. (evrp_range_analyzer::record_ranges_from_stmt): Same. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Same. * gimple-ssa-sprintf.c (get_int_range): Same. (format_integer): Same. (sprintf_dom_walker::handle_gimple_call): Same. * ipa-cp.c (ipcp_vr_lattice::meet_with_1): Same. (ipcp_vr_lattice::top_p): Same. (ipcp_vr_lattice::bottom_p): Same. (ipcp_vr_lattice::set_to_bottom): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (ipcp_store_vr_results): Same. * ipa-prop.c (struct ipa_vr_ggc_hash_traits): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_get_value_range): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_write_jump_function): Same. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Same. * tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): Same. * vr-values.c (set_value_range_to_nonnegative): Same. (set_value_range_to_truthvalue): Same. (vr_values::get_value_range): Same. (vr_values::set_defs_to_varying): Same. (vr_values::update_value_range): Same. (symbolic_range_based_on_p): Same. (vr_values::op_with_boolean_value_range_p): Same. (vr_values::extract_range_for_var_from_comparison_expr): Same. (vr_values::extract_range_from_ssa_name): Same. (vr_values::extract_range_from_binary_expr): Same. (vr_values::extract_range_from_unary_expr): Same. (vr_values::extract_range_from_cond_expr): Same. (vr_values::extract_range_from_comparison): Same. (vr_values::check_for_binary_op_overflow): Same. (vr_values::extract_range_basic): Same. (vr_values::extract_range_from_assignment): Same. (compare_ranges): Same. (compare_range_with_value): Same. (vr_values::adjust_range_with_scev): Same. (vrp_valueize): Same. (vrp_valueize_1): Same. (vr_values::get_vr_for_comparison): Same. (vr_values::compare_name_with_value): Same. (vr_values::compare_names): Same. (vr_values::vrp_evaluate_conditional): Same. (find_case_label_ranges): Same. (vr_values::vrp_visit_switch_stmt): Same. (vr_values::extract_range_from_phi_node): Same. (vr_values::simplify_div_or_mod_using_ranges): Same. (vr_values::simplify_bit_ops_using_ranges): Same. (test_for_singularity): Same. (range_fits_type_p): Same. (vr_values::simplify_cond_using_ranges_1): Same. (vr_values::simplify_switch_using_ranges): Same. (vr_values::simplify_float_conversion_using_ranges): Same. (vr_values::two_valued_val_range_p): Same. (vr_values::add_equivalence): Move to value_range::equiv_add. * vr-values.h (vr_values::add_equivalence): Remove. (VR_INITIALIZER): Remove. * tree-vrp.c (value_range::set): New. (value_range::equiv_add): New. (value_range::value_range): New. (value_range::deep_copy): New. (value_range::check): New. (value_range::equal_p): New. (value_range::ignore_equivs_equal_p): New. (value_range::operator==): New. (value_range::operator!=): New. (value_range::symbolic_p): New. (value_range::numeric_p): New. (value_range::set_undefined): New. (value_range::set_varying): New. (value_range::may_contain_p): New. (value_range::equiv_clear): New. (value_range::singleton_p): New. (value_range::intersect): New. (value_range::dump): New. (value_range::set_and_canonicalize): New. (set_value_range): Adjust for value_range API. (set_value_range_to_undefined): Same. (set_value_range_to_varying): Same. (set_and_canonicalize_value_range): Same. (set_value_range_to_nonnull): Same. (set_value_range_to_null): Same. (range_is_null): Same. (range_is_nonnull): Same. (range_int_cst_p): Same. (range_int_cst_singleton_p): Same. (symbolic_range_p): Same. (range_includes_zero_p): Same. (value_range_constant_singleton): Same. (vrp_set_zero_nonzero_bits): Same. (ranges_from_anti_range): Same. (extract_range_into_wide_ints): Same. (extract_range_from_multiplicative_op): Same. (set_value_range_with_overflow): Same. (extract_range_from_binary_expr_1): Same. (extract_range_from_unary_expr): Same. (dump_value_range): Same. (debug_value_range): Same. (vrp_prop::check_array_ref): Same. (vrp_prop::check_mem_ref): Same. (vrp_prop::vrp_initialize): Same. (vrp_prop::visit_stmt): Same. (intersect_ranges): Same. (vrp_prop::visit_phi): Same. (vrp_prop::vrp_finalize): Same. (determine_value_range_1): Same. (determine_value_range): Same. (vrp_intersect_ranges_1): Rename to... (vrp_intersect_1): this. (vrp_intersect_ranges): Rename to... (value_range::intersect_helper): ...this. (vrp_meet_1): Rename to... (value_range::union_helper): ...this. (vrp_meet): Rename to... (value_range::union_): ...this. (copy_value_range): Remove. * tree-vrp.h (struct value_range): Rewrite into a proper class. (value_range::vrtype): New. (value_range::type): New. (value_range::equiv): New. (value_range::min): New. (value_range::max): New. (value_range::varying_p): New. (value_range::undefined_p): New. (value_range::null_p): New. (value_range::equiv_add): New. (copy_value_range): Remove. From-SVN: r265241
2018-10-17tree-vrp.c (extract_range_from_multiplicative_op): Remove overflow wraps ↵Aldy Hernandez
argument. * tree-vrp.c (extract_range_from_multiplicative_op): Remove overflow wraps argument. (extract_range_from_binary_expr_1): Do not pass overflow wraps to wide_int_range_multiplicative_op. * wide-int-range.cc (wide_int_range_mult_wrapping): Remove overflow wraps argument. (wide_int_range_multiplicative_op): Same. (wide_int_range_lshift): Same. (wide_int_range_div): Same. * wide-int-range.h (wide_int_range_multiplicative_op): Same. (wide_int_range_lshift): Same. (wide_int_range_div): Same. From-SVN: r265238
2018-10-17wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to use sign as ↵Aldy Hernandez
argument. * wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to use sign as argument. * tree-vrp.c (extract_range_from_binary_expr_1): Pass sign to wide_int_range_shift_undefined_p. From-SVN: r265237
2018-10-03re PR tree-optimization/87415 (wrong code at -O1 and above on x86_64-linux-gnu)Aldy Hernandez
PR tree-optimization/87415 * tree-vrp.c (set_value_range_with_overflow): Special case one bit precision fields. From-SVN: r264817
2018-10-03tree-vrp.c (extract_range_from_unary_expr): Special case all pointer ↵Aldy Hernandez
conversions. * tree-vrp.c (extract_range_from_unary_expr): Special case all pointer conversions. Do not do anything special for anti-ranges. From-SVN: r264815
2018-09-25Remove unused functions and fields.Martin Liska
2018-09-25 Martin Liska <mliska@suse.cz> * alias.c (set_dest_equal_p): Remove unused function. * config/i386/i386.c (def_builtin_pure2): Likewise. * diagnostic-show-locus.c (class layout): Remove unused field. (layout::layout): Likewise here. * dump-context.h (class temp_dump_context): Likewise. * dwarf2out.c (add_AT_fde_ref): Remove unused function. (add_AT_loclistsptr): Likewise. (add_AT_offset): Likewise. (get_AT_hi_pc): Likewise. (is_comdat_die): Likewise. (type_is_enum): Likewise. (ceiling): Likewise. (add_AT_vms_delta): Likewise. (is_class_die): Likewise. * edit-context.c (class line_event): Remove unused field. * graphite-sese-to-poly.c (tree_int_to_gmp): Remove unused function. * ipa-cp.c (ipa_get_vr_lat): Likewise. * lra-constraints.c (ok_for_index_p_nonstrict): Likewise. (ok_for_base_p_nonstrict): Likewise. * tree-chrec.c (is_not_constant_evolution): Likewise. (chrec_fold_poly_cst): Likewise. * tree-if-conv.c (has_pred_critical_p): Likewise. * tree-ssa-coalesce.c (print_exprs): Likewise. * tree-ssa-pre.c (bitmap_set_contains_expr): Likewise. * tree-ssa-uninit.c (is_and_or_or_p): Likewise. * tree-vrp.c (value_ranges_intersect_p): Likewise. (value_range_nonnegative_p): Likewise. 2018-09-25 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_scope_ht_size): Remove unused function. * parser.c (cp_lexer_next_token_is_not_keyword): Likewise. 2018-09-25 Martin Liska <mliska@suse.cz> * trans.c (remove_suffix): Remove unused function. 2018-09-25 Martin Liska <mliska@suse.cz> * gofrontend/escape.cc (Gogo::analyze_escape): Remove usage of a parameter. (Gogo::assign_connectivity): Likewise. (class Escape_analysis_tag): Likewise. (Gogo::tag_function): Likewise. * gofrontend/expressions.cc (Call_expression::do_type): Likewise. * gofrontend/gogo.h (class Gogo): Likewise. * gofrontend/types.cc (class Call_multiple_result_type): Likewise. (Type::make_call_multiple_result_type): Likewise. * gofrontend/types.h (class Type): Likewise. * gofrontend/wb.cc (class Check_escape): Likewise. (Gogo::add_write_barriers): Likewise. From-SVN: r264561
2018-09-21gimple-ssa-evrp.c (evrp_dom_walker::cleanup): Call ↵Jeff Law
vr_values::cleanup_edges_and_switches. * gimple-ssa-evrp.c (evrp_dom_walker::cleanup): Call vr_values::cleanup_edges_and_switches. * tree-vrp.c (to_remove_edges, to_update_switch_stmts): Moved into vr_values class. (identify_jump_threads): Remove EDGE_IGNORE handling. (execute_vrp): Move handling of to_remove_edges and to_update_switch_stmts into vr_values class member functions. * tree-vrp.h (switch_update, to_remove_edges): Remove declarations. (to_update_switch_stmts): Likewise. * vr-values.c: Include cfghooks.h. (vr_values::vr_values): Initialize to_remove_edges and to_update_switch_stmts. (vr_values::~vr_values): Verify to_remove_edges and to_update_switch_stmts are empty. (vr_values::simplify_switch_using_ranges): Set EDGE_IGNORE as needed. (vr_values::cleanup_edges_and_switches): New member function. * vr-values.h (vr_values): Add cleanup_edges_and_switches member function. Add new data members. * gcc.dg/tree-ssa/vrp113.c: Disable EVRP. * gcc.dg/tree-ssa/vrp120.c: New test. From-SVN: r264491
2018-09-17tree-vrp.c (extract_range_from_unary_expr): Do not special case symbolics or ↵Aldy Hernandez
VR_VARYING ranges for ABS_EXPR. * tree-vrp.c (extract_range_from_unary_expr): Do not special case symbolics or VR_VARYING ranges for ABS_EXPR. * wide-int-range.cc (wide_int_range_abs): Return positive numbers when range will wrap. From-SVN: r264356
2018-09-14tree-vrp.c (extract_range_from_binary_expr_1): Normalize VR_VARYING for ↵Aldy Hernandez
PLUS/MINUS_EXPR. * tree-vrp.c (extract_range_from_binary_expr_1): Normalize VR_VARYING for PLUS/MINUS_EXPR. From-SVN: r264307
2018-09-12tree-vrp.c (vrp_shift_undefined_p): Remove.Aldy Hernandez
* tree-vrp.c (vrp_shift_undefined_p): Remove. (extract_range_from_binary_expr_1: Call wide_int_range_shift_undefined_p instead of vrp_shift_undefined_p. * wide-int-range.h (wide_int_range_shift_undefined_p): Do not depend on sign. From-SVN: r264228
2018-09-11tree-vrp (extract_range_from_binary_expr_1): Treat all divisions by zero as ↵Aldy Hernandez
VR_UNDEFINED. * tree-vrp (extract_range_from_binary_expr_1): Treat all divisions by zero as VR_UNDEFINED. From-SVN: r264203
2018-09-04wide-int-range.cc (wide_int_range_convert): New.Aldy Hernandez
* wide-int-range.cc (wide_int_range_convert): New. * wide-int-range.h (wide_int_range_convert): New. * tree-vrp.c (extract_range_from_unary_expr): Abstract wide int code into wide_int_range_convert. (extract_range_into_wide_ints): Do not munge anti range constants into the entire domain. Just return the range back. From-SVN: r264085
2018-09-04tree-vrp.c (vrp_can_optimize_bit_op): Remove.Aldy Hernandez
* tree-vrp.c (vrp_can_optimize_bit_op): Remove. (extract_range_from_binary_expr_1): Do not call vrp_can_optimize_bit_op. * wide-int-range.cc (wide_int_range_can_optimize_bit_op): Make static. (wide_int_range_get_mask_and_bounds): New. (wide_int_range_optimize_bit_op): New. (wide_int_range_bit_ior): Call wide_int_range_optimize_bit_op. (wide_int_range_bit_and): Same. * wide-int-range.h (wide_int_range_can_optimize_bit_op): Remove. (wide_int_range_optimize_bit_op): New. (wide_int_range_get_mask_and_bounds): New. From-SVN: r264078
2018-08-31tree-vrp: add "const" qualifier to various value_range pointersDavid Malcolm
gcc/ChangeLog: * tree-vrp.c (copy_value_range): Convert param "from" from "value_range *" to "const value_range *". (range_is_null): Likewise for param "vr". (range_int_cst_p): Likewise. (range_int_cst_singleton_p): Likewise. (symbolic_range_p): Likewise. (value_ranges_intersect_p): Likewise for both params. (value_range_nonnegative_p): Likewise for param "vr". (value_range_constant_singleton): Likewise. (vrp_set_zero_nonzero_bits): Likewise for param "ar". (extract_range_into_wide_ints): Likewise for param "vr". (extract_range_from_multiplicative_op): Likewise for params "vr0" and "vr1". (vrp_can_optimize_bit_op): Likewise. (extract_range_from_binary_expr_1): Likewise for params "vr0_" and "vr1_". (extract_range_from_unary_expr): Likewise. (debug_value_range): Likewise for param "vr". (value_range::dump): Add "const" qualifier. (vrp_prop::check_array_ref): Convert local "vr" from "value_range *" to "const value_range *". (vrp_prop::check_mem_ref): Likewise. (vrp_prop::visit_stmt): Likewise for local "old_vr". (vrp_intersect_ranges_1): Likewise for param "vr_1". (vrp_intersect_ranges): Likewise. (simplify_stmt_for_jump_threading): Likewise for local "vr". (vrp_prop::vrp_finalize): Likewise. * tree-vrp.h (value_range::dump): Add "const" qualifier. (vrp_intersect_ranges): Add "const" qualifier to params as above. (extract_range_from_unary_expr): Likewise. (value_range_constant_singleton): Likewise. (symbolic_range_p): Likewise. (copy_value_range): Likewise. (extract_range_from_binary_expr_1): Likewise. (range_int_cst_p): Likewise. (vrp_set_zero_nonzero_bits): Likewise. (range_int_cst_singleton_p): Likewise. From-SVN: r264020
2018-08-27Add new gswitch related functions into tree-cfg.c.Martin Liska
2018-08-27 Martin Liska <mliska@suse.cz> * cfgexpand.c (expand_asm_stmt): Use label_to_block and pass cfun argument explicitly. * gimple-pretty-print.c (dump_gimple_switch): Likewise. * hsa-gen.c (gen_hsa_insns_for_switch_stmt): Use new function gimple_switch_default_bb. (convert_switch_statements): (expand_builtins): * ipa-fnsummary.c (set_switch_stmt_execution_predicate): * stmt.c (label_to_block_fn): Use label_to_block and pass cfun argument explicitly and use gimple_switch_label_bb. (expand_case): Likewise. * tree-cfg.c (lower_phi_internal_fn): Use label_to_block and pass cfun argument explicitly. Likewise. (make_edges_bb): Likewise. (make_cond_expr_edges): Likewise. (get_cases_for_edge): Likewise. (make_gimple_switch_edges): Likewise. (label_to_block_fn): Likewise. (label_to_block): Likewise. (make_goto_expr_edges): Likewise. (make_gimple_asm_edges): Likewise. (main_block_label): Likewise. (group_case_labels_stmt): Likewise. (find_taken_edge_computed_goto): Likewise. (find_taken_edge_switch_expr): Likewise. (gimple_verify_flow_info): Likewise. (gimple_redirect_edge_and_branch): Likewise. (gimple_switch_label_bb): New function. (gimple_switch_default_bb): Likewise. (gimple_switch_edge): Likewise. (gimple_switch_default_edge): Likewise. * tree-cfg.h (label_to_block_fn): Remove and replace ... (label_to_block): ... with this. (gimple_switch_label_bb): New. (gimple_switch_default_bb): Likewise. (gimple_switch_edge): Likewise. (gimple_switch_default_edge): Likewise. * tree-cfgcleanup.c (convert_single_case_switch): Use new gimple functions and pass new argument to label_to_block. (cleanup_control_flow_bb): * tree-eh.c (make_eh_dispatch_edges): Use label_to_block and pass cfun argument explicitly. (make_eh_edges): Likewise. (redirect_eh_dispatch_edge): Likewise. (lower_resx): Likewise. (lower_eh_dispatch): Likewise. (maybe_remove_unreachable_handlers): Likewise. (unsplit_eh): Likewise. (cleanup_empty_eh): Likewise. (verify_eh_edges): Likewise. (verify_eh_dispatch_edge): Likewise. * tree-ssa-dom.c (record_edge_info): Likewise. * tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise. * tree-ssa-threadedge.c (thread_around_empty_blocks): Likewise. (thread_through_normal_block): Likewise. * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise. * tree-ssa-uninit.c (convert_control_dep_chain_into_preds): * tree-switch-conversion.c (switch_conversion::collect): Use new gimple functions. (switch_conversion::check_final_bb): Likewise. (switch_conversion::gather_default_values): Pass new argument to label_to_block. (switch_conversion::build_constructors): Likewise. (switch_decision_tree::compute_cases_per_edge): Use new gimple_switch_edge function. (switch_decision_tree::analyze_switch_statement): Pass new argument to label_to_block. (switch_decision_tree::try_switch_expansion): Use gimple_switch_default_edge. * tree-vrp.c (find_switch_asserts): Pass new argument to label_to_block. * vr-values.c (vr_values::vrp_visit_switch_stmt): Likewise. (vr_values::simplify_switch_using_ranges): Likewise. From-SVN: r263876
2018-08-24gimple-ssa-evrp-analyze.c (set_ssa_range_info): Pass value_range to ↵Aldy Hernandez
range_includes_zero_p. * gimple-ssa-evrp-analyze.c (set_ssa_range_info): Pass value_range to range_includes_zero_p. Do not special case VR_ANTI_RANGE. * tree-vrp.c (range_is_nonnull): Remove. (range_includes_zero_p): Accept value_range instead of min/max. (extract_range_from_binary_expr_1): Do not early bail on POINTER_PLUS_EXPR. Use range_includes_zero_p instead of range_is_nonnull. (extract_range_from_unary_expr): Use range_includes_zero_p instead of range_is_nonnull. (vrp_meet_1): Pass value_range to range_includes_zero_p. Do not special case VR_ANTI_RANGE. (vrp_finalize): Same. * tree-vrp.h (range_includes_zero_p): Pass value_range as argument instead of min/max. (range_is_nonnull): Remove. * vr-values.c (vrp_stmt_computes_nonzero): Use range_includes_zero_p instead of range_is_nonnull. (extract_range_basic): Pass value_range to range_includes_zero_p instead of range_is_nonnull. From-SVN: r263842
2018-08-23tree-vrp.c (abs_extent_range): Remove.Aldy Hernandez
* tree-vrp.c (abs_extent_range): Remove. (extract_range_into_wide_ints): Pass wide ints by reference. (extract_range_from_binary_expr_1): Rewrite the *DIV_EXPR code. Pass wide ints by reference in all calls to extract_range_into_wide_ints. * wide-int-range.cc (wide_int_range_div): New. * wide-int-range.h (wide_int_range_div): New. (wide_int_range_includes_zero_p): New. (wide_int_range_zero_p): New. From-SVN: r263813
2018-08-22re PR tree-optimization/86988 (ICE: tree check: expected integer_cst, have ↵Richard Biener
var_decl in get_len, at tree.h:5563) 2018-08-22 Richard Biener <rguenther@suse.de> PR tree-optimization/86988 * tree-vrp.c (vrp_prop::check_mem_ref): Bail out on VLAs. * g++.dg/pr86988.C: New testcase. From-SVN: r263762
2018-08-21wide-int-range.cc (wide_int_range_abs): New.Aldy Hernandez
* wide-int-range.cc (wide_int_range_abs): New. (wide_int_range_order_set): Rename from wide_int_range_min_max. * wide-int-range.h (wide_int_range_abs): New. (wide_int_range_min_max): New. * tree-vrp.c (extract_range_from_unary_expr): Rewrite ABS_EXPR case to call wide_int_range_abs. Rewrite MIN/MAX_EXPR to call wide_int_range_min_max. (extract_range_from_abs_expr): Delete. From-SVN: r263685
2018-08-20re PR c++/78655 (gcc doesn't exploit the fact that the result of pointer ↵Richard Biener
addition can not be nullptr) 2018-08-20 Richard Biener <rguenther@suse.de> PR tree-optimization/78655 * tree-vrp.c (extract_range_from_binary_expr_1): Make pointer + offset nonnull if either operand is nonnull work. * gcc.dg/tree-ssa/evrp11.c: New testcase. From-SVN: r263662
2018-08-14PR tree-optimization/86650 - -Warray-bounds missing inlining contextMartin Sebor
gcc/ChangeLog: PR tree-optimization/86650 * tree-vrp.c (vrp_prop::check_array_ref): Print an inform message. (vrp_prop::check_mem_ref): Same. gcc/testsuite/ChangeLog: PR tree-optimization/86650 * gcc.dg/Warray-bounds-34.c: New test. From-SVN: r263541
2018-08-03Makefile.in (wide-int-range.o): New.Aldy Hernandez
* Makefile.in (wide-int-range.o): New. * tree-vrp.c: Move all the wide_int_* functions to... * wide-int-range.cc: ...here. * tree-vrp.h: Move all the wide_int_* prototypes to... * wide-int-range.h: ...here. From-SVN: r263288
2018-08-01tree-vrp (zero_nonzero_bits_from_bounds): Rename to...Aldy Hernandez
* tree-vrp (zero_nonzero_bits_from_bounds): Rename to... (wide_int_set_zero_nonzero_bits): ...this. (zero_nonzero_bits_from_vr): Rename to... (vrp_set_zero_nonzero_bits): ...this. (extract_range_from_multiplicative_op_1): Abstract wide int code... (wide_int_range_multiplicative_op): ...here. (extract_range_from_binary_expr_1): Extract wide int binary operations into their own functions. (wide_int_range_lshift): New. (wide_int_range_can_optimize_bit_op): New. (wide_int_range_shift_undefined_p): New. (wide_int_range_bit_xor): New. (wide_int_range_bit_ior): New. (wide_int_range_bit_and): New. (wide_int_range_trunc_mod): New. (extract_range_into_wide_ints): New. (vrp_shift_undefined_p): New. (extract_range_from_multiplicative_op): New. (vrp_can_optimize_bit_op): New. * tree-vrp.h (value_range::dump): New. (wide_int_range_multiplicative_op): New. (wide_int_range_lshift):New. (wide_int_range_shift_undefined_p): New. (wide_int_range_bit_xor): New. (wide_int_range_bit_ior): New. (wide_int_range_bit_and): New. (wide_int_range_trunc_mod): New. (zero_nonzero_bits_from_bounds): Rename to... (wide_int_set_zero_nonzero_bits): ...this. (zero_nonzero_bits_from_vr): Rename to... (vrp_set_zero_nonzero_bits): ...this. (range_easy_mask_min_max): Rename to... (wide_int_range_can_optimize_bit_op): this. From-SVN: r263218
2018-07-31PR tree-optimization/86741 - ICE in -Warray-bounds indexing into an object ↵Martin Sebor
of incomplete type gcc/ChangeLog: PR tree-optimization/86741 * tree-vrp.c (vrp_prop::check_mem_ref): Avoid incomplete types. gcc/testsuite/ChangeLog: PR tree-optimization/86741 * gcc.dg/Warray-bounds-33.c: New test. From-SVN: r263166
2018-07-19PR tree-optimization/84047 - missing -Warray-bounds on an out-of-bounds ↵Martin Sebor
index into an array PR tree-optimization/84047 - missing -Warray-bounds on an out-of-bounds index into an array PR tree-optimization/83776 - missing -Warray-bounds indexing past the end of a string literal gcc/ChangeLog: PR tree-optimization/84047 PR tree-optimization/83776 * tree-vrp.c (vrp_prop::check_mem_ref): New function. (check_array_bounds): Call it. gcc/testsuite/ChangeLog: PR tree-optimization/83776 PR tree-optimization/84047 * gcc.dg/Warray-bounds-29.c: New test. * gcc.dg/Warray-bounds-30.c: New test. * gcc.dg/Warray-bounds-31.c: New test. * gcc.dg/Warray-bounds-32.c: New test. From-SVN: r262893
2018-07-19wide-int.h (widest2_int): New.Aldy Hernandez
* wide-int.h (widest2_int): New. * gimple-fold.c (arith_overflowed_p): Use it. * tree.h (widest2_int_cst): New. * tree-vrp.c (wide_int_binop_overflow): Rename from vrp_int_const_binop. Rewrite to work on trees. (extract_range_from_multiplicative_op_1): Abstract code to... (wide_int_range_min_max): ...here. (wide_int_range_cross_product): ...and here. (extract_range_from_binary_expr_1): Abstract overflow code to... (wide_int_range_cross_product_wrapping): ...here. * tree-vrp.h (wide_int_range_cross_product): New. (wide_int_range_cross_product_wrapping): New. From-SVN: r262874