aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-cache.h
AgeCommit message (Collapse)AuthorFilesLines
2021-07-15Abstract out non_null adjustments in ranger.Aldy Hernandez1-0/+2
There are 4 exact copies of the non-null range adjusting code in the ranger. This patch abstracts the functionality into a separate method. As a follow-up I would like to remove the varying_p check, since I have seen incoming ranges such as [0, 0xff....ef] which are not varying, but are not-null. Removing the varying restriction catches those. gcc/ChangeLog: * gimple-range-cache.cc (non_null_ref::adjust_range): New. (ranger_cache::range_of_def): Call adjust_range. (ranger_cache::entry_range): Same. * gimple-range-cache.h (non_null_ref::adjust_range): New. * gimple-range.cc (gimple_ranger::range_of_expr): Call adjust_range. (gimple_ranger::range_on_entry): Same.
2021-06-23Do not continue propagating values which cannot be set properly.Andrew MacLeod1-0/+1
If the on-entry cache cannot properly represent a range, do not continue trying to propagate it. PR tree-optimization/101148 PR tree-optimization/101014 * gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust. (ranger_cache::~ranger_cache): Adjust. (ranger_cache::block_range): Check if propagation disallowed. (ranger_cache::propagate_cache): Disallow propagation if new value can't be stored properly. * gimple-range-cache.h (ranger_cache::m_propfail): New member.
2021-06-23Adjust on_entry cache to indicate if the value was set properly.Andrew MacLeod1-1/+1
* gimple-range-cache.cc (class ssa_block_ranges): Adjust prototype. (sbr_vector::set_bb_range): Return true. (class sbr_sparse_bitmap): Adjust. (sbr_sparse_bitmap::set_bb_range): Return value. (block_range_cache::set_bb_range): Return value. (ranger_cache::propagate_cache): Use return value to print msg. * gimple-range-cache.h (class block_range_cache): Adjust.
2021-06-18Calculate a global definition if one has not been registered.Andrew MacLeod1-1/+1
With poor values gone, Pick up range restrictions from statements by folding them with global cache values. * gimple-range-cache.cc (ranger_cache::range_of_def): Calculate a range if global is not available. (ranger_cache::entry_range): Fallback to range_of_def. * gimple-range-cache.h (range_of_def): Adjust prototype.
2021-06-18Remove poor value computations.Andrew MacLeod1-12/+1
Remove the old "poor value" approach which made callbacks into ranger from the cache. Use only the best available value for all propagation. PR tree-optimization/101014 * gimple-range-cache.cc (ranger_cache::ranger_cache): Remove poor value list. (ranger_cache::~ranger_cache): Ditto. (ranger_cache::enable_new_values): Delete. (ranger_cache::push_poor_value): Delete. (ranger_cache::range_of_def): Remove poor value processing. (ranger_cache::entry_range): Ditto. (ranger_cache::fill_block_cache): Ditto. * gimple-range-cache.h (class ranger_cache): Remove poor value members. * gimple-range.cc (gimple_ranger::range_of_expr): Remove call. * gimple-range.h (class gimple_ranger): Adjust.
2021-06-14Limit new value calculations to first order effects.Andrew MacLeod1-2/+1
When utilzing poor values during propagation, we mostly care about values that were undefined/processed directly used in calcualting the SSA_NAME being processed. 2nd level derivations of such poor values rarely affect the inital calculation. Leave them to when they are directly encountered. * gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust. (ranger_cache::enable_new_values): Set to specified value and return the old value. (ranger_cache::disable_new_values): Delete. (ranger_cache::fill_block_cache): Disable non 1st order derived poor values. * gimple-range-cache.h (ranger_cache): Adjust prototypes. * gimple-range.cc (gimple_ranger::range_of_expr): Adjust.
2021-06-07Implement a sparse bitmap representation for Rangers on-entry cache.Andrew MacLeod1-0/+1
Use a sparse representation for the on entry cache, and utilize it when the number of basic blocks in the function exceeds param_evrp_sparse_threshold. PR tree-optimization/PR100299 * gimple-range-cache.cc (class sbr_sparse_bitmap): New. (sbr_sparse_bitmap::sbr_sparse_bitmap): New. (sbr_sparse_bitmap::bitmap_set_quad): New. (sbr_sparse_bitmap::bitmap_get_quad): New. (sbr_sparse_bitmap::set_bb_range): New. (sbr_sparse_bitmap::get_bb_range): New. (sbr_sparse_bitmap::bb_range_p): New. (block_range_cache::block_range_cache): initialize bitmap obstack. (block_range_cache::~block_range_cache): Destruct obstack. (block_range_cache::set_bb_range): Decide when to utilze the sparse on entry cache. * gimple-range-cache.h (block_range_cache): Add bitmap obstack. * params.opt (-param=evrp-sparse-threshold): New.
2021-05-31Do not calculate new values when evaluating a debug statement.Andrew MacLeod1-0/+3
Add a flag to enable/disable immediately improving poor values found during cache propagation. Then disable it when processing debug statements. gcc/ PR tree-optimization/100781 * gimple-range-cache.cc (ranger_cache::ranger_cache): Enable new value calculation by default. (ranger_cache::enable_new_values): New. (ranger_cache::disable_new_values): New. (ranger_cache::push_poor_value): Check if new values are allowed. * gimple-range-cache.h (class ranger_cache): New member/methods. * gimple-range.cc (gimple_ranger::range_of_expr): Check for debug statement, and disable/renable new value calculation. gcc/testsuite/ PR tree-optimization/100781 * gcc.dg/pr100781.c: New.
2021-05-31Replace ssa_range_in_bb with entry exit and def rangeAndrew MacLeod1-2/+5
Split the old functionality of ssa_name_in_bb into the components for definition in a block, entry and exit range. Call these as appropriate. * gimple-range-cache.cc (ranger_cache::ssa_range_in_bb): Delete. (ranger_cache::range_of_def): New. (ranger_cache::entry_range): New. (ranger_cache::exit_range): New. (ranger_cache::range_of_expr): Adjust. (ranger_cache::range_on_edge): Adjust. (ranger_cache::propagate_cache): Call exit_range directly. * gimple-range-cache.h (class ranger_cache): Adjust.
2021-05-31Move Ranger cache to range-query and fur_source model.Andrew MacLeod1-4/+7
Flatten and simplify gori-computes. Tweak debug output. range-cache now provides range_of_expr and range_on_edge in the standard formats, but in a "query what you have" mode rather than "go figure out anything that is missing" mode. * gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust for gori_compute being a member rather than base class. dervied call to member call. (ranger_cache::dump): No longer dump gori_map. (ranger_cache::dump_bb): New. (ranger_cache::get_non_stale_global_range): Adjust for gori_compute being a member rather than base class. (ranger_cache::set_global_range): Ditto. (ranger_cache::ssa_range_in_bb): Ditto. (ranger_cache::range_of_expr): New. (ranger_cache::range_on_edge): New. (ranger_cache::block_range): Adjust for gori_computes. Debug changes. (ranger_cache::propagate_cache): Adjust debugging output. (ranger_cache::fill_block_cache): Adjust for gori_computes. Debug output changes. * gimple-range-cache.h (class ranger_cache): Make gori_compute a member, and inherit from range_query instead. (ranger_cache::dump_bb): New. split from dump. * gimple-range-gori.cc (gori_compute::ssa_range_in_bb): Delete. (gori_compute::expr_range_at_stmt): Delete. (gori_compute::compute_name_range_op): Delete. (gori_compute::compute_operand_range_switch): Add fur_source. (gori_compute::compute_operand_range): Add fur_source param, inline old compute_name_range_op and optimize_logical_operands. (struct tf_range): Delete. (gori_compute::logical_combine): Adjust (gori_compute::optimize_logical_operands): Delete. (gori_compute::compute_logical_operands_in_chain): Delete. (gori_compute::compute_logical_operands): Adjust. (gori_compute::compute_operand1_range): Adjust to fur_source. (gori_compute::compute_operand2_range): Ditto. (gori_compute::compute_operand1_and_operand2_range): Ditto. (gori_compute::outgoing_edge_range_p): Add range_query parameter, and adjust to fur_source. * gimple-range-gori.h (class gori_compute): Simplify and adjust to range_query and fur_source. * gimple-range.cc (gimple_ranger::range_on_edge): Query range_on_edge from the ranger_cache.. (gimple_ranger::fold_range_internal): Adjust to base class change of ranger_cache. (gimple_ranger::dump_bb): Adjust dump. * gimple-range.h (gimple_ranger):export gori computes object.
2021-05-25Unify temporal cache with gori dependencies.Andrew MacLeod1-1/+0
Move the temporal cache to strictly be a timestamp, and query GORI for the dependencies rather than trying to register and maintain them. * gimple-range-cache.cc (struct range_timestamp): Delete. (class temporal_cache): Adjust. (temporal_cache::get_timestamp): Delete. (temporal_cache::set_dependency): Delete. (temporal_cache::temporal_value): Adjust. (temporal_cache::current_p): Take dependencies as params. (temporal_cache::set_timestamp): Adjust. (temporal_cache::set_always_current): Adjust. (ranger_cache::get_non_stale_global_range): Adjust. (ranger_cache::register_dependency): Delete. * gimple-range-cache.h (class range_cache): Adjust.
2021-05-07Clean up and virtualize the on-entry cache interface.Andrew MacLeod1-1/+0
Cleanup/Virtualize the ssa_block_range class, and implement the current vector approach as a derived class. Allow memory allocation from the irange allocator obstack for easy freeing. * gimple-range-cache.cc (ssa_block_ranges): Virtualize. (sbr_vector): Renamed from ssa_block_cache. (sbr_vector::sbr_vector): Allocate from obstack abd initialize. (ssa_block_ranges::~ssa_block_ranges): Remove. (sbr_vector::set_bb_range): Use varying and undefined cached values. (ssa_block_ranges::set_bb_varying): Remove. (sbr_vector::get_bb_range): Adjust assert. (sbr_vector::bb_range_p): Adjust assert. (~block_range_cache): No freeing loop required. (block_range_cache::get_block_ranges): Remove. (block_range_cache::set_bb_range): Inline get_block_ranges. (block_range_cache::set_bb_varying): Remove. * gimple-range-cache.h (set_bb_varying): Remove prototype. * value-range.h (irange_allocator::get_memory): New.
2021-05-07When searching for non-null, check the dominator tree.Andrew MacLeod1-1/+1
The non-null bitmap only indicates which blocks non-null setting occurs. Generalized queries need to search the dom tree, whereas propagation engines only need to know the current block. Add a flag for this purpose. * gimple-range-cache.cc (non_null_ref::non_null_deref_p): Search dominator tree is available and requested. (ranger_cache::ssa_range_in_bb): Don't search dom tree here. (ranger_cache::fill_block_cache): Don't search dom tree here either. * gimple-range-cache.h (non_null_deref_p): Add dom_search param.
2021-04-19tree-optimization/100081 - Limit depth of logical expression windback.Andrew MacLeod1-1/+1
Limit how many logical expressions GORI will look back through when evaluating outgoing edge range. PR tree-optimization/100081 * gimple-range-cache.h (ranger_cache): Inherit from gori_compute rather than gori_compute_cache. * gimple-range-gori.cc (is_gimple_logical_p): Move to top of file. (range_def_chain::m_logical_depth): New member. (range_def_chain::range_def_chain): Initialize m_logical_depth. (range_def_chain::get_def_chain): Don't build defchains through more than LOGICAL_LIMIT logical expressions. * params.opt (param_ranger_logical_depth): New.
2021-01-04Update copyright years.Jakub Jelinek1-1/+1
2020-11-04Add Ranger temporal cacheAndrew MacLeod1-0/+3
Add a timestamp to supplement the global range cache to detect when a value may become stale. gcc/ PR tree-optimization/97515 * gimple-range-cache.h (class ranger_cache): New prototypes plus temporal cache pointer. * gimple-range-cache.cc (struct range_timestamp): New. (class temporal_cache): New. (temporal_cache::temporal_cache): New. (temporal_cache::~temporal_cache): New. (temporal_cache::get_timestamp): New. (temporal_cache::set_dependency): New. (temporal_cache::temporal_value): New. (temporal_cache::current_p): New. (temporal_cache::set_timestamp): New. (temporal_cache::set_always_current): New. (ranger_cache::ranger_cache): Allocate the temporal cache. (ranger_cache::~ranger_cache): Free temporal cache. (ranger_cache::get_non_stale_global_range): New. (ranger_cache::set_global_range): Add a timestamp. (ranger_cache::register_dependency): New. Add timestamp dependency. * gimple-range.cc (gimple_ranger::range_of_range_op): Add operand dependencies. (gimple_ranger::range_of_phi): Ditto. (gimple_ranger::range_of_stmt): Check if global range is stale, and recalculate if so. gcc/testsuite/ * gcc.dg/pr97515.c: Check listing for folding of entire function.
2020-11-03More Ranger cache tweaksAndrew MacLeod1-4/+6
This patch splits the individual value propagation out from fill_block_cache, and calls it from set_global_value when the global value is updated. This ensures the "current" global value is reflected in the on-entry cache. * gimple-range-cache.cc (ssa_global_cache::get_global_range): Return true if there was a previous range set. (ranger_cache::ranger_cache): Take a gimple_ranger parameter. (ranger_cache::set_global_range): Propagate the value if updating. (ranger_cache::propagate_cache): Renamed from iterative_cache_update. (ranger_cache::propagate_updated_value): New. Split from: (ranger_cache::fill_block_cache): Split out value propagator. * gimple-range-cache.h (ssa_global_cache): Update prototypes. (ranger_cache): Update prototypes.
2020-11-03Tweaks to ranger cacheAndrew MacLeod1-2/+9
Add some bounds checking to ssa_block_ranges, and privatize the ranges block cache and global cache, adding API points for accessing them. * gimple-range-cache.h (block_range_cache): Add new entry point. (ranger_cache): Privatize global abnd block cache members. * gimple-range-cache.cc (ssa_block_ranges::set_bb_range): Add bounds check. (ssa_block_ranges::set_bb_varying): Ditto. (ssa_block_ranges::get_bb_range): Ditto. (ssa_block_ranges::bb_range_p): Ditto. (block_range_cache::get_block_ranges): Fix formatting. (block_range_cache::query_block_ranges): New. (block_range_cache::get_bb_range): Use Query_block_ranges. (block_range_cache::bb_range_p): Ditto. (ranger_cache::dump): New. (ranger_cache::get_global_range): New. (ranger_cache::set_global_range): New. * gimple-range.cc (gimple_ranger::range_of_expr): Use new API. (gimple_ranger::range_of_stmt): Ditto. (gimple_ranger::export_global_ranges): Ditto. (gimple_ranger::dump): Ditto.
2020-10-06Ranger classes.Andrew MacLeod1-0/+120
Add the 8 ranger files and the Makefile changes to build it. 2020-10-06 Andrew MacLeod <amacleod@redhat.com> * Makefile.in (OBJS): Add gimple-range*.o. * gimple-range.h: New file. * gimple-range.cc: New file. * gimple-range-cache.h: New file. * gimple-range-cache.cc: New file. * gimple-range-edge.h: New file. * gimple-range-edge.cc: New file. * gimple-range-gori.h: New file. * gimple-range-gori.cc: New file.