GCC Middle and Back End API Reference
tree-vrp.h File Reference
#include "value-range.h"
Include dependency graph for tree-vrp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int compare_values (tree, tree)
 
int compare_values_warnv (tree, tree, bool *)
 
enum value_range_kind intersect_range_with_nonzero_bits (enum value_range_kind, wide_int *, wide_int *, const wide_int &, signop)
 
bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *)
 
tree find_case_label_range (gswitch *, const irange *vr)
 
bool find_case_label_index (gswitch *, size_t, tree, size_t *)
 
bool overflow_comparison_p (tree_code, tree, tree, tree *)
 

Function Documentation

◆ compare_values()

int compare_values ( tree val1,
tree val2 )
extern
Support routines for Value Range Propagation (VRP).
   Copyright (C) 2016-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Compare values like compare_values_warnv.   

References compare_values_warnv(), and ggc_alloc().

Referenced by test_for_singularity().

◆ compare_values_warnv()

int compare_values_warnv ( tree val1,
tree val2,
bool * strict_overflow_p )
extern
Compare two values VAL1 and VAL2.  Return

        -2 if VAL1 and VAL2 cannot be compared at compile-time,
        -1 if VAL1 < VAL2,
         0 if VAL1 == VAL2,
     +1 if VAL1 > VAL2, and
     +2 if VAL1 != VAL2

This is similar to tree_int_cst_compare but supports pointer values
and values that cannot be compared at compile time.

If STRICT_OVERFLOW_P is not NULL, then set *STRICT_OVERFLOW_P to
true if the return value is only valid if we assume that signed
overflow is undefined.   

References boolean_type_node, build_int_cst(), wi::cmp(), fold_binary_to_constant(), fold_convert, fold_defer_overflow_warnings(), fold_undefer_and_ignore_overflow_warnings(), gcc_assert, get_single_symbol(), ggc_alloc(), integer_onep(), INTEGRAL_TYPE_P, is_gimple_min_invariant(), known_eq, known_gt, known_lt, NULL, operand_equal_p(), POINTER_TYPE_P, poly_int_tree_p(), wi::to_poly_widest(), wi::to_wide(), TREE_CODE, tree_int_cst_compare(), TREE_OVERFLOW, TREE_TYPE, TYPE_OVERFLOW_UNDEFINED, TYPE_SIGN, useless_type_conversion_p(), and warning_suppressed_p().

Referenced by compare_values().

◆ find_case_label_index()

bool find_case_label_index ( gswitch * stmt,
size_t start_idx,
tree val,
size_t * idx )
extern
Searches the case label vector VEC for the index *IDX of the CASE_LABEL
that includes the value VAL.  The search is restricted to the range
[START_IDX, n - 1] where n is the size of VEC.

If there is a CASE_LABEL for VAL, its index is placed in IDX and true is
returned.

If there is no CASE_LABEL for VAL and there is one that is larger than VAL,
it is placed in IDX and false is returned.

If VAL is larger than any CASE_LABEL, n is placed on IDX and false is
returned.  

References CASE_HIGH, CASE_LOW, ggc_alloc(), gimple_switch_label(), gimple_switch_num_labels(), i, NULL, and tree_int_cst_compare().

Referenced by find_case_label_range(), and simplify_using_ranges::simplify_switch_using_ranges().

◆ find_case_label_range() [1/2]

tree find_case_label_range ( gswitch * switch_stmt,
const irange * range_of_op )
extern
Given a SWITCH_STMT, return the case label that encompasses the
known possible values for the switch operand.  RANGE_OF_OP is a
range for the known values of the switch operand.   

References CASE_HIGH, CASE_LOW, find_case_label_range(), ggc_alloc(), gimple_switch_index(), gimple_switch_label(), gimple_switch_num_labels(), i, NULL_TREE, range_cast(), wi::to_wide(), TREE_TYPE, types_compatible_p(), and wide_int_to_tree().

◆ find_case_label_range() [2/2]

bool find_case_label_range ( gswitch * stmt,
tree min,
tree max,
size_t * min_idx,
size_t * max_idx )
extern
Searches the case label vector VEC for the range of CASE_LABELs that is used
for values between MIN and MAX. The first index is placed in MIN_IDX. The
last index is placed in MAX_IDX. If the range of CASE_LABELs is empty
then MAX_IDX < MIN_IDX.
Returns true if the default label is not needed.  

References CASE_HIGH, CASE_LOW, find_case_label_index(), ggc_alloc(), gimple_switch_label(), i, int_const_binop(), and integer_onep().

Referenced by find_case_label_range(), find_case_label_ranges(), back_threader::find_taken_edge_switch(), hybrid_jt_simplifier::simplify(), and simplify_using_ranges::simplify_switch_using_ranges().

◆ intersect_range_with_nonzero_bits()

enum value_range_kind intersect_range_with_nonzero_bits ( enum value_range_kind vr_type,
wide_int * min,
wide_int * max,
const wide_int & nonzero_bits,
signop sgn )
extern
VR_TYPE describes a range with minimum value *MIN and maximum
value *MAX.  Restrict the range to the set of values that have
no bits set outside NONZERO_BITS.  Update *MIN and *MAX and
return the new range type.

SGN gives the sign of the values described by the range.   

References gcc_checking_assert, wi::ge_p(), ggc_alloc(), wi::gt_p(), wi::le_p(), wi::max_value(), wi::min_value(), nonzero_bits(), wi::round_down_for_mask(), wi::round_up_for_mask(), VR_ANTI_RANGE, VR_RANGE, VR_UNDEFINED, and VR_VARYING.

Referenced by split_constant_offset(), and vect_get_range_info().

◆ overflow_comparison_p()

bool overflow_comparison_p ( tree_code code,
tree name,
tree val,
tree * new_cst )
extern
OP0 CODE OP1 is a comparison.  Examine the comparison and potentially
OP1's defining statement to see if it ultimately has the form
OP0 CODE (OP0 PLUS INTEGER_CST)

If so, return TRUE indicating this is an overflow test and store into
*NEW_CST an updated constant that can be used in a narrowed range test.

These statements are left as-is in the IL to facilitate discovery of
{ADD,SUB}_OVERFLOW sequences later in the optimizer pipeline.  But
the alternate range representation is often useful within VRP.   

References ggc_alloc(), overflow_comparison_p_1(), and swap_tree_comparison().

Referenced by simplify_using_ranges::legacy_fold_cond_overflow().