From 79f71ec6fca0e093d27cb238d7c75dccb3a55d65 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 15 Jul 2021 12:38:36 +0200 Subject: Abstract out non_null adjustments in ranger. 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. --- gcc/gimple-range.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'gcc/gimple-range.cc') diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 1851339..b210787 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -69,9 +69,7 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt) if (def_stmt && gimple_bb (def_stmt) == bb) { range_of_stmt (r, def_stmt, expr); - if (!cfun->can_throw_non_call_exceptions && r.varying_p () && - m_cache.m_non_null.non_null_deref_p (expr, bb)) - r = range_nonzero (TREE_TYPE (expr)); + m_cache.m_non_null.adjust_range (r, expr, bb, true); } else // Otherwise OP comes from outside this block, use range on entry. @@ -95,9 +93,7 @@ gimple_ranger::range_on_entry (irange &r, basic_block bb, tree name) if (m_cache.block_range (entry_range, bb, name)) r.intersect (entry_range); - if (!cfun->can_throw_non_call_exceptions && r.varying_p () && - m_cache.m_non_null.non_null_deref_p (name, bb)) - r = range_nonzero (TREE_TYPE (name)); + m_cache.m_non_null.adjust_range (r, name, bb, true); } // Calculate the range for NAME at the end of block BB and return it in R. -- cgit v1.1