GCC Middle and Back End API Reference
range-op.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "insn-codes.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "ssa.h"
#include "optabs-tree.h"
#include "gimple-pretty-print.h"
#include "diagnostic-core.h"
#include "flags.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "calls.h"
#include "cfganal.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "tree-eh.h"
#include "gimple-walk.h"
#include "tree-cfg.h"
#include "wide-int.h"
#include "value-relation.h"
#include "range-op.h"
#include "tree-ssa-ccp.h"
#include "range-op-mixed.h"
Include dependency graph for range-op.cc:

Data Structures

class  operator_widen_plus_signed
 
class  operator_widen_plus_unsigned
 
class  operator_widen_mult_signed
 
class  operator_widen_mult_unsigned
 
class  operator_div
 
class  operator_exact_divide
 
class  operator_lshift
 
class  operator_rshift
 
class  operator_logical_and
 
class  operator_logical_or
 
class  operator_trunc_mod
 
class  operator_logical_not
 
class  operator_unknown
 
class  operator_absu
 

Macros

#define INCLUDE_MEMORY
 

Functions

constexpr unsigned dispatch_trio (unsigned lhs, unsigned op1, unsigned op2)
 
static bool has_pointer_operand_p (const vrange &r1, const vrange &r2, const vrange &r3)
 
void update_known_bitmask (vrange &r, tree_code code, const vrange &lh, const vrange &rh)
 
static wide_int max_limit (const_tree type)
 
static wide_int min_limit (const_tree type)
 
static bool get_shift_range (irange &r, tree type, const irange &op)
 
static void value_range_from_overflowed_bounds (irange &r, tree type, const wide_int &wmin, const wide_int &wmax)
 
static void value_range_with_overflow (irange &r, tree type, const wide_int &wmin, const wide_int &wmax, wi::overflow_type min_ovf=wi::OVF_NONE, wi::overflow_type max_ovf=wi::OVF_NONE)
 
static void create_possibly_reversed_range (irange &r, tree type, const wide_int &new_lb, const wide_int &new_ub)
 
bool_range_state get_bool_state (vrange &r, const vrange &lhs, tree val_type)
 
static void build_lt (irange &r, tree type, const wide_int &val)
 
static void build_le (irange &r, tree type, const wide_int &val)
 
static void build_gt (irange &r, tree type, const wide_int &val)
 
static void build_ge (irange &r, tree type, const wide_int &val)
 
static relation_kind plus_minus_ranges (irange &r_ov, irange &r_normal, const irange &offset, bool add_p)
 
static void adjust_op1_for_overflow (irange &r, const irange &op2, relation_kind rel, bool add_p)
 
bool minus_op1_op2_relation_effect (irange &lhs_range, tree type, const irange &op1_range, const irange &op2_range, relation_kind rel)
 
static bool wi_optimize_signed_bitwise_op (irange &r, tree type, const wide_int &lh_lb, const wide_int &lh_ub, const wide_int &rh_lb, const wide_int &rh_ub)
 
static bool wi_optimize_and_or (irange &r, enum tree_code code, tree type, const wide_int &lh_lb, const wide_int &lh_ub, const wide_int &rh_lb, const wide_int &rh_ub)
 
void wi_set_zero_nonzero_bits (tree type, const wide_int &lb, const wide_int &ub, wide_int &maybe_nonzero, wide_int &mustbe_nonzero)
 
static void set_nonzero_range_from_mask (irange &r, tree type, const irange &lhs)
 
wide_int masked_increment (const wide_int &val_in, const wide_int &mask, const wide_int &sgnbit, unsigned int prec)
 

Variables

operator_equal op_equal
 
operator_not_equal op_not_equal
 
operator_lt op_lt
 
operator_le op_le
 
operator_gt op_gt
 
operator_ge op_ge
 
operator_identity op_ident
 
operator_cst op_cst
 
operator_cast op_cast
 
operator_plus op_plus
 
operator_abs op_abs
 
operator_minus op_minus
 
operator_negate op_negate
 
operator_mult op_mult
 
operator_addr_expr op_addr
 
operator_bitwise_not op_bitwise_not
 
operator_bitwise_xor op_bitwise_xor
 
operator_bitwise_and op_bitwise_and
 
operator_bitwise_or op_bitwise_or
 
operator_min op_min
 
operator_max op_max
 
range_op_table operator_table
 
range_operator default_operator
 
const unsigned RO_III = dispatch_trio (VR_IRANGE, VR_IRANGE, VR_IRANGE)
 
const unsigned RO_IFI = dispatch_trio (VR_IRANGE, VR_FRANGE, VR_IRANGE)
 
const unsigned RO_IFF = dispatch_trio (VR_IRANGE, VR_FRANGE, VR_FRANGE)
 
const unsigned RO_FFF = dispatch_trio (VR_FRANGE, VR_FRANGE, VR_FRANGE)
 
const unsigned RO_FIF = dispatch_trio (VR_FRANGE, VR_IRANGE, VR_FRANGE)
 
const unsigned RO_FII = dispatch_trio (VR_FRANGE, VR_IRANGE, VR_IRANGE)
 
const unsigned RO_PPP = dispatch_trio (VR_PRANGE, VR_PRANGE, VR_PRANGE)
 
const unsigned RO_PPI = dispatch_trio (VR_PRANGE, VR_PRANGE, VR_IRANGE)
 
const unsigned RO_IPP = dispatch_trio (VR_IRANGE, VR_PRANGE, VR_PRANGE)
 
const unsigned RO_IPI = dispatch_trio (VR_IRANGE, VR_PRANGE, VR_IRANGE)
 
const unsigned RO_PIP = dispatch_trio (VR_PRANGE, VR_IRANGE, VR_PRANGE)
 
const unsigned RO_PII = dispatch_trio (VR_PRANGE, VR_IRANGE, VR_IRANGE)
 
operator_widen_plus_signed op_widen_plus_signed
 
operator_widen_plus_unsigned op_widen_plus_unsigned
 
operator_widen_mult_signed op_widen_mult_signed
 
operator_widen_mult_unsigned op_widen_mult_unsigned
 
static operator_div op_trunc_div (TRUNC_DIV_EXPR)
 
static operator_div op_floor_div (FLOOR_DIV_EXPR)
 
static operator_div op_round_div (ROUND_DIV_EXPR)
 
static operator_div op_ceil_div (CEIL_DIV_EXPR)
 
operator_exact_divide op_exact_div
 
operator_lshift op_lshift
 
operator_rshift op_rshift
 
operator_logical_and op_logical_and
 
operator_logical_or op_logical_or
 
operator_trunc_mod op_trunc_mod
 
operator_logical_not op_logical_not
 
operator_unknown op_unknown
 
operator_absu op_absu
 

Macro Definition Documentation

◆ INCLUDE_MEMORY

#define INCLUDE_MEMORY
Code for range operators.
   Copyright (C) 2017-2024 Free Software Foundation, Inc.
   Contributed by Andrew MacLeod <amacleod@redhat.com>
   and Aldy Hernandez <aldyh@redhat.com>.

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/>.   

Function Documentation

◆ adjust_op1_for_overflow()

static void adjust_op1_for_overflow ( irange & r,
const irange & op2,
relation_kind rel,
bool add_p )
static

◆ build_ge()

static void build_ge ( irange & r,
tree type,
const wide_int & val )
static

References max_limit(), and r.

◆ build_gt()

static void build_gt ( irange & r,
tree type,
const wide_int & val )
static

◆ build_le()

static void build_le ( irange & r,
tree type,
const wide_int & val )
static

References min_limit(), and r.

◆ build_lt()

static void build_lt ( irange & r,
tree type,
const wide_int & val )
static

◆ create_possibly_reversed_range()

static void create_possibly_reversed_range ( irange & r,
tree type,
const wide_int & new_lb,
const wide_int & new_ub )
inlinestatic

◆ dispatch_trio()

unsigned dispatch_trio ( unsigned lhs,
unsigned op1,
unsigned op2 )
constexpr

◆ get_bool_state()

bool_range_state get_bool_state ( vrange & r,
const vrange & lhs,
tree val_type )

◆ get_shift_range()

static bool get_shift_range ( irange & r,
tree type,
const irange & op )
inlinestatic

◆ has_pointer_operand_p()

static bool has_pointer_operand_p ( const vrange & r1,
const vrange & r2,
const vrange & r3 )
inlinestatic

References is_a< prange >().

◆ masked_increment()

wide_int masked_increment ( const wide_int & val_in,
const wide_int & mask,
const wide_int & sgnbit,
unsigned int prec )
Find out smallest RES where RES > VAL && (RES & MASK) == RES, if any
(otherwise return VAL).  VAL and MASK must be zero-extended for
precision PREC.  If SGNBIT is non-zero, first xor VAL with SGNBIT
(to transform signed values into unsigned) and at the end xor
SGNBIT back.   

References wi::bit_and_not(), wi::gtu_p(), i, and wi::one().

Referenced by operator_bitwise_and::simple_op1_range_solver().

◆ max_limit()

static wide_int max_limit ( const_tree type)
inlinestatic

References irange_val_max().

Referenced by build_ge(), and build_gt().

◆ min_limit()

static wide_int min_limit ( const_tree type)
inlinestatic

References irange_val_min().

Referenced by build_le(), and build_lt().

◆ minus_op1_op2_relation_effect()

◆ plus_minus_ranges()

static relation_kind plus_minus_ranges ( irange & r_ov,
irange & r_normal,
const irange & offset,
bool add_p )
static

◆ set_nonzero_range_from_mask()

static void set_nonzero_range_from_mask ( irange & r,
tree type,
const irange & lhs )
static

◆ update_known_bitmask()

void update_known_bitmask ( vrange & r,
tree_code code,
const vrange & lh,
const vrange & rh )
Header file for mixed range operator class.
   Copyright (C) 2017-2024 Free Software Foundation, Inc.
   Contributed by Andrew MacLeod <amacleod@redhat.com>
   and Aldy Hernandez <aldyh@redhat.com>.

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/>.   

References bit_value_binop(), bit_value_unop(), wide_int_storage::from(), gcc_unreachable, vrange::get_bitmask(), get_gimple_rhs_class(), GIMPLE_BINARY_RHS, GIMPLE_UNARY_RHS, irange_bitmask::mask(), r, vrange::type(), TYPE_PRECISION, TYPE_SIGN, vrange::undefined_p(), and irange_bitmask::value().

Referenced by operator_bitwise_and::fold_range(), operator_bitwise_or::fold_range(), operator_max::fold_range(), operator_min::fold_range(), pointer_plus_operator::fold_range(), operator_abs::update_bitmask(), operator_absu::update_bitmask(), operator_bitwise_and::update_bitmask(), operator_bitwise_not::update_bitmask(), operator_bitwise_or::update_bitmask(), operator_bitwise_xor::update_bitmask(), operator_cast::update_bitmask(), operator_div::update_bitmask(), operator_equal::update_bitmask(), operator_ge::update_bitmask(), operator_gt::update_bitmask(), operator_le::update_bitmask(), operator_lshift::update_bitmask(), operator_lt::update_bitmask(), operator_max::update_bitmask(), operator_min::update_bitmask(), operator_minus::update_bitmask(), operator_mult::update_bitmask(), operator_not_equal::update_bitmask(), operator_plus::update_bitmask(), operator_pointer_diff::update_bitmask(), operator_rshift::update_bitmask(), operator_trunc_mod::update_bitmask(), and pointer_plus_operator::update_bitmask().

◆ value_range_from_overflowed_bounds()

static void value_range_from_overflowed_bounds ( irange & r,
tree type,
const wide_int & wmin,
const wide_int & wmax )
static

◆ value_range_with_overflow()

◆ wi_optimize_and_or()

static bool wi_optimize_and_or ( irange & r,
enum tree_code code,
tree type,
const wide_int & lh_lb,
const wide_int & lh_ub,
const wide_int & rh_lb,
const wide_int & rh_ub )
static

◆ wi_optimize_signed_bitwise_op()

static bool wi_optimize_signed_bitwise_op ( irange & r,
tree type,
const wide_int & lh_lb,
const wide_int & lh_ub,
const wide_int & rh_lb,
const wide_int & rh_ub )
static

◆ wi_set_zero_nonzero_bits()

Variable Documentation

◆ default_operator

◆ op_abs

◆ op_absu

◆ op_addr

◆ op_bitwise_and

◆ op_bitwise_not

◆ op_bitwise_or

◆ op_bitwise_xor

◆ op_cast

◆ op_ceil_div

operator_div op_ceil_div(CEIL_DIV_EXPR) ( CEIL_DIV_EXPR )
static

◆ op_cst

◆ op_equal

◆ op_exact_div

◆ op_floor_div

operator_div op_floor_div(FLOOR_DIV_EXPR) ( FLOOR_DIV_EXPR )
static

◆ op_ge

◆ op_gt

◆ op_ident

◆ op_le

◆ op_logical_and

◆ op_logical_not

◆ op_logical_or

◆ op_lshift

◆ op_lt

◆ op_max

◆ op_min

◆ op_minus

◆ op_mult

◆ op_negate

◆ op_not_equal

◆ op_plus

◆ op_round_div

operator_div op_round_div(ROUND_DIV_EXPR) ( ROUND_DIV_EXPR )
static

◆ op_rshift

◆ op_trunc_div

operator_div op_trunc_div(TRUNC_DIV_EXPR) ( TRUNC_DIV_EXPR )
static

◆ op_trunc_mod

◆ op_unknown

◆ op_widen_mult_signed

◆ op_widen_mult_unsigned

◆ op_widen_plus_signed

◆ op_widen_plus_unsigned

◆ operator_table

◆ RO_FFF

◆ RO_FIF

◆ RO_FII

const unsigned RO_FII = dispatch_trio (VR_FRANGE, VR_IRANGE, VR_IRANGE)

◆ RO_IFF

◆ RO_IFI

const unsigned RO_IFI = dispatch_trio (VR_IRANGE, VR_FRANGE, VR_IRANGE)

◆ RO_III

◆ RO_IPI

const unsigned RO_IPI = dispatch_trio (VR_IRANGE, VR_PRANGE, VR_IRANGE)

◆ RO_IPP

◆ RO_PII

◆ RO_PIP

◆ RO_PPI

const unsigned RO_PPI = dispatch_trio (VR_PRANGE, VR_PRANGE, VR_IRANGE)

◆ RO_PPP