aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-evrp.c
AgeCommit message (Collapse)AuthorFilesLines
2021-01-04Update copyright years.Jakub Jelinek1-1/+1
2020-10-16Don't invoke range_of_expr multiple times.Andrew MacLeod1-2/+11
Call evrp_folder::range_of_expr directly so we dont end up calling hybrid_folder::range_of_expr and doing double lookups/comparisons. * gimple-ssa-evrp.c (hybrid_folder::value_on_edge): Call evrp_folder::value_of_expr directly. (hybrid_folder::value_of_stmt): Ditto.
2020-10-08Fix PR97315 (part 1 of 2)Aldy Hernandez1-21/+27
gcc/ChangeLog: PR tree-optimization/97315 * gimple-ssa-evrp.c (hybrid_folder::choose_value): Removes the trap and instead annotates the listing. gcc/testsuite/ChangeLog: * gcc.dg/pr97315-1.c: New test.
2020-10-07Rename -fevrp-mode= to --param=evrp-mode=.Aldy Hernandez1-4/+4
* common.opt (-fevrp-mode): Rename and move... * params.opt (--param=evrp-mode): ...here. * gimple-range.h (DEBUG_RANGE_CACHE): Use param_evrp_mode instead of flag_evrp_mode. * gimple-ssa-evrp.c (rvrp_folder): Same. (hybrid_folder): Same. (execute_early_vrp): Same.
2020-10-06Hybrid EVRP and testcasesAndrew MacLeod1-3/+218
Provide a hybrid EVRP pass which uses legacy EVRP and adds additonal enhancements from the new ranger infrastructure. A New option is also provided, -fevrp-mode= And adjust testcases gcc/ChangeLog: 2020-10-06 Andrew MacLeod <amacleod@redhat.com> * flag-types.h (enum evrp_mode): New enumerated type EVRP_MODE_*. * common.opt (fevrp-mode): New undocumented flag. * gimple-ssa-evrp.c: Include gimple-range.h (class rvrp_folder): EVRP folding using ranger exclusively. (rvrp_folder::rvrp_folder): New. (rvrp_folder::~rvrp_folder): New. (rvrp_folder::value_of_expr): New. Use rangers value_of_expr. (rvrp_folder::value_on_edge): New. Use rangers value_on_edge. (rvrp_folder::value_of_Stmt): New. Use rangers value_of_stmt. (rvrp_folder::fold_stmt): New. Call the simplifier. (class hybrid_folder): EVRP folding using both engines. (hybrid_folder::hybrid_folder): New. (hybrid_folder::~hybrid_folder): New. (hybrid_folder::fold_stmt): New. Simplify with one engne, then the other. (hybrid_folder::value_of_expr): New. Use both value routines. (hybrid_folder::value_on_edge): New. Use both value routines. (hybrid_folder::value_of_stmt): New. Use both value routines. (hybrid_folder::choose_value): New. Choose between range_analzyer and rangers values. (execute_early_vrp): Choose a folder based on flag_evrp_mode. * vr-values.c (simplify_using_ranges::fold_cond): Try range_of_stmt first to see if it returns a value. (simplify_using_ranges::simplify_switch_using_ranges): Return true if any changes were made to the switch. gcc/testsuite/ChangeLog: 2020-10-06 Andrew MacLeod <amacleod@redhat.com> * gcc.dg/pr81192.c: Disable EVRP pass. * gcc.dg/tree-ssa/pr77445-2.c: Ditto. * gcc.dg/tree-ssa/ssa-dom-thread-6.c: Adjust. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Ditto.
2020-10-01Convert vr-values to value query class.Aldy Hernandez1-11/+9
gcc/ChangeLog: * gimple-loop-versioning.cc (lv_dom_walker::before_dom_children): Pass m_range_analyzer instead of get_vr_values. (loop_versioning::name_prop::get_value): Rename to... (loop_versioning::name_prop::value_of_expr): ...this. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::evrp_range_analyzer): Adjust for evrp_range_analyzer inheriting from vr_values. (evrp_range_analyzer::try_find_new_range): Same. (evrp_range_analyzer::record_ranges_from_incoming_edge): Same. (evrp_range_analyzer::record_ranges_from_phis): Same. (evrp_range_analyzer::record_ranges_from_stmt): Same. (evrp_range_analyzer::push_value_range): Same. (evrp_range_analyzer::pop_value_range): Same. * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Inherit from vr_values. Adjust accordingly. * gimple-ssa-evrp.c: Adjust for evrp_range_analyzer inheriting from vr_values. (evrp_folder::value_of_evrp): Rename from get_value. * tree-ssa-ccp.c (class ccp_folder): Rename get_value to value_of_expr. (ccp_folder::get_value): Rename to... (ccp_folder::value_of_expr): ...this. * tree-ssa-copy.c (class copy_folder): Rename get_value to value_of_expr. (copy_folder::get_value): Rename to... (copy_folder::value_of_expr): ...this. * tree-ssa-dom.c (dom_opt_dom_walker::after_dom_children): Adjust for evrp_range_analyzer inheriting from vr_values. (dom_opt_dom_walker::optimize_stmt): Same. * tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in): Call value_of_* instead of get_value. (substitute_and_fold_engine::replace_phi_args_in): Same. (substitute_and_fold_engine::propagate_into_phi_args): Same. (substitute_and_fold_dom_walker::before_dom_children): Same. * tree-ssa-propagate.h: Include value-query.h. (class substitute_and_fold_engine): Inherit from value_query. * tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Adjust for evrp_range_analyzer inheriting from vr_values. * tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): Same. * tree-vrp.c (class vrp_folder): Same. (vrp_folder::get_value): Rename to value_of_expr. * vr-values.c (vr_values::get_lattice_entry): Adjust for vr_values inheriting from range_query. (vr_values::range_of_expr): New. (vr_values::value_of_expr): New. (vr_values::value_on_edge): New. (vr_values::value_of_stmt): New. (simplify_using_ranges::op_with_boolean_value_range_p): Call get_value_range through query. (check_for_binary_op_overflow): Rename store to query. (vr_values::vr_values): Remove vrp_value_range_pool. (vr_values::~vr_values): Same. (simplify_using_ranges::get_vr_for_comparison): Call get_value_range through query. (simplify_using_ranges::compare_names): Same. (simplify_using_ranges::vrp_evaluate_conditional): Same. (simplify_using_ranges::vrp_visit_cond_stmt): Same. (simplify_using_ranges::simplify_abs_using_ranges): Same. (simplify_using_ranges::simplify_cond_using_ranges_1): Same. (simplify_cond_using_ranges_2): Same. (simplify_using_ranges::simplify_switch_using_ranges): Same. (simplify_using_ranges::two_valued_val_range_p): Same. (simplify_using_ranges::simplify_using_ranges): Rename store to query. (simplify_using_ranges::simplify): Assert that we have a query. * vr-values.h (class range_query): Remove. (class simplify_using_ranges): Remove inheritance of range_query. (class vr_values): Add virtuals for range_of_expr, value_of_expr, value_on_edge, value_of_stmt, and get_value_range. Call range_query allocator instead of using vrp_value_range_pool. Remove vrp_value_range_pool. (simplify_using_ranges::get_value_range): Remove.
2020-06-27Move simplification of statements using ranges into its own class.Aldy Hernandez1-5/+6
This moves all the simplification code from vr_values into a separate class (simplify_using_ranges). In doing so, we get rid of a bunch of dependencies on the internals of vr_values. The goal is to (a) remove unnecessary interdependendcies (b) be able to use this engine with any range infrastructure, as all it needs is a method to get the range for an SSA name (get_value_range). I also removed as many dependencies on value_range_equiv as possible, preferring value_range. A few value_range_equiv uses remain, but for cases where equivalences are actually used (folding conditionals, etc). gcc/ChangeLog: * gimple-ssa-evrp-analyze.h (vrp_visit_cond_stmt): Use simplify_using_ranges class. * gimple-ssa-evrp.c (class evrp_folder): New simplify_using_ranges field. Adjust all methods to use new field. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Use simplify_using_ranges class. * tree-vrp.c (class vrp_folder): New simplify_using_ranges field. Adjust all methods to use new field. (simplify_stmt_for_jump_threading): Use simplify_using_ranges class. (vrp_prop::vrp_finalize): New vrp_folder argument. (execute_vrp): Pass folder to vrp_finalize. Use simplify_using_ranges class. Remove cleanup_edges_and_switches call. * vr-values.c (vr_values::op_with_boolean_value_range_p): Change value_range_equiv uses to value_range. (simplify_using_ranges::op_with_boolean_value_range_p): Use simplify_using_ranges class. (check_for_binary_op_overflow): Make static. (vr_values::extract_range_basic): Pass this to check_for_binary_op_overflow. (compare_range_with_value): Change value_range_equiv uses to value_range. (vr_values::vr_values): Initialize simplifier field. Remove uses of to_remove_edges and to_update_switch_stmts. (vr_values::~vr_values): Remove uses of to_remove_edges and to_update_switch_stmts. (vr_values::get_vr_for_comparison): Move to simplify_using_ranges class. (vr_values::compare_name_with_value): Same. (vr_values::compare_names): Same. (vr_values::vrp_evaluate_conditional_warnv_with_ops): Same. (vr_values::vrp_evaluate_conditional): Same. (vr_values::vrp_visit_cond_stmt): Same. (find_case_label_ranges): Change value_range_equiv uses to value_range. (vr_values::extract_range_from_stmt): Use simplify_using_ranges class. (vr_values::simplify_truth_ops_using_ranges): Move to simplify_using_ranges class. (vr_values::simplify_div_or_mod_using_ranges): Same. (vr_values::simplify_min_or_max_using_ranges): Same. (vr_values::simplify_abs_using_ranges): Same. (vr_values::simplify_bit_ops_using_ranges): Same. (test_for_singularity): Change value_range_equiv uses to value_range. (range_fits_type_p): Same. (vr_values::simplify_cond_using_ranges_1): Same. (vr_values::simplify_cond_using_ranges_2): Make extern. (vr_values::fold_cond): Move to simplify_using_ranges class. (vr_values::simplify_switch_using_ranges): Same. (vr_values::cleanup_edges_and_switches): Same. (vr_values::simplify_float_conversion_using_ranges): Same. (vr_values::simplify_internal_call_using_ranges): Same. (vr_values::two_valued_val_range_p): Same. (vr_values::simplify_stmt_using_ranges): Move to... (simplify_using_ranges::simplify): ...here. * vr-values.h (class vr_values): Move all the simplification of statements using ranges methods and code from here... (class simplify_using_ranges): ...to here. (simplify_cond_using_ranges_2): New extern prototype.
2020-06-10Merge evrp uses of substitute_and_fold_engine into the engine itself.Aldy Hernandez1-271/+63
This patch merges the evrp uses of the substitute and fold engine into the engine itself, at least the parts that can be re-used by other engine uses. It also adds a context parameter to get_value() for further use. gcc/ * gimple-loop-versioning.cc (loop_versioning::name_prop::get_value): Add stmt parameter. * gimple-ssa-evrp.c (class evrp_folder): New. (class evrp_dom_walker): Remove. (execute_early_vrp): Use evrp_folder instead of evrp_dom_walker. * tree-ssa-ccp.c (ccp_folder::get_value): Add stmt parameter. * tree-ssa-copy.c (copy_folder::get_value): Same. * tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in): Pass stmt to get_value. (substitute_and_fold_engine::replace_phi_args_in): Same. (substitute_and_fold_dom_walker::after_dom_children): Call post_fold_bb. (substitute_and_fold_dom_walker::foreach_new_stmt_in_bb): New. (substitute_and_fold_dom_walker::propagate_into_phi_args): New. (substitute_and_fold_dom_walker::before_dom_children): Adjust to call virtual functions for folding, pre_folding, and post folding. Call get_value with PHI. Tweak dump. * tree-ssa-propagate.h (class substitute_and_fold_engine): New argument to get_value. New virtual function pre_fold_bb. New virtual function post_fold_bb. New virtual function pre_fold_stmt. New virtual function post_new_stmt. New function propagate_into_phi_args. * tree-vrp.c (vrp_folder::get_value): Add stmt argument. * vr-values.c (vr_values::extract_range_from_stmt): Adjust dump output. (vr_values::fold_cond): New. (vr_values::simplify_cond_using_ranges_1): Call fold_cond. * vr-values.h (class vr_values): Add simplify_cond_using_ranges_when_edge_is_known. gcc/testsuite/ * gcc.dg/tree-ssa/ssa-dse-30.c: Adjust test for folding of memmove happening later.
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-11-05The base class for ranges is currently value_range_base, which is rather ↵Aldy Hernandez1-4/+5
long and cumbersome. The base class for ranges is currently value_range_base, which is rather long and cumbersome. It also occurs more often than the derived class of value_range. To avoid confusion, and save typing, this patch does a global rename from value_range to value_range_equiv, and from value_range_base to value_range. This way, the base class is simply value_range, and the derived class is value_range_equiv which explicitly states what it does. From-SVN: r277847
2019-07-25gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions): Make ↵Richard Biener1-3/+4
value_range * temporary const. 2019-07-25 Richard Biener <rguenther@suse.de> * gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions): Make value_range * temporary const. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Likewise. (evrp_range_analyzer::record_ranges_from_): Likewise. (evrp_range_analyzer::pop_value_range): Return a const value_range *, deal with having recorded a const one. * gimple-ssa-evrp-analyze.h (evrp_range_analyzer::get_value_range): Return a const value_range *. (evrp_range_analyzer::pop_value_range): Likewise. (evrp_range_analyzer::stack): Record const value_range *s. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Adjust. * gimple-ssa-sprintf.c (get_int_range): Likewise. (format_integer): Likewise. (sprintf_dom_walker::handle_gimple_call): Likewise. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Likewise. * tree-vrp.c (vrp_prop::set_def_to_varying): Add. (vrp_prop::get_value_range): Adjust. (vrp_prop::vrp_initialize): Use set_def_to_varying instead of modifying the lattice in-place. (vrp_prop::visit_stmt): Likewise. * vr-values.c (vr_values::get_lattice_entry): New private method. (vr_values::get_value_range): Wrap it and return a const value_range *. (vr_values::set_def_to_varying): New. (vr_values::set_defs_to_varying): Use it. (vr_values::update_value_range): Likewise. (vr_values::vrp_stmt_computes_nonzero): Adjust. (values::op_with_constant_singleton_va): Likewise. (vr_values::extract_range_for_var_from_co): Likewise. (vr_values::extract_range_from_ssa_name): Likewise. (vr_values::extract_range_from_cond_expr): Likewise. (vr_values::extract_range_basic): Likewise. (compare_ranges): Take const value_range *, adjust. (compare_range_with_value): Likewise. (vrp_valueize): Adjust. (vrp_valueize_1): Likewise. (vr_values::get_vr_for_comparison): Return a const value_range *. (vr_values::compare_name_with_value): Adjust. (vr_values::compare_names): Likewise. (vr_values::vrp_evaluate_conditional_warnv_with_ops_using_ranges): Likewise. (vr_values::vrp_evaluate_conditional): Likewise. (find_case_label_ranges): Take a const value_range *. (vr_values::vrp_visit_switch_stmt): Adjust. (vr_values::extract_range_from_phi_node): Likewise. (vr_values::simplify_div_or_mod_using_ran): Likewise. (vr_values::simplify_abs_using_ranges): Likewise. (test_for_singularity): Take a const value_range *. (range_fits_type_p): Likewise. (vr_values::simplify_cond_using_ranges_1): Adjust. (vr_values::simplify_cond_using_ranges_2): Likewise. (vr_values::simplify_switch_using_ranges): Likewise. (vr_values::simplify_float_conversion_usi): Likewise. (vr_values::two_valued_val_range_p): Likewise. * vr-values.h (vr_values::get_value_range): Return a const value_range *. (vr_values::set_def_to_varying): New. (vr_values::get_lattice_entry): New private method. (vr_values::get_vr_for_comparison): Return a const value_range *. From-SVN: r273792
2019-06-12Remove value_range_constant_singleton in favor of value_range::singleton_p.Aldy Hernandez1-5/+5
From-SVN: r272182
2019-06-06vr-values.c (vr_values::extract_range_from_ssa_name): Do not put ↵Richard Biener1-0/+17
equivalences on UNDEFINED ranges. 2019-06-06 Richard Biener <rguenther@suse.de> * vr-values.c (vr_values::extract_range_from_ssa_name): Do not put equivalences on UNDEFINED ranges. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Make sure to drop defs of stmts added during simplification to VARYING. From-SVN: r271990
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-12-07gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Add ↵Jeff Law1-0/+1
m_update_global_ranges member. * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Add m_update_global_ranges member. Add corresponding argument to ctor. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::evrp_range_analyzer): Add new argument and initialize m_update_global_ranges. (evrp_range_analyzer::set_ssa_range_info): Assert that we are updating global ranges. (evrp_range_analyzer::record_ranges_from_incoming_edge): Only update global ranges if explicitly requested. (evrp_range_analyzer::record_ranges_from_phis): Similarly. (evrp_range_analyzer::record_ranges_from_stmt): Similarly. * gimple-ssa-evrp.c (evrp_dom_walker): Pass new argument to evrp_range_analyzer ctor. * gimple-ssa-sprintf.c (sprintf_dom_walker): Similarly. * tree-ssa-dom.c (dom_opt_dom_walker): Similarly. * gcc.c-torture/builtins/strnlen.x: New file to filter -Og from options to test. From-SVN: r266897
2018-10-22Add a fun parameter to three stmt_could_throw... functionsMartin Jambor1-1/+1
This long patch only does one simple thing, adds an explicit function parameter to predicates stmt_could_throw_p, stmt_can_throw_external and stmt_can_throw_internal. My motivation was ability to use stmt_can_throw_external in IPA analysis phase without the need to push cfun. As I have discovered, we were already doing that in cgraph.c, which this patch avoids as well. In the process, I had to add a struct function parameter to stmt_could_throw_p and decided to also change the interface of stmt_can_throw_internal just for the sake of some minimal consistency. In the process I have discovered that calling method cgraph_node::create_version_clone_with_body (used by ipa-split, ipa-sra, OMP simd and multiple_target) leads to calls of stmt_can_throw_external with NULL cfun. I have worked around this by making stmt_can_throw_external and stmt_could_throw_p gracefully accept NULL and just be pessimistic in that case. The problem with fixing this in a better way is that struct function for the clone is created after cloning edges where we attempt to push the yet not existing cfun, and moving it before would require a bit of surgery in tree-inline.c. A slightly hackish but simpler fix might be to explicitely pass the "old" function to symbol_table::create_edge because it should be just as good at that moment. In any event, that is a topic for another patch. I believe that currently we incorrectly use cfun in maybe_clean_eh_stmt_fn and maybe_duplicate_eh_stmt_fn, both in tree-eh.c, and so I have fixed these cases too. The bulk of other changes is just mechanical adding of cfun to all users. Bootstrapped and tested on x86_64-linux (also with extra NULLing and restoring cfun to double check it is not used in a place I missed), OK for trunk? Thanks, Martin 2018-10-22 Martin Jambor <mjambor@suse.cz> * tree-eh.h (stmt_could_throw_p): Add function parameter. (stmt_can_throw_external): Likewise. (stmt_can_throw_internal): Likewise. * tree-eh.c (lower_eh_constructs_2): Pass cfun to stmt_could_throw_p. (lower_eh_constructs_2): Likewise. (stmt_could_throw_p): Add fun parameter, use it instead of cfun. (stmt_can_throw_external): Likewise. (stmt_can_throw_internal): Likewise. (maybe_clean_eh_stmt_fn): Pass cfun to stmt_could_throw_p. (maybe_clean_or_replace_eh_stmt): Pass cfun to stmt_could_throw_p. (maybe_duplicate_eh_stmt_fn): Pass new_fun to stmt_could_throw_p. (maybe_duplicate_eh_stmt): Pass cfun to stmt_could_throw_p. (pass_lower_eh_dispatch::execute): Pass cfun to stmt_can_throw_external. (cleanup_empty_eh): Likewise. (verify_eh_edges): Pass cfun to stmt_could_throw_p. * cgraph.c (cgraph_edge::set_call_stmt): Pass a function to stmt_can_throw_external instead of pushing it to cfun. (symbol_table::create_edge): Likewise. * gimple-fold.c (fold_builtin_atomic_compare_exchange): Pass cfun to stmt_can_throw_internal. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Pass cfun to stmt_could_throw_p. * gimple-ssa-store-merging.c (handled_load): Pass cfun to stmt_can_throw_internal. (pass_store_merging::execute): Likewise. * gimple-ssa-strength-reduction.c (find_candidates_dom_walker::before_dom_children): Pass cfun to stmt_could_throw_p. * gimplify-me.c (gimple_regimplify_operands): Pass cfun to stmt_can_throw_internal. * ipa-pure-const.c (check_call): Pass cfun to stmt_could_throw_p and to stmt_can_throw_external. (check_stmt): Pass cfun to stmt_could_throw_p. (check_stmt): Pass cfun to stmt_can_throw_external. (pass_nothrow::execute): Likewise. * trans-mem.c (expand_call_tm): Pass cfun to stmt_can_throw_internal. * tree-cfg.c (is_ctrl_altering_stmt): Pass cfun to stmt_can_throw_internal. (verify_gimple_in_cfg): Pass cfun to stmt_could_throw_p. (stmt_can_terminate_bb_p): Pass cfun to stmt_can_throw_external. (gimple_purge_dead_eh_edges): Pass cfun to stmt_can_throw_internal. * tree-complex.c (expand_complex_libcall): Pass cfun to stmt_could_throw_p and to stmt_can_throw_internal. (expand_complex_multiplication): Pass cfun to stmt_can_throw_internal. * tree-inline.c (copy_edges_for_bb): Likewise. (maybe_move_debug_stmts_to_successors): Likewise. * tree-outof-ssa.c (ssa_is_replaceable_p): Pass cfun to stmt_could_throw_p. * tree-parloops.c (oacc_entry_exit_ok_1): Likewise. * tree-sra.c (scan_function): Pass cfun to stmt_can_throw_external. * tree-ssa-alias.c (stmt_kills_ref_p): Pass cfun to stmt_can_throw_internal. * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Pass cfun to stmt_could_throw_p. (mark_aliased_reaching_defs_necessary_1): Pass cfun to stmt_can_throw_internal. * tree-ssa-forwprop.c (pass_forwprop::execute): Likewise. * tree-ssa-loop-im.c (movement_possibility): Pass cfun to stmt_could_throw_p. * tree-ssa-loop-ivopts.c (find_givs_in_stmt_scev): Likewise. (add_autoinc_candidates): Pass cfun to stmt_can_throw_internal. * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise. (convert_mult_to_fma_1): Likewise. (convert_to_divmod): Likewise. * tree-ssa-phiprop.c (propagate_with_phi): Likewise. * tree-ssa-pre.c (compute_avail): Pass cfun to stmt_could_throw_p. * tree-ssa-propagate.c (substitute_and_fold_dom_walker::before_dom_children): Likewise. * tree-ssa-reassoc.c (suitable_cond_bb): Likewise. (maybe_optimize_range_tests): Likewise. (linearize_expr_tree): Likewise. (reassociate_bb): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_call): Likewise. * tree-ssa-scopedtables.c (hashable_expr_equal_p): Likewise. * tree-ssa-strlen.c (adjust_last_stmt): Likewise. (handle_char_store): Likewise. * tree-vect-data-refs.c (vect_find_stmt_data_reference): Pass cfun to stmt_can_throw_internal. * tree-vect-patterns.c (check_bool_pattern): Pass cfun to stmt_could_throw_p. * tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise. (vectorizable_call): Pass cfun to stmt_can_throw_internal. (vectorizable_simd_clone_call): Likewise. * value-prof.c (gimple_ic): Pass cfun to stmt_could_throw_p. (gimple_stringop_fixed_value): Likewise. From-SVN: r265372
2018-10-17bitmap.c (bitmap_head::dump): New.Aldy Hernandez1-2/+1
* 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-09-21gimple-ssa-evrp.c (evrp_dom_walker::cleanup): Call ↵Jeff Law1-0/+2
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-05-18gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges method.Richard Biener1-0/+8
2018-05-18 Richard Biener <rguenther@suse.de> * gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges method. (evrp_dom_walker::before_dom_children): Call it. * gcc.dg/tree-ssa/pr21559.c: Adjust. * gcc.dg/tree-ssa/pr45397.c: Likewise. * gcc.dg/tree-ssa/pr61839_1.c: Likewise. * gcc.dg/tree-ssa/pr61839_2.c: Likewise. * gcc.dg/tree-ssa/pr61839_4.c: Likewise. * gcc.dg/tree-ssa/vrp17.c: Likewise. * gcc.dg/tree-ssa/vrp18.c: Likewise. * gcc.dg/tree-ssa/vrp23.c: Likewise. * gcc.dg/tree-ssa/vrp24.c: Likewise. * gcc.dg/tree-ssa/vrp58.c: Likewise. * gcc.dg/vrp-min-max-1.c: Likewise. * gcc.dg/vrp-min-max-3.c: New testcase. From-SVN: r260357
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-12-12re PR tree-optimization/83298 (wrong code at -O1, -O2 and -O3 on ↵Jeff Law1-1/+1
x86_64-linux-gnu) PR tree-optimization/83298 PR tree-optimization/83362 PR tree-optimization/83383 * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Make push_value_range a public interface. Add new argument to record_ranges_from_stmt. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_stmt): Add new argument. Update comments. Handle recording temporary equivalences. * tree-ssa-dom.c (dom_opt_opt_walker::before_dom_children): Add new argument to call to evrp_range_analyzer::record_ranges_from_stmt. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Likewise. * tree-ssa-threadedge.c: Include alloc-pool.h, vr-values.h and gimple-ssa-evrp-analyze.h. (record_temporary_equivalences_from_phis): Add new argument. When the PHI arg is an SSA_NAME, set the result's range to the range of the PHI arg. (record_temporary_equivalences_from_stmts_at_dest): Record ranges from statements too. (thread_through_normal_block): Accept new argument, evrp_range_analyzer. Pass it down to children as needed. (thread_outgoing_edges): Likewise. (thread_across_edge): Likewise. Push/pop range state as needed. * tree-ssa-threadedge.h (thread_outgoing_edges): Update prototype. PR tree-optimization/83298 PR tree-optimization/83362 PR tree-optimization/83383 * gcc.c-torture/execute/pr83298.c: New test. * gcc.c-torture/execute/pr83362.c New test. * gcc.c-torture/execute/pr83383.c New test. From-SVN: r255593
2017-12-04re PR tree-optimization/78496 (Missed opportunities for jump threading)Jeff Law1-1/+1
PR tree-optimizatin/78496 * gimple-ssa-evrp-analyze.h (evrp_range_analyzer::get_vr_values): Simplify. * gimple-ssa-evrp-analyze.c: Corresponding changes. * tree-ssa-dom.c: Include alloc-pool.h, tree-vrp.h, vr-values.h and gimple-ssa-evrp-analyze.h. (dom_opt_dom_walker class): Add evrp_range_analyzer member. (simplify_stmt_for_jump_threading): Copy a blob of code from tree-vrp.c to use ranges to simplify statements. (dom_opt_dom_walker::before_dom_children): Call evrp_range_analyzer::{enter,record_ranges_from_stmt} methods. (dom_opt_dom_walker::after_dom_children): Similarly for evrp_range_analyzer::leave. (dom_opt_dom_walker::optimize_stmt): Use EVRP ranges to optimize conditionals. PR tree-optimization/78496 * gcc.dg/builtin-unreachable-6.c: Disable DOM. * gcc.dg/builtin-unreachable-6a.c: New test. * gcc.dg/tree-ssa/20030922-1.c: No longer XFAIL. * gcc.dg/ssa-dom-branch-1.c: Tweak expected output. From-SVN: r255387
2017-11-22* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::evrp_range_analyzer)Jeff Law1-20/+17
Initialize vr_values. (evrp_range_analyzer::try_find_new_range): Call methods attached to vr_values via vr_values class instance rather than delegators. (evrp_range_analyzer::record_ranges_from_phis): Likewise. (evrp_range_analyzer::record_ranges_from_stmt): Likewise. (evrp_range_analyzer::push_value_range): Likewise. (evrp_range_analyzer::pop_value_range): Likewise. * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Remove most delegators. Those remaining are exposed as public interfaces. Make vr_values a pointer and private. (evrp_range_analyzer::~evrp_range_analyzer): Delete the attached vr_values. (evrp_range_analyzer::get_vr_value): New method. * gimple-ssa-evrp.c (class evrp_folder): Use DISABLE_COPY_AND_ASSIGN. (evrp_folder::evrp_folder): New ctor to initialize vr_values. (class evrp_dom_walker): Attach evrp_folder class, initialize it in the ctor. Remove temporary delegators. (evrp_dom_walker::before_dom_children): Call methods in attached evrp_range_analyzer class via class instance pointer. Use free value_range_constant_singleton to remove need for op_with_constant_singleton_value delegator method. Do not create a vrp_prop class instance for every call! Narrow scope of a couple variables. (evrp_dom_walker::cleanup): Call methods in attached evrp_range_analyzer class via class instance pointer. * vr-values.h (class vr_values): Privatize many methods and data members. From-SVN: r255074
2017-11-20Makefile.in (OBJS): Add gimple-ssa-evrp-analyze.o.Jeff Law1-352/+1
* Makefile.in (OBJS): Add gimple-ssa-evrp-analyze.o. * gimple-ssa-evrp-analyze.c: New file pulled from gimple-ssa-evrp.c. * gimple-ssa-evrp-analyze.h: New file pulled from gimple-ssa-evrp.c. * gimple-ssa-evrp.c: Remove bits moved into new files. Include gimple-ssa-evrp-analyze.h. From-SVN: r254961
2017-11-20gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Do not set ↵Jeff Law1-2/+1
BB_VISITED here. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Do not set BB_VISITED here. (evrp_range_analyzer::enter): Set BB_VISITED here instead. From-SVN: r254960
2017-11-17gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted from ↵Jeff Law1-78/+101
evrp_dom_walker class. * gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted from evrp_dom_walker class. Various methods moved into new class. (evrp_range_analyzer::evrp_range_analyzer): Constructor for new class. (evrp_range_analyzer::enter): New method. (evrp_range_analyzer::leave): New method. (evrp_dom_walker): Remove delegators no longer needed by this class. Replace vr_values data member with evrp_range_analyzer From-SVN: r254884
2017-11-17gimple-ssa-evrp.c (evrp_dom_walker::record_ranges_from_phis): New method ↵Jeff Law1-96/+139
extracted from evrp_dom_walker::before_dom_children. * gimple-ssa-evrp.c (evrp_dom_walker::record_ranges_from_phis): New method extracted from evrp_dom_walker::before_dom_children. (evrp_dom_walker::record_ranges_from_stmt): Likewise. (evrp_dom_walker::record_ranges_from_incoming_edge): Likewise. From-SVN: r254883
2017-11-17gimple-ssa-evrp.c (evrp_dom_walker): Add cleanup method.Jeff Law1-33/+47
* gimple-ssa-evrp.c (evrp_dom_walker): Add cleanup method. Add private copy constructor and move assignment operators. Privatize methods and class data where trivially possible. (evrp_dom_walker::cleanup): New function, extracted from execute_early_vrp. Simplify access to class data. From-SVN: r254882
2017-11-10vr-values.h (VR_INITIALIZER): Move #define here.Jeff Law1-0/+624
* vr-values.h (VR_INITIALIZER): Move #define here. * gimple-ssa-evrp.c: New file with contents extracted from tree-vrp.c * Makefile.in (OBJS): Add tree-evrp.o * tree-vrp.h (assert_info): Move structure definition here. (set_value_range_to_varying): Prototype. (vrp_operand_equal_p, range_includes_zero_p): Likewise. (infer_value_range, register_edge_assert_for): Likewise. (stmt_interesting_for_vrp): Likewise. * tree-vrp.c: Move all methods for evrp class into tree-evrp.c. (set_value_range_to_varying): No longer static. (vrp_operand_equal_p, range_includes_zero_p): Likewise. (infer_value_range, register_edge_assert_for): Likewise. From-SVN: r254639