GCC Middle and Back End API Reference
fold-const.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "flags.h"
Include dependency graph for fold-const.c:

Enumerations

enum  comparison_code {
  COMPCODE_FALSE = 0, COMPCODE_LT = 1, COMPCODE_EQ = 2, COMPCODE_LE = 3,
  COMPCODE_GT = 4, COMPCODE_LTGT = 5, COMPCODE_GE = 6, COMPCODE_ORD = 7,
  COMPCODE_UNORD = 8, COMPCODE_UNLT = 9, COMPCODE_UNEQ = 10, COMPCODE_UNLE = 11,
  COMPCODE_UNGT = 12, COMPCODE_NE = 13, COMPCODE_UNGE = 14, COMPCODE_TRUE = 15
}

Functions

static bool negate_mathfn_p (enum built_in_function)
static bool negate_expr_p (tree)
static tree negate_expr (tree)
static tree split_tree (tree, enum tree_code, tree *, tree *, tree *, int)
static tree associate_trees (location_t, tree, tree, enum tree_code, tree)
static tree const_binop (enum tree_code, tree, tree)
static enum comparison_code comparison_to_compcode (enum tree_code)
static enum tree_code compcode_to_comparison (enum comparison_code)
static int operand_equal_for_comparison_p (tree, tree, tree)
static int twoval_comparison_p (tree, tree *, tree *, int *)
static tree eval_subst (location_t, tree, tree, tree, tree, tree)
static tree pedantic_omit_one_operand_loc (location_t, tree, tree, tree)
static tree distribute_bit_expr (location_t, enum tree_code, tree, tree, tree)
static tree make_bit_field_ref (location_t, tree, tree, HOST_WIDE_INT, HOST_WIDE_INT, int)
static tree optimize_bit_field_compare (location_t, enum tree_code, tree, tree, tree)
static tree decode_field_reference (location_t, tree, HOST_WIDE_INT *, HOST_WIDE_INT *, enum machine_mode *, int *, int *, tree *, tree *)
static int all_ones_mask_p (const_tree, int)
static tree sign_bit_p (tree, const_tree)
static int simple_operand_p (const_tree)
static bool simple_operand_p_2 (tree)
static tree range_binop (enum tree_code, tree, tree, int, tree, int)
static tree range_predecessor (tree)
static tree range_successor (tree)
static tree fold_range_test (location_t, enum tree_code, tree, tree, tree)
static tree fold_cond_expr_with_comparison (location_t, tree, tree, tree, tree)
static tree unextend (tree, int, int, tree)
static tree optimize_minmax_comparison (location_t, enum tree_code, tree, tree, tree)
static tree extract_muldiv (tree, tree, enum tree_code, tree, bool *)
static tree extract_muldiv_1 (tree, tree, enum tree_code, tree, bool *)
static tree fold_binary_op_with_conditional_arg (location_t, enum tree_code, tree, tree, tree, tree, tree, int)
static tree fold_mathfn_compare (location_t, enum built_in_function, enum tree_code, tree, tree, tree)
static tree fold_inf_compare (location_t, enum tree_code, tree, tree, tree)
static tree fold_div_compare (location_t, enum tree_code, tree, tree, tree)
static bool reorder_operands_p (const_tree, const_tree)
static tree fold_negate_const (tree, tree)
static tree fold_not_const (const_tree, tree)
static tree fold_relational_const (enum tree_code, tree, tree, tree)
static tree fold_convert_const (enum tree_code, tree, tree)
static location_t expr_location_or ()
static tree protected_set_expr_location_unshare ()
tree div_if_zero_remainder ()
void fold_defer_overflow_warnings ()
void fold_undefer_overflow_warnings ()
void fold_undefer_and_ignore_overflow_warnings ()
bool fold_deferring_overflow_warnings_p ()
static void fold_overflow_warning ()
static bool negate_mathfn_p ()
bool may_negate_without_overflow_p ()
static bool negate_expr_p ()
static tree fold_negate_expr ()
static tree negate_expr ()
static tree associate_trees ()
static bool int_binop_types_match_p ()
static tree int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree arg2, int overflowable)
tree int_const_binop ()
static tree const_binop ()
tree size_int_kind ()
tree size_binop_loc ()
tree size_diffop_loc ()
static tree fold_convert_const_int_from_int ()
static tree fold_convert_const_int_from_real ()
static tree fold_convert_const_int_from_fixed ()
static tree fold_convert_const_real_from_real ()
static tree fold_convert_const_real_from_fixed ()
static tree fold_convert_const_fixed_from_fixed ()
static tree fold_convert_const_fixed_from_int ()
static tree fold_convert_const_fixed_from_real ()
static tree fold_convert_const ()
static tree build_zero_vector ()
bool fold_convertible_p ()
tree fold_convert_loc ()
static bool maybe_lvalue_p ()
tree non_lvalue_loc ()
static tree pedantic_non_lvalue_loc ()
enum tree_code invert_tree_comparison ()
enum tree_code swap_tree_comparison ()
static enum comparison_code comparison_to_compcode ()
static enum tree_code compcode_to_comparison ()
tree combine_comparisons (location_t loc, enum tree_code code, enum tree_code lcode, enum tree_code rcode, tree truth_type, tree ll_arg, tree lr_arg)
int operand_equal_p ()
static int operand_equal_for_comparison_p ()
static int twoval_comparison_p ()
tree omit_one_operand_loc ()
tree omit_two_operands_loc (location_t loc, tree type, tree result, tree omitted1, tree omitted2)
static tree fold_truth_not_expr ()
static tree fold_invert_truthvalue ()
tree invert_truthvalue_loc ()
static tree distribute_real_division (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1)
static int all_ones_mask_p ()
static tree sign_bit_p ()
static int simple_operand_p ()
static bool simple_operand_p_2 ()
tree make_range_step (location_t loc, enum tree_code code, tree arg0, tree arg1, tree exp_type, tree *p_low, tree *p_high, int *p_in_p, bool *strict_overflow_p)
tree make_range (tree exp, int *pin_p, tree *plow, tree *phigh, bool *strict_overflow_p)
tree build_range_check (location_t loc, tree type, tree exp, int in_p, tree low, tree high)
static tree range_predecessor ()
static tree range_successor ()
bool merge_ranges (int *pin_p, tree *plow, tree *phigh, int in0_p, tree low0, tree high0, int in1_p, tree low1, tree high1)
static tree unextend ()
static tree merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop, bool rhs_only)
static tree fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, tree lhs, tree rhs)
tree constant_boolean_node ()
bool fold_real_zero_addition_p ()
static tree fold_single_bit_test_into_sign_test (location_t loc, enum tree_code code, tree arg0, tree arg1, tree result_type)
tree fold_single_bit_test (location_t loc, enum tree_code code, tree arg0, tree arg1, tree result_type)
static bool reorder_operands_p ()
bool tree_swap_operands_p ()
static tree fold_widened_comparison (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1)
static tree fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1)
static tree try_move_mult_to_index ()
static tree fold_to_nonsharp_ineq_using_bound ()
static tree fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1)
static int native_encode_int ()
static int native_encode_fixed ()
static int native_encode_real ()
static int native_encode_complex ()
static int native_encode_vector ()
static int native_encode_string ()
int native_encode_expr ()
static tree native_interpret_int ()
static tree native_interpret_fixed ()
static tree native_interpret_real ()
static tree native_interpret_complex ()
static tree native_interpret_vector ()
tree native_interpret_expr ()
static bool can_native_interpret_type_p ()
static tree fold_view_convert_expr ()
tree build_fold_addr_expr_with_type_loc ()
tree build_fold_addr_expr_loc ()
static bool vec_cst_ctor_to_array (tree, tree *)
tree fold_unary_loc ()
tree fold_unary_ignore_overflow_loc (location_t loc, enum tree_code code, tree type, tree op0)
static tree fold_truth_andor (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1, tree op0, tree op1)
static tree fold_minmax ()
static tree maybe_canonicalize_comparison_1 (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1, bool *strict_overflow_p)
static tree maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1)
static bool pointer_may_wrap_p ()
static tree fold_comparison (location_t loc, enum tree_code code, tree type, tree op0, tree op1)
static tree fold_mult_zconjz ()
static unsigned HOST_WIDE_INT get_pointer_modulus_and_residue (tree expr, unsigned HOST_WIDE_INT *residue, bool allow_func_align)
static bool vec_cst_ctor_to_array ()
static tree fold_vec_perm ()
static tree fold_addr_of_array_ref_difference (location_t loc, tree type, tree aref0, tree aref1)
static tree exact_inverse ()
static double_int mask_with_tz ()
tree fold_binary_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1)
static tree contains_label_1 ()
static bool contains_label_p ()
tree fold_ternary_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1, tree op2)
static tree fold_1 (tree)
static tree fold ()
static void fold_checksum_tree (const_tree, struct md5_ctx *, hash_table< pointer_hash< tree_node > >)
static void fold_check_failed (const_tree, const_tree)
void print_fold_checksum (const_tree)
void print_fold_checksum ()
static void fold_check_failed ()
DEBUG_FUNCTION void debug_fold_checksum ()
tree fold_build1_stat_loc (location_t loc, enum tree_code code, tree type, tree op0 MEM_STAT_DECL)
tree fold_build2_stat_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1 MEM_STAT_DECL)
tree fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1, tree op2 MEM_STAT_DECL)
tree fold_build_call_array_loc (location_t loc, tree type, tree fn, int nargs, tree *argarray)
tree fold_build1_initializer_loc (location_t loc, enum tree_code code, tree type, tree op)
tree fold_build2_initializer_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1)
tree fold_build3_initializer_loc (location_t loc, enum tree_code code, tree type, tree op0, tree op1, tree op2)
tree fold_build_call_array_initializer_loc (location_t loc, tree type, tree fn, int nargs, tree *argarray)
int multiple_of_p ()
static bool tree_simple_nonnegative_warnv_p ()
bool tree_unary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0, bool *strict_overflow_p)
bool tree_binary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0, tree op1, bool *strict_overflow_p)
bool tree_single_nonnegative_warnv_p ()
bool tree_call_nonnegative_warnv_p (tree type, tree fndecl, tree arg0, tree arg1, bool *strict_overflow_p)
bool tree_invalid_nonnegative_warnv_p ()
bool tree_expr_nonnegative_warnv_p ()
bool tree_expr_nonnegative_p ()
bool tree_unary_nonzero_warnv_p (enum tree_code code, tree type, tree op0, bool *strict_overflow_p)
bool tree_binary_nonzero_warnv_p (enum tree_code code, tree type, tree op0, tree op1, bool *strict_overflow_p)
bool tree_single_nonzero_warnv_p ()
bool tree_expr_nonzero_warnv_p ()
bool tree_expr_nonzero_p ()
tree fold_binary_to_constant ()
tree fold_unary_to_constant ()
tree fold_read_from_constant_string ()
static tree fold_negate_const ()
tree fold_abs_const ()
static tree fold_not_const ()
static tree fold_relational_const ()
tree fold_build_cleanup_point_expr ()
tree fold_indirect_ref_1 ()
tree build_fold_indirect_ref_loc ()
tree fold_indirect_ref_loc ()
tree fold_ignored_result ()
tree round_up_loc ()
tree round_down_loc ()
static tree split_address_to_core_and_offset (tree exp, HOST_WIDE_INT *pbitpos, tree *poffset)
bool ptr_difference_const ()
tree fold_strip_sign_ops ()

Variables

int folding_initializer = 0
static int fold_deferring_overflow_warnings
static const char * fold_deferred_overflow_warning
static enum
warn_strict_overflow_code 
fold_deferred_overflow_code
int pedantic_lvalues

Enumeration Type Documentation

   The following constants represent a bit based encoding of GCC's
   comparison operators.  This encoding simplifies transformations
   on relational comparison operators, such as AND and OR.  
Enumerator:
COMPCODE_FALSE 
COMPCODE_LT 
COMPCODE_EQ 
COMPCODE_LE 
COMPCODE_GT 
COMPCODE_LTGT 
COMPCODE_GE 
COMPCODE_ORD 
COMPCODE_UNORD 
COMPCODE_UNLT 
COMPCODE_UNEQ 
COMPCODE_UNLE 
COMPCODE_UNGT 
COMPCODE_NE 
COMPCODE_UNGE 
COMPCODE_TRUE 

Function Documentation

static int all_ones_mask_p ( const_tree  ,
int   
)
static
static int all_ones_mask_p ( )
static
   Return nonzero if MASK represents a mask of SIZE ones in the low-order
   bit positions.  
static tree associate_trees ( location_t  ,
tree  ,
tree  ,
enum  tree_code,
tree   
)
static
static tree associate_trees ( )
static
   Re-associate trees split by the above function.  T1 and T2 are
   either expressions to associate or null.  Return the new
   expression, if any.  LOC is the location of the new expression.  If
   we build an operation, do it in TYPE and with CODE.  
     If either input is CODE, a PLUS_EXPR, or a MINUS_EXPR, don't
     try to fold this since we will have infinite recursion.  But do
     deal with any NEGATE_EXPRs.  
tree build_fold_addr_expr_loc ( )
   Build an expression for the address of T.  

References fold_convert_loc(), and negate_expr().

Referenced by initialize_argument_information(), lower_reduction_clauses(), and native_interpret_real().

tree build_fold_addr_expr_with_type_loc ( )
   Build an expression for the address of T.  Folds away INDIRECT_REF
   to avoid confusing the gimplify process.  
     The size of the object is not relevant when talking about its address.  
tree build_fold_indirect_ref_loc ( )
   Builds an expression for an indirection through T, simplifying some
   cases.  
tree build_range_check ( location_t  loc,
tree  type,
tree  exp,
int  in_p,
tree  low,
tree  high 
)
   Given a range, LOW, HIGH, and IN_P, an expression, EXP, and a result
   type, TYPE, return an expression to test if EXP is in (or out of, depending
   on IN_P) the range.  Return 0 if the test couldn't be created.  
     Disable this optimization for function pointer expressions
     on targets that require function pointer canonicalization.  
     Optimize (c>=1) && (c<=127) into (signed char)c > 0.  
     Optimize (c>=low) && (c<=high) into (c-low>=0) && (c-low<=high-low).
     This requires wrap-around arithmetics for the type of the expression.
     First make sure that arithmetics in this type is valid, then make sure
     that it wraps around.  
         Check if (unsigned) INT_MAX + 1 == (unsigned) INT_MIN
         for the type in question, as we rely on this here.  
static tree build_zero_vector ( )
static
   Construct a vector of zero elements of vector type TYPE.  
static bool can_native_interpret_type_p ( )
static
   Returns true if we can interpret the contents of a native encoding
   as TYPE.  
tree combine_comparisons ( location_t  loc,
enum tree_code  code,
enum tree_code  lcode,
enum tree_code  rcode,
tree  truth_type,
tree  ll_arg,
tree  lr_arg 
)
   Return a tree for the comparison which is the combination of
   doing the AND or OR (depending on CODE) of the two operations LCODE
   and RCODE on the identical operands LL_ARG and LR_ARG.  Take into account
   the possibility of trapping if the mode has NaNs, and return NULL_TREE
   if this makes the transformation invalid.  
         Eliminate unordered comparisons, as well as LTGT and ORD
         which are not used unless the mode has NaNs.  
           Check that the original operation and the optimized ones will trap
           under the same condition.  
           In a short-circuited boolean expression the LHS might be
           such that the RHS, if evaluated, will never trap.  For
           example, in ORD (x, y) && (x < y), we evaluate the RHS only
           if neither x nor y is NaN.  (This is a mixed blessing: for
           example, the expression above will never trap, hence
           optimizing it to x < y would be invalid).  
           If the comparison was short-circuited, and only the RHS
           trapped, we may now generate a spurious trap.  
           If we changed the conditions that cause a trap, we lose.  

Referenced by fold_range_test().

static enum comparison_code comparison_to_compcode ( enum  tree_code)
static

Referenced by swap_tree_comparison().

static enum comparison_code comparison_to_compcode ( )
static
   Convert a comparison tree code from an enum tree_code representation
   into a compcode bit-based encoding.  This function is the inverse of
   compcode_to_comparison.  
static enum tree_code compcode_to_comparison ( enum  comparison_code)
static
static enum tree_code compcode_to_comparison ( )
static
   Convert a compcode bit-based encoding of a comparison operator back
   to GCC's enum tree_code representation.  This function is the
   inverse of comparison_to_compcode.  

References tree_int_cst_equal().

static tree const_binop ( enum  tree_code,
tree  ,
tree   
)
static
static tree const_binop ( )
static
   Combine two constants ARG1 and ARG2 under operation CODE to produce a new
   constant.  We assume ARG1 and ARG2 have the same data type, or at least
   are the same kind of constant and the same machine mode.  Return zero if
   combining the constants is not allowed in the current operating mode.  
     Sanity check for the recursive cases.  
         The following codes are handled by real_arithmetic.  
         Don't perform operation if we honor signaling NaNs and
         either operand is a NaN.  
         Don't perform operation if it would raise a division
         by zero exception.  
         If either operand is a NaN, just return it.  Otherwise, set up
         for floating-point trap; we return an overflow.  
         Don't constant fold this floating point operation if
         the result has overflowed and flag_trapping_math.  
         Don't constant fold this floating point operation if the
         result may dependent upon the run-time rounding mode and
         flag_rounding_math is set, or if GCC's software emulation
         is unable to accurately represent the result.  
         The following codes are handled by fixed_arithmetic.  
         Propagate overflow flags.  
                                   do_nonfinite= 
                                   do_nonfinite= 
             Fallthru ... 
               Keep this algorithm in sync with
               tree-complex.c:expand_complex_div_straight().

               Expand complex division to scalars, straightforward algorithm.
               a / b = ((ar*br + ai*bi)/t) + i((ai*br - ar*bi)/t)
               t = br*br + bi*bi
               Keep this algorithm in sync with
               tree-complex.c:expand_complex_div_wide().

               Expand complex division to scalars, modified algorithm to minimize
               overflow with wide input ranges.  
                   In the TRUE branch, we compute
                   ratio = br/bi;
                   div = (br * ratio) + bi;
                   tr = (ar * ratio) + ai;
                   ti = (ai * ratio) - ar;
                   tr = tr / div;
                   ti = ti / div;  
                   In the FALSE branch, we compute
                   ratio = d/c;
                   divisor = (d * ratio) + c;
                   tr = (b * ratio) + a;
                   ti = b - (a * ratio);
                   tr = tr / div;
                   ti = ti / div;  
             It is possible that const_binop cannot handle the given
             code and return NULL_TREE 
     Shifts allow a scalar offset for a vector.  
             The direction of VEC_[LR]SHIFT_EXPR is endian dependent.
             For reductions, compiler emits VEC_RSHIFT_EXPR always,
             for !BYTES_BIG_ENDIAN picks first vector element, but
             for BYTES_BIG_ENDIAN last element from the vector.  
               It is possible that const_binop cannot handle the given
               code and return NULL_TREE 
tree constant_boolean_node ( )
   Return a node which has the indicated constant VALUE (either 0 or
   1 for scalars or {-1,-1,..} or {0,0,...} for vectors),
   and is of the indicated TYPE.  

Referenced by distribute_real_division(), and fold_comparison().

static tree contains_label_1 ( )
static
   Callback for walk_tree, looking for LABEL_EXPR.  Return *TP if it is
   a LABEL_EXPR; otherwise return NULL_TREE.  Do not check the subtrees
   of GOTO_EXPR.  
         ... fall through ...  
static bool contains_label_p ( )
static
   Return whether the sub-tree ST contains a label which is accessible from
   outside the sub-tree.  
DEBUG_FUNCTION void debug_fold_checksum ( )
   Helper function for outputting the checksum of a tree T.  When
   debugging with gdb, you can "define mynext" to be "next" followed
   by "call debug_fold_checksum (op0)", then just trace down till the
   outputs differ.  
static tree decode_field_reference ( location_t  loc,
tree  exp,
HOST_WIDE_INT pbitsize,
HOST_WIDE_INT pbitpos,
enum machine_mode *  pmode,
int *  punsignedp,
int *  pvolatilep,
tree pmask,
tree pand_mask 
)
static
   Subroutine for fold_truth_andor_1: decode a field reference.

   If EXP is a comparison reference, we return the innermost reference.

   *PBITSIZE is set to the number of bits in the reference, *PBITPOS is
   set to the starting bit number.

   If the innermost field can be completely contained in a mode-sized
   unit, *PMODE is set to that mode.  Otherwise, it is set to VOIDmode.

   *PVOLATILEP is set to 1 if the any expression encountered is volatile;
   otherwise it is not changed.

   *PUNSIGNEDP is set to the signedness of the field.

   *PMASK is set to the mask used.  This is either contained in a
   BIT_AND_EXPR or derived from the width of the field.

   *PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.

   Return 0 if this is not a component reference or is one that we can't
   do anything with.  
     All the optimizations using this function assume integer fields.
     There are problems with FP fields since the type_for_size call
     below can fail for, e.g., XFmode.  
     We are interested in the bare arrangement of bits, so strip everything
     that doesn't affect the machine mode.  However, record the type of the
     outermost expression if it may matter below.  
     If the number of bits in the reference is the same as the bitsize of
     the outer type, then the outer type gives the signedness. Otherwise
     (in case of a small bitfield) the signedness is unchanged.  
     Compute the mask to access the bitfield.  
     Merge it with the mask we found in the BIT_AND_EXPR, if any.  

References tcc_comparison.

static tree distribute_bit_expr ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Given a bit-wise operation CODE applied to ARG0 and ARG1, see if both
   operands are another bit-wise operation with a common input.  If so,
   distribute the bit operations to save an operation and possibly two if
   constants are involved.  For example, convert
        (A | B) & (A | C) into A | (B & C)
   Further simplification will occur if B and C are constants.

   If this optimization cannot be done, 0 will be returned.  
static tree distribute_real_division ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Knowing that ARG0 and ARG1 are both RDIV_EXPRs, simplify a binary operation
   with code CODE.  This optimization is unsafe.  
     (A / C) +- (B / C) -> (A +- B) / C.  
     (A / C1) +- (A / C2) -> A * (1 / C1 +- 1 / C2).  

References const_binop(), constant_boolean_node(), fold_convert_loc(), integer_zerop(), and warning().

tree div_if_zero_remainder ( )
   If ARG2 divides ARG1 with zero remainder, carries out the division
   of type CODE and returns the quotient.
   Otherwise returns NULL_TREE.  
     The sign of the division is according to operand two, that
     does the correct thing for POINTER_PLUS_EXPR where we want
     a signed division.  
static tree eval_subst ( location_t  loc,
tree  arg,
tree  old0,
tree  new0,
tree  old1,
tree  new1 
)
static
   ARG is a tree that is known to contain just arithmetic operations and
   comparisons.  Evaluate the operations in the tree substituting NEW0 for
   any occurrence of OLD0 as an operand of a comparison and likewise for
   NEW1 and OLD1.  
     We can handle some of the tcc_expression cases here.  
         Fall through - ???  
           We need to check both for exact equality and tree equality.  The
           former will be true if the operand has a side-effect.  In that
           case, we know the operand occurred exactly once.  

Referenced by operand_equal_for_comparison_p().

static tree exact_inverse ( )
static
   If the real or vector real constant CST of type TYPE has an exact
   inverse, return it, else return NULL.  

References fold_convert_loc().

static location_t expr_location_or ( )
static
   Return EXPR_LOCATION of T if it is not UNKNOWN_LOCATION.
   Otherwise, return LOC.  
static tree extract_muldiv ( tree  t,
tree  c,
enum tree_code  code,
tree  wide_type,
bool *  strict_overflow_p 
)
static
   T is an integer expression that is being multiplied, divided, or taken a
   modulus (CODE says which and what kind of divide or modulus) by a
   constant C.  See if we can eliminate that operation by folding it with
   other operations already in T.  WIDE_TYPE, if non-null, is a type that
   should be used for the computation if wider than our type.

   For example, if we are dividing (X * 8) + (Y * 16) by 4, we can return
   (X * 2) + (Y * 4).  We must, however, be assured that either the original
   expression would not overflow or that overflow is undefined for the type
   in the language in question.

   If we return a non-null expression, it is an equivalent form of the
   original computation, but need not be in the original type.

   We set *STRICT_OVERFLOW_P to true if the return values depends on
   signed overflow being undefined.  Otherwise we do not change
   *STRICT_OVERFLOW_P.  
     To avoid exponential search depth, refuse to allow recursion past
     three levels.  Beyond that (1) it's highly unlikely that we'll find
     something interesting and (2) we've probably processed it before
     when we built the inner expression.  

References const_binop(), and integer_zerop().

static tree extract_muldiv_1 ( tree  t,
tree  c,
enum tree_code  code,
tree  wide_type,
bool *  strict_overflow_p 
)
static
     Don't deal with constants of zero here; they confuse the code below.  
     Note that we need not handle conditional operations here since fold
     already handles those cases.  So just do arithmetic here.  
         For a constant, we can always simplify if we are a multiply
         or (for divide and modulus) if it is a multiple of our constant.  
         If op0 is an expression ...  
             ... and has wrapping overflow, and its type is smaller
             than ctype, then we cannot pass through as widening.  
                 ... or this is a truncation (t is narrower than op0),
                 then we cannot pass through this narrowing.  
                 ... or signedness changes for division or modulus,
                 then we cannot pass through this conversion.  
                 ... or has undefined overflow while the converted to
                 type has not, we cannot do the operation in the inner type
                 as that would introduce undefined overflow.  
         Pass the constant down and see if we can make a simplification.  If
         we can, replace this expression with the inner simplification for
         possible later conversion to our or some other type.  
         If widening the type changes it from signed to unsigned, then we
         must avoid building ABS_EXPR itself as unsigned.  
         If the constant is negative, we cannot simplify this.  
         FALLTHROUGH 
         For division and modulus, type can't be unsigned, as e.g.
         (-(x / 2U)) / 2U isn't equal to -((x / 2U) / 2U) for x >= 2.
         For signed types, even with wrapping overflow, this is fine.  
         If widening the type changes the signedness, then we can't perform
         this optimization as that changes the result.  
         MIN (a, b) / 5 -> MIN (a / 5, b / 5)  
         If the second operand is constant, this is a multiplication
         or floor division, by a power of two, so we can treat it that
         way unless the multiplier or divisor overflows.  Signed
         left-shift overflow is implementation-defined rather than
         undefined in C90, so do not convert signed left shift into
         multiplication.  
             const_binop may not detect overflow correctly,
             so check for it explicitly here.  
         See if we can eliminate the operation on both sides.  If we can, we
         can return a new PLUS or MINUS.  If we can't, the only remaining
         cases where we can do anything are if the second operand is a
         constant.  
                 If not multiplication, we can only do this if both operands
                 are divisible by c.  
         If this was a subtraction, negate OP1 and set it to be an addition.
         This simplifies the logic below.  
             If OP1 was not easily negatable, the constant may be OP0.  
         If either OP1 or C are negative, this optimization is not safe for
         some of the division and remainder types while for others we need
         to change the code.  
         If it's a multiply or a division/modulus operation of a multiple
         of our constant, do the operation and verify it doesn't overflow.  
             We allow the constant to overflow with wrapping semantics.  
         If we have an unsigned type, we cannot widen the operation since it
         will change the result if the original computation overflowed.  
         If we were able to eliminate our operation from the first side,
         apply our operation to the second side and reform the PLUS.  
         The last case is if we are a multiply.  In that case, we can
         apply the distributive law to commute the multiply and addition
         if the multiplication of the constants doesn't overflow
         and overflow is defined.  With undefined overflow
         op0 * c might overflow, while (op0 + orig_op1) * c doesn't.  
         We have a special case here if we are doing something like
         (C * 8) % 4 since we know that's zero.  
             If the multiplication can overflow we cannot optimize this.  
         ... fall through ...  
         If we can extract our operation from the LHS, do so and return a
         new operation.  Likewise for the RHS from a MULT_EXPR.  Otherwise,
         do something only if the second operand is a constant.  
         If these are the same operation types, we can associate them
         assuming no overflow.  
         If these operations "cancel" each other, we have the main
         optimizations of this pass, which occur when either constant is a
         multiple of the other, in which case we replace this with either an
         operation or CODE or TCODE.

         If we have an unsigned type, we cannot do this since it will change
         the result if the original computation overflowed.  
tree fold ( )
static
   When --enable-checking=fold, compute a digest of expr before
   and after actual fold call to see if fold did not accidentally
   change original expr.  
     Return right away if a constant.  
     CALL_EXPR-like objects with variable numbers of operands are
     treated specially.  
               Find a matching index by means of a binary search.  
         Return a VECTOR_CST if possible.  
static tree fold_1 ( tree  )
static
tree fold_abs_const ( )
   Return the tree for abs (ARG0) when ARG0 is known to be either
   an integer constant or real constant.

   TYPE is the type of the result.  
           If the value is unsigned or non-negative, then the absolute value
           is the same as the ordinary value.  
           If the value is negative, then the absolute value is
           its negation.  
static tree fold_addr_of_array_ref_difference ( location_t  loc,
tree  type,
tree  aref0,
tree  aref1 
)
static
   Try to fold a pointer difference of type TYPE two address expressions of
   array references AREF0 and AREF1 using location LOC.  Return a
   simplified expression for the difference or NULL_TREE.  
     If the bases are array references as well, recurse.  If the bases
     are pointer indirections compute the difference of the pointers.
     If the bases are equal, we are set.  
tree fold_binary_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1 
)
   Fold a binary expression of code CODE and type TYPE with operands
   OP0 and OP1.  LOC is the location of the resulting expression.
   Return the folded expression if folding is successful.  Otherwise,
   return NULL_TREE.  
     Strip any conversions that don't change the mode.  This is
     safe for every expression, except for a comparison expression
     because its signedness is derived from its operands.  So, in
     the latter case, only strip conversions that don't change the
     signedness.  MIN_EXPR/MAX_EXPR also need signedness of arguments
     preserved.

     Note that this is done as an internal manipulation within the
     constant folder, in order to find the simplest representation
     of the arguments so that their form can be studied.  In any
     cases, the appropriate type conversions should be put back in
     the tree that will get out of the constant folder.  
     Note that TREE_CONSTANT isn't enough: static var addresses are
     constant but we can't do arithmetic on them.  
             Make sure type and arg0 have the same saturating flag.  
     If this is a commutative operation, and ARG0 is a constant, move it
     to ARG1 to reduce the number of tests below.  
     ARG0 is the first operand of EXPR, and ARG1 is the second operand.

     First check for cases where an arithmetic operation is applied to a
     compound, conditional, or comparison operation.  Push the arithmetic
     operation inside the compound or conditional to see if any folding
     can then be done.  Convert comparison to conditional for this purpose.
     The also optimizes non-constant cases that used to be done in
     expand_expr.

     Before we do that, see if this is a BIT_AND_EXPR or a BIT_IOR_EXPR,
     one of the operands is a comparison and the other is a comparison, a
     BIT_AND_EXPR with the constant 1, or a truth value.  In that case, the
     code below would make the expression more complex.  Change it to a
     TRUTH_{AND,OR}_EXPR.  Likewise, convert a similar NE_EXPR to
     TRUTH_XOR_EXPR and an EQ_EXPR to the inversion of a TRUTH_XOR_EXPR.  
         MEM[&MEM[p, CST1], CST2] -> MEM[p, CST1 + CST2].  
         MEM[&a.b, CST2] -> MEM[&a, offsetof (a, b) + CST2].  
         0 +p index -> (type)index 
         PTR +p 0 -> PTR 
         INT +p INT -> (PTR)(INT + INT).  Stripping types allows for this. 
         (PTR +p B) +p A -> PTR +p (B + A) 
         PTR_CST +p CST -> CST1 
        Try replacing &a[i1] +p c * i2 with &a[i1 + i2], if c is step
        of the array.  Loop optimizer sometimes produce this type of
        expressions.  
         A + (-B) -> A - B 
         (-A) + B -> B - A 
             Convert ~A + 1 to -A.  
             ~X + X is -1.  
             X + ~X is -1.  
             X + (X / CST) * -CST is X % CST.  
         Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the same or
         one.  Make sure the type is not saturating and has the signedness of
         the stripped operands, as fold_plusminus_mult_expr will re-associate.
         ??? The latter condition should use TYPE_OVERFLOW_* flags instead.  
             If we are adding two BIT_AND_EXPR's, both of which are and'ing
             with a constant, and the two constants have no bits in common,
             we should treat this as a BIT_IOR_EXPR since this may produce more
             simplifications.  
             Reassociate (plus (plus (mult) (foo)) (mult)) as
             (plus (plus (mult) (mult)) (foo)) so that we can
             take advantage of the factoring cases below.  
             See if ARG1 is zero and X + ARG1 reduces to X.  
             Likewise if the operands are reversed.  
             Convert X + -C into X - C.  
             Fold __complex__ ( x, 0 ) + __complex__ ( 0, y )
             to __complex__ ( x, y ).  This is not the same for SNaNs or
             if signed zeros are involved.  
             Convert x+x into x*2.0.  
             Convert a + (b*c + d*e) into (a + b*c) + d*e.
             We associate floats only if the user has specified
             -fassociative-math.  
             Convert (b*c + d*e) + a into b*c + (d*e +a).
             We associate floats only if the user has specified
             -fassociative-math.  
         (A << C1) + (A >> C2) if A is unsigned and C1+C2 is the size of A
         is a rotate of A by C1 bits.  
         (A << B) + (A >> (Z - B)) if A is unsigned and Z is the size of A
         is a rotate of A by B bits.  
               Only create rotates in complete modes.  Other cases are not
               expanded properly.  
         In most languages, can't associate operations on floats through
         parentheses.  Rather than remember where the parentheses were, we
         don't associate floats at all, unless the user has specified
         -fassociative-math.
         And, we need to make sure type is not saturating.  
             Split both trees into variables, constants, and literals.  Then
             associate each group together, the constants with literals,
             then the result with variables.  This increases the chances of
             literals being recombined later and of generating relocatable
             expressions for the sum of a constant and literal.  
             Recombine MINUS_EXPR operands by using PLUS_EXPR.  
             With undefined overflow prefer doing association in a type
             which wraps on overflow, if that is one of the operand types.  
             With undefined overflow we can only associate constants with one
             variable, and constants whose association doesn't overflow.  
                     The only case we can still associate with two variables
                     is if they are the same, modulo negation and bit-pattern
                     preserving conversions.  
             Only do something if we found more than two objects.  Otherwise,
             nothing has changed and we risk infinite recursion.  
                 Preserve the MINUS_EXPR if the negative part of the literal is
                 greater than the positive part.  Otherwise, the multiplicative
                 folding code (i.e extract_muldiv) may be fooled in case
                 unsigned constants are subtracted, like in the following
                 example: ((X*2 + 4) - 8U)/2.  
                 Don't introduce overflows through reassociation.  
         Pointer simplifications for subtraction, simple reassociations. 
             (PTR0 p+ A) - (PTR1 p+ B) -> (PTR0 - PTR1) + (A - B) 
             (PTR0 p+ A) - PTR1 -> (PTR0 - PTR1) + A, assuming PTR0 - PTR1 simplifies. 
         A - (-B) -> A + B 
         (-A) - B -> (-B) - A  where B is easily negated and we can swap.  
         Convert -A - 1 to ~A.  
         Convert -1 - A to ~A.  
         X - (X / Y) * Y is X % Y.  
             Fold A - (A & B) into ~B & A.  
             Fold (A & ~B) - (A & B) into (A ^ B) - B, where B is
             any power of 2 minus 1.  
         See if ARG1 is zero and X - ARG1 reduces to X.  
         (ARG0 - ARG1) is the same as (-ARG1 + ARG0).  So check whether
         ARG0 is zero and X + ARG0 reduces to X, since that would mean
         (-ARG1 + ARG0) reduces to -ARG1.  
         Fold __complex__ ( x, 0 ) - __complex__ ( 0, y ) to
         __complex__ ( x, -y ).  This is not the same for SNaNs or if
         signed zeros are involved.  
         Fold &x - &x.  This can happen from &x.foo - &x.
         This is unsafe for certain floats even in non-IEEE formats.
         In IEEE, it is unsafe because it does wrong for NaNs.
         Also note that operand_equal_p is always false if an operand
         is volatile.  
         A - B -> A + (-B) if B is easily negatable.  
                  Avoid this transformation if B is a positive REAL_CST.  
         Try folding difference of addresses.  
         Fold &a[i] - &a[j] to i-j.  
         Handle (A1 * C1) - (A2 * C2) with A1, A2 or C1, C2 being the same or
         one.  Make sure the type is not saturating and has the signedness of
         the stripped operands, as fold_plusminus_mult_expr will re-associate.
         ??? The latter condition should use TYPE_OVERFLOW_* flags instead.  
         (-A) * (-B) -> A * B  
             Transform x * -1 into -x.  Make sure to do the negation
             on the original operand with conversions not stripped
             because we can only strip non-sign-changing conversions.  
             Transform x * -C into -x * C if x is easily negatable.  
             (a * (1 << b)) is (a << b)  
             (A + A) * C -> A * 2 * C  
             ((T) (X /[ex] C)) * C cancels out if the conversion is
             sign-changing only.  
             Optimize z * conj(z) for integer complex numbers.  
             Maybe fold x * 0 to 0.  The expressions aren't the same
             when x is NaN, since x * 0 is also NaN.  Nor are they the
             same in modes with signed zeros, since multiplying a
             negative value by 0 gives -0, not +0.  
             In IEEE floating point, x*1 is not equivalent to x for snans.
             Likewise for complex arithmetic with signed zeros.  
             Transform x * -1.0 into -x.  
             Convert (C1/X)*C2 into (C1*C2)/X.  This transformation may change
             the result for floating point types due to rounding so it is applied
             only if -fassociative-math was specify.  
             Strip sign operations from X in X*X, i.e. -Y*-Y -> Y*Y.  
             Fold z * +-I to __complex__ (-+__imag z, +-__real z).
             This is not the same for NaNs or if signed zeros are
             involved.  
             Optimize z * conj(z) for floating point complex numbers.
             Guarded by flag_unsafe_math_optimizations as non-finite
             imaginary components don't produce scalar results.  
                 Optimizations of root(...)*root(...).  
                     Optimize sqrt(x)*sqrt(x) as x.  
                     Optimize root(x)*root(y) as root(x*y).  
                 Optimize expN(x)*expN(y) as expN(x+y).  
                 Optimizations of pow(...)*pow(...).  
                     Optimize pow(x,y)*pow(z,y) as pow(x*z,y).  
                     Optimize pow(x,y)*pow(x,z) as pow(x,y+z).  
                 Optimize tan(x)*cos(x) as sin(x).  
                 Optimize x*pow(x,c) as pow(x,c+1).  
                 Optimize pow(x,c)*x as pow(x,c+1).  
                 Canonicalize x*x as pow(x,2.0), which is expanded as x*x.  
         ~X | X is -1.  
         X | ~X is -1.  
         Canonicalize (X & C1) | C2.  
             If (C1&C2) == C1, then (X&C1)|C2 becomes (X,C2).  
             If (C1|C2) == ~0 then (X&C1)|C2 becomes X|C2.  
             Minimize the number of bits set in C1, i.e. C1 := C1 & ~C2,
             unless (C1 & ~C2) | (C2 & C3) for some C3 is a mask of some
             mode which allows further optimizations.  
             If X is a tree of the form (Y * K1) & K2, this might conflict
             with that optimization from the BIT_AND_EXPR optimizations.
             This could end up in an infinite recursion.  
         (X & Y) | Y is (X, Y).  
         (X & Y) | X is (Y, X).  
         X | (X & Y) is (Y, X).  
         X | (Y & X) is (Y, X).  
         (X & ~Y) | (~X & Y) is X ^ Y 
         Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))).

         This results in more efficient code for machines without a NAND
         instruction.  Combine will canonicalize to the first form
         which will allow use of NAND instructions provided by the
         backend if they exist.  
         See if this can be simplified into a rotate first.  If that
         is unsuccessful continue in the association code.  
         ~X ^ X is -1.  
         X ^ ~X is -1.  
         If we are XORing two BIT_AND_EXPR's, both of which are and'ing
         with a constant, and the two constants have no bits in common,
         we should treat this as a BIT_IOR_EXPR since this may produce more
         simplifications.  
         (X | Y) ^ X -> Y & ~ X
         (Y | X) ^ X -> Y & ~ X
         X ^ (X | Y) -> Y & ~ X
         X ^ (Y | X) -> Y & ~ X
         Convert ~X ^ ~Y to X ^ Y.  
         Convert ~X ^ C to X ^ ~C.  
         Fold (X & 1) ^ 1 as (X & 1) == 0.  
         Fold (X & Y) ^ Y as ~X & Y.  
         Fold (X & Y) ^ X as ~Y & X.  
         Fold X ^ (X & Y) as X & ~Y.  
         Fold X ^ (Y & X) as ~Y & X.  
         See if this can be simplified into a rotate first.  If that
         is unsuccessful continue in the association code.  
         ~X & X, (X == 0) & X, and !X & X are always zero.  
         X & ~X , X & (X == 0), and X & !X are always zero.  
         Canonicalize (X | C1) & C2 as (X & C2) | (C1 & C2).  
         (X | Y) & Y is (X, Y).  
         (X | Y) & X is (Y, X).  
         X & (X | Y) is (Y, X).  
         X & (Y | X) is (Y, X).  
         Fold (X ^ 1) & 1 as (X & 1) == 0.  
         Fold ~X & 1 as (X & 1) == 0.  
         Fold !X & 1 as X == 0.  
         Fold (X ^ Y) & Y as ~X & Y.  
         Fold (X ^ Y) & X as ~Y & X.  
         Fold X & (X ^ Y) as X & ~Y.  
         Fold X & (Y ^ X) as ~Y & X.  
         Fold (X * Y) & -(1 << CST) to X * Y if Y is a constant
         multiple of 1 << CST.  
         Fold (X * CST1) & CST2 to zero if we can, or drop known zero
         bits from CST2.  
         For constants M and N, if M == (1LL << cst) - 1 && (N & M) == M,
         ((A & N) + B) & M -> (A + B) & M
         Similarly if (N & M) == 0,
         ((A | N) + B) & M -> (A + B) & M
         and for - instead of + (or unary - instead of +)
         and/or ^ instead of |.
         If B is constant and (B & M) == 0, fold into A & M.  
                 Now we know that arg0 is (C + D) or (C - D) or
                 -C and arg1 (M) is == (1LL << cst) - 1.
                 Store C into PMOP[0] and D into PMOP[1].  
                       tree_low_cst not used, because we don't care about
                       the upper bits.  
                       If C or D is of the form (A & N) where
                       (N & M) == M, or of the form (A | N) or
                       (A ^ N) where (N & M) == 0, replace it with A.  
                       If C or D is a N where (N & M) == 0, it can be
                       omitted (assumed 0).  
                 Only build anything new if we optimized one or both arguments
                 above.  
                         Perform the operations in a type that has defined
                         overflow behavior.  
                     TEM is now the new binary +, - or unary - replacement.  
         Simplify ((int)c & 0377) into (int)c, if c is unsigned char.  
         Convert (and (not arg0) (not arg1)) to (not (or (arg0) (arg1))).

         This results in more efficient code for machines without a NOR
         instruction.  Combine will canonicalize to the first form
         which will allow use of NOR instructions provided by the
         backend if they exist.  
         If arg0 is derived from the address of an object or function, we may
         be able to fold this expression using the object or function's
         alignment.  
             This works because modulus is a power of 2.  If this weren't the
             case, we'd have to replace it by its greatest power-of-2
             divisor: modulus & -modulus.  
         Fold (X << C1) & C2 into (X << C1) & (C2 | ((1 << C1) - 1))
              (X >> C1) & C2 into (X >> C1) & (C2 | ~((type) -1 >> C1))
         if the new mask might be further optimized.  
                 See if more bits can be proven as zero because of
                 zero extension.  
                         See if we can shorten the right shift.  
                 For arithmetic shift if sign bit could be set, zerobits
                 can contain actually sign bits, so no transformation is
                 possible, unless MASK masks them all away.  In that
                 case the shift needs to be converted into logical shift.  
             ((X << 16) & 0xff00) is (X, 0).  
                 Only do the transformation if NEWMASK is some integer
                 mode's mask.  
         Don't touch a floating-point divide by zero unless the mode
         of the constant can represent infinity.  
         Optimize A / A to 1.0 if we don't care about
         NaNs or Infinities.  Skip the transformation
         for non-real operands.  
         The complex version of the above A / A optimization.  
                 omit_two_operands will call fold_convert for us.  
         (-A) / (-B) -> A / B  
         In IEEE floating point, x/1 is not equivalent to x for snans.  
         In IEEE floating point, x/-1 is not equivalent to -x for snans.  
         If ARG1 is a constant, we can convert this to a multiply by the
         reciprocal.  This does not have the same rounding properties,
         so only do this if -freciprocal-math.  We can actually
         always safely do it if ARG1 is a power of two, but it's hard to
         tell if it is or not in a portable manner.  
             Find the reciprocal if optimizing and the result is exact.
             TODO: Complex reciprocal not implemented.  
         Convert A/B/C to A/(B*C).  
         Convert A/(B/C) to (A/B)*C.  
         Convert C1/(X*C2) into (C1/C2)/X.  
             Optimize sin(x)/cos(x) as tan(x).  
             Optimize cos(x)/sin(x) as 1.0/tan(x).  
             Optimize sin(x)/tan(x) as cos(x) if we don't care about
             NaNs or Infinities.  
             Optimize tan(x)/sin(x) as 1.0/cos(x) if we don't care about
             NaNs or Infinities.  
             Optimize pow(x,c)/x as pow(x,c-1).  
             Optimize a/root(b/c) into a*root(c/b).  
             Optimize x/expN(y) into x*expN(-y).  
             Optimize x/pow(y,z) into x*pow(y,-z).  
         Optimize (X & (-A)) / A where A is a power of 2,
         to X >> log2(A) 
         Fall through 
         Simplify A / (B << N) where A and B are positive and B is
         a power of 2, to A >> (N + log2(B)).  
         For unsigned integral types, FLOOR_DIV_EXPR is the same as
         TRUNC_DIV_EXPR.  Rewrite into the latter in this case.  
         Fall through 
         X / -1 is -X.  
         Convert -A / -B to A / B when the type is signed and overflow is
         undefined.  
         If arg0 is a multiple of arg1, then rewrite to the fastest div
         operation, EXACT_DIV_EXPR.

         Note that only CEIL_DIV_EXPR and FLOOR_DIV_EXPR are rewritten now.
         At one time others generated faster code, it's not clear if they do
         after the last round to changes to the DIV code in expmed.c.  
         X % 1 is always zero, but be sure to preserve any side
         effects in X.  
         X % 0, return X % 0 unchanged so that we can get the
         proper warnings and errors.  
         0 % X is always zero, but be sure to preserve any side
         effects in X.  Place this after checking for X == 0.  
         X % -1 is zero.  
         X % -C is the same as X % C.  
             Avoid this transformation if C is INT_MIN, i.e. C == -C.  
         X % -Y is the same as X % Y.  
         Optimize TRUNC_MOD_EXPR by a power of two into a BIT_AND_EXPR,
         i.e. "X % C" into "X & (C - 1)", if X and C are positive.  
             Also optimize A % (C << N)  where C is a power of 2,
             to A & ((C << N) - 1).  
         Optimize -1 >> x for arithmetic right shifts.  
         ... fall through ...  
         Prefer vector1 << scalar to vector1 << vector2
         if vector2 is uniform.  
         Since negative shift count is not well-defined,
         don't try to compute it in the compiler.  
         Turn (a OP c1) OP c2 into a OP (c1+c2).  
             Deal with a OP (c1 + c2) being undefined but (a OP c1) OP c2
             being well defined.  
         Transform (x >> c) << c into x & (-1<<c), or transform (x << c) >> c
         into x & ((unsigned)-1 >> c) for unsigned types.  
         Rewrite an LROTATE_EXPR by a constant into an
         RROTATE_EXPR by a new constant.  
         If we have a rotate of a bit operation with the rotate count and
         the second operand of the bit operation both constant,
         permute the two operations.  
         Two consecutive rotates adding up to the precision of the
         type can be ignored.  
         Fold (X & C2) << C1 into (X << C1) & (C2 << C1)
              (X & C2) >> C1 into (X >> C1) & (C2 >> C1)
         if the latter can be further optimized.  
         Note that the operands of this must be ints
         and their values must be 0 or 1.
         ("true" is a fixed value perhaps depending on the language.)  
         If first arg is constant zero, return it.  
         If either arg is constant true, drop it.  
             Preserve sequence points.  
         If second arg is constant zero, result is zero, but first arg
         must be evaluated.  
         Likewise for first arg, but note that only the TRUTH_AND_EXPR
         case will be handled here.  
         !X && X is always false.  
         X && !X is always false.  
         A < X && A + 1 > Y ==> A < X && A >= Y.  Normally A + 1 > Y
         means A >= Y && A != MAX, but in this case we know that
         A < X <= MAX.  
         Note that the operands of this must be ints
         and their values must be 0 or true.
         ("true" is a fixed value perhaps depending on the language.)  
         If first arg is constant true, return it.  
         If either arg is constant zero, drop it.  
             Preserve sequence points.  
         If second arg is constant true, result is true, but we must
         evaluate first arg.  
         Likewise for first arg, but note this only occurs here for
         TRUTH_OR_EXPR.  
         !X || X is always true.  
         X || !X is always true.  
         (X && !Y) || (!X && Y) is X ^ Y 
         If the second arg is constant zero, drop it.  
         If the second arg is constant true, this is a logical inversion.  
         Identical arguments cancel to zero.  
         !X ^ X is always true.  
         X ^ !X is always true.  
         bool_var != 0 becomes bool_var. 
         bool_var == 1 becomes bool_var. 
         bool_var != 1 becomes !bool_var. 
         bool_var == 0 becomes !bool_var. 
         !exp != 0 becomes !exp 
         If this is an equality comparison of the address of two non-weak,
         unaliased symbols neither of which are extern (since we do not
         have access to attributes for externs), then we know the result.  
             We know that we're looking at the address of two
             non-weak, unaliased, static _DECL nodes.

             It is both wasteful and incorrect to call operand_equal_p
             to compare the two ADDR_EXPR nodes.  It is wasteful in that
             all we need to do is test pointer equality for the arguments
             to the two ADDR_EXPR nodes.  It is incorrect to use
             operand_equal_p as that function is NOT equivalent to a
             C equality test.  It can in fact return false for two
             objects which would test as equal using the C equality
             operator.  
         If this is an EQ or NE comparison of a constant with a PLUS_EXPR or
         a MINUS_EXPR of a constant, we can convert it into a comparison with
         a revised constant as long as no overflow occurs.  
         Similarly for a NEGATE_EXPR.  
         Similarly for a BIT_XOR_EXPR;  X ^ C1 == C2 is X == (C1 ^ C2).  
         Transform comparisons of the form X +- Y CMP X to Y CMP 0.  
         Transform comparisons of the form C - X CMP X if C % 2 == 1.  
         If we have X - Y == 0, we can convert that to X == Y and similarly
         for !=.  Don't do this for ordered comparisons due to overflow.  
         Convert ABS_EXPR<x> == 0 or ABS_EXPR<x> != 0 to x == 0 or x != 0.  
         If this is an EQ or NE comparison with zero and ARG0 is
         (1 << foo) & bar, convert it to (bar >> foo) & 1.  Both require
         two operations, but the latter can be done in one less insn
         on machines that have only two-operand insns or on which a
         constant cannot be the first operand.  
         If this is an NE or EQ comparison of zero against the result of a
         signed MOD operation whose second operand is a power of 2, make
         the MOD operation unsigned since it is simpler and equivalent.  
         Fold ((X >> C1) & C2) == 0 and ((X >> C1) & C2) != 0 where
         C1 is a valid shift constant, and C2 is a power of two, i.e.
         a single bit.  
             Check for a valid shift count.  
                 If (C2 << C1) doesn't overflow, then ((X >> C1) & C2) != 0
                 can be rewritten as (X & (C2 << C1)) != 0.  
                 Otherwise, for signed (arithmetic) shifts,
                 ((X >> C1) & C2) != 0 is rewritten as X < 0, and
                 ((X >> C1) & C2) == 0 is rewritten as X >= 0.  
                 Otherwise, of unsigned (logical) shifts,
                 ((X >> C1) & C2) != 0 is rewritten as (X,false), and
                 ((X >> C1) & C2) == 0 is rewritten as (X,true).  
         If we have (A & C) == C where C is a power of 2, convert this into
         (A & C) != 0.  Similarly for NE_EXPR.  
         If we have (A & C) != 0 or (A & C) == 0 and C is the sign
         bit, then fold the expression into A < 0 or A >= 0.  
         If we have (A & C) == D where D & ~C != 0, convert this into 0.
         Similarly for NE_EXPR.  
         If we have (A | C) == D where C & ~D != 0, convert this into 0.
         Similarly for NE_EXPR.  
         If this is a comparison of a field, we may be able to simplify it.  
             Handle the constant case even without -O
             to make sure the warnings are given.  
         Optimize comparisons of strlen vs zero to a compare of the
         first character of the string vs zero.  To wit,
                strlen(ptr) == 0   =>  *ptr == 0
                strlen(ptr) != 0   =>  *ptr != 0
         Other cases should reduce to one of these two (or a constant)
         due to the return value of strlen being unsigned.  
         Fold (X >> C) != 0 into X < 0 if C is one less than the width
         of X.  Similarly fold (X >> C) == 0 into X >= 0.  
         (X ^ Y) == 0 becomes X == Y, and (X ^ Y) != 0 becomes X != Y.  
         (X ^ Y) == Y becomes X == 0.  We know that Y has no side-effects.  
         Likewise (X ^ Y) == X becomes Y == 0.  X has no side-effects.  
         (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2).  
         Fold (~X & C) == 0 into (X & C) != 0 and (~X & C) != 0 into
         (X & C) == 0 when C is a single bit.  
         Fold ((X & C) ^ C) eq/ne 0 into (X & C) ne/eq 0, when the
         constant C is a power of two, i.e. a single bit.  
         Likewise, fold ((X ^ C) & C) eq/ne 0 into (X & C) ne/eq 0,
         when is C is a power of two, i.e. a single bit.  
         Fold -X op -Y as X op Y, where op is eq/ne.  
         Fold (X & C) op (Y & C) as (X ^ Y) & C op 0", and symmetries.  
             Optimize (X ^ Z) op (Y ^ Z) as X op Y, and symmetries.
             operand_equal_p guarantees no side-effects so we don't need
             to use omit_one_operand on Z.  
             Optimize (X ^ C1) op (Y ^ C2) as (X ^ (C1 ^ C2)) op Y.  
         Attempt to simplify equality/inequality comparisons of complex
         values.  Only lower the comparison if the result is known or
         can be simplified to a single scalar comparison.  
         Transform comparisons of the form X +- C CMP X.  
             (X - c) > X becomes false.  
             Likewise (X + c) < X becomes false.  
             Convert (X - c) <= X to true.  
             Convert (X + c) >= X to true.  
                 Convert X + c > X and X - c < X to true for integers.  
                 Convert X + c <= X and X - c >= X to false for integers.  
         Comparisons with the highest or lowest possible integer of
         the specified precision will have known values.  
                   The GE_EXPR and LT_EXPR cases above are not normally
                   reached because of previous transformations.  
                        We will flip the signedness of the comparison operator
                        associated with the mode of arg1, so the sign bit is
                        specified by this mode.  Check that arg1 is the signed
                        max associated with this sign bit.  
                        signed_type does not work on pointer types.  
                   The following case also applies to X < signed_max+1
                   and X >= signed_max+1 because previous transformations.  
         If we are comparing an ABS_EXPR with a constant, we can
         convert all the cases into explicit comparisons, but they may
         well not be faster than doing the ABS and one comparison.
         But ABS (X) <= C is a range comparison, which becomes a subtraction
         and a comparison, and is probably faster.  
         Convert ABS_EXPR<x> >= 0 to true.  
         Convert ABS_EXPR<x> < 0 to false.  
         If X is unsigned, convert X < (1 << Y) into X >> Y == 0
         and similarly for >= into !=.  
         Similarly for X < (cast) (1 << Y).  But cast can't be narrowing,
         otherwise Y might be >= # of bits in X's type and thus e.g.
         (unsigned char) (1 << Y) for Y 15 might be 0.
         If the cast is widening, then 1 << Y should have unsigned type,
         otherwise if Y is number of bits in the signed shift type minus 1,
         we can't optimize this.  E.g. (unsigned long long) (1 << Y) for Y
         31 might be 0xffffffff80000000.  
         If the first operand is NaN, the result is constant.  
         If the second operand is NaN, the result is constant.  
         Simplify unordered comparison of something with itself.  
         Fold (double)float1 CMP (double)float2 into float1 CMP float2.  
         When pedantic, a compound expression can be neither an lvalue
         nor an integer constant expression.  
         Don't let (0, 0) be null pointer constant.  
         An ASSERT_EXPR should never be passed to fold_binary.  

Referenced by create_bb(), fold_mult_zconjz(), optimize_stmt(), and rhs_to_tree().

static tree fold_binary_op_with_conditional_arg ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
tree  cond,
tree  arg,
int  cond_first_p 
)
static
   Transform `a + (b ? x : y)' into `b ? (a + x) : (a + y)'.
   Transform, `a + (x < y)' into `(x < y) ? (a + 1) : (a + 0)'.  Here
   CODE corresponds to the `+', COND to the `(b ? x : y)' or `(x < y)'
   expression, and ARG to `a'.  If COND_FIRST_P is nonzero, then the
   COND is the first argument to CODE; otherwise (as in the example
   given here), it is the second argument.  TYPE is the type of the
   original expression.  Return NULL_TREE if no simplification is
   possible.  
         If this operand throws an expression, then it does not make
         sense to try to perform a logical or arithmetic operation
         involving it.  
     This transformation is only worthwhile if we don't have to wrap ARG
     in a SAVE_EXPR and the operation can be simplified without recursing
     on at least one of the branches once its pushed inside the COND_EXPR.  
     Check that we have simplified at least one of the branches.  
tree fold_binary_to_constant ( )
   Given the components of a binary expression CODE, TYPE, OP0 and OP1,
   attempt to fold the expression to a constant without modifying TYPE,
   OP0 or OP1.

   If the expression could be simplified to a constant, then return
   the constant.  If the expression would not be simplified to a
   constant, then return NULL_TREE.  

Referenced by maybe_fold_tmr(), and number_of_iterations_cond().

tree fold_build1_initializer_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op 
)
tree fold_build1_stat_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree op0  MEM_STAT_DECL 
)
   Fold a unary tree expression with code CODE of type TYPE with an
   operand OP0.  LOC is the location of the resulting expression.
   Return a folded expression if successful.  Otherwise, return a tree
   expression with code CODE of type TYPE with an operand OP0.  
tree fold_build2_initializer_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1 
)
tree fold_build2_stat_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree op1  MEM_STAT_DECL 
)
   Fold a binary tree expression with code CODE of type TYPE with
   operands OP0 and OP1.  LOC is the location of the resulting
   expression.  Return a folded expression if successful.  Otherwise,
   return a tree expression with code CODE of type TYPE with operands
   OP0 and OP1.  

References tree_expr_nonzero_warnv_p(), and type().

tree fold_build3_initializer_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
tree  op2 
)
tree fold_build3_stat_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
tree op2  MEM_STAT_DECL 
)
   Fold a ternary tree expression with code CODE of type TYPE with
   operands OP0, OP1, and OP2.  Return a folded expression if
   successful.  Otherwise, return a tree expression with code CODE of
   type TYPE with operands OP0, OP1, and OP2.  
tree fold_build_call_array_initializer_loc ( location_t  loc,
tree  type,
tree  fn,
int  nargs,
tree argarray 
)
tree fold_build_call_array_loc ( location_t  loc,
tree  type,
tree  fn,
int  nargs,
tree argarray 
)
   Fold a CALL_EXPR expression of type TYPE with operands FN and NARGS
   arguments in ARGARRAY, and a null static chain.
   Return a folded expression if successful.  Otherwise, return a CALL_EXPR
   of type TYPE from the given operands as constructed by build_call_array.  
tree fold_build_cleanup_point_expr ( )
   If necessary, return a CLEANUP_POINT_EXPR for EXPR with the
   indicated TYPE.  If no CLEANUP_POINT_EXPR is necessary, return EXPR
   itself.  
     If the expression does not have side effects then we don't have to wrap
     it with a cleanup point expression.  
     If the expression is a return, check to see if the expression inside the
     return has no side effects or the right hand side of the modify expression
     inside the return. If either don't have side effects set we don't need to
     wrap the expression in a cleanup point expression.  Note we don't check the
     left hand side of the modify because it should always be a return decl.  
static void fold_check_failed ( const_tree  ,
const_tree   
)
static
static void fold_check_failed ( )
static
static void fold_checksum_tree ( const_tree  expr,
struct md5_ctx *  ctx,
hash_table< pointer_hash< tree_node > >  ht 
)
static
         Allow DECL_ASSEMBLER_NAME to be modified.  
         Allow these fields to be modified.  
static tree fold_comparison ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1 
)
static
   Subroutine of fold_binary.  This routine performs all of the
   transformations that are common to the equality/inequality
   operators (EQ_EXPR and NE_EXPR) and the ordering operators
   (LT_EXPR, LE_EXPR, GE_EXPR and GT_EXPR).  Callers other than
   fold_binary should call fold_binary.  Fold a comparison with
   tree code CODE and type TYPE with operands OP0 and OP1.  Return
   the folded comparison or NULL_TREE.  
     If one arg is a real or integer constant, put it last.  
     Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 +- C1.  
         If the constant operation overflowed this can be
         simplified as a comparison against INT_MAX/INT_MIN.  
             Get the sign of the constant on the lhs if the
             operation were VARIABLE + CONST1.  
             The sign of the constant determines if we overflowed
             INT_MAX (const1_sgn == -1) or INT_MIN (const1_sgn == 1).
             Canonicalize to the INT_MIN overflow by swapping the comparison
             if necessary.  
             We now can look at the canonicalized case
               VARIABLE + 1  CODE2  INT_MIN
             and decide on the result.  
     For comparisons of pointers we can decompose it to a compile time
     comparison of the base objects and the offsets into the object.
     This requires at least one operand being an ADDR_EXPR or a
     POINTER_PLUS_EXPR to do more than the operand_equal_p test below.  
         Get base and offset for the access.  Strip ADDR_EXPR for
         get_inner_reference, but put it back by stripping INDIRECT_REF
         off the base object if possible.  indirect_baseN will be true
         if baseN is not an address but refers to the object itself.  
         A local variable can never be pointed to by
         the default SSA name of an incoming parameter.  
         If we have equivalent bases we might be able to simplify.  
             We can fold this expression to a constant if the non-constant
             offset parts are equal.  
             We can simplify the comparison to a comparison of the variable
             offset parts if the constant offset parts are equal.
             Be careful to use signed sizetype here because otherwise we
             mess with array offsets in the wrong way.  This is possible
             because pointer arithmetic is restricted to retain within an
             object and overflow on pointer differences is undefined as of
             6.5.6/8 and /9 with respect to the signed ptrdiff_t.  
                 By converting to signed sizetype we cover middle-end pointer
                 arithmetic which operates on unsigned pointer types of size
                 type size and ARRAY_REF offsets which are properly sign or
                 zero extended from their type in case it is narrower than
                 sizetype.  
         For non-equal bases we can simplify if they are addresses
         of local binding decls or constants.  
                  We know that !operand_equal_p (base0, base1, 0)
                  because the if condition was false.  But make
                  sure two decls are not the same.  
         For equal offsets we can simplify to a comparison of the
         base addresses.  
     Transform comparisons of the form X +- C1 CMP Y +- C2 to
     X CMP Y +- C2 +- C1 for signed X, Y.  This is valid if
     the resulting offset is smaller in absolute value than the
     original one.  
         Put the constant on the side where it doesn't overflow and is
         of lower absolute value than before.  
     Transform comparisons of the form X * C1 CMP 0 to X CMP 0 in the
     signed arithmetic case.  That form is created by the compiler
     often enough for folding it to be of value.  One example is in
     computing loop trip counts after Operator Strength Reduction.  
         Handle unfolded multiplication by zero.  
         If const1 is negative we swap the sense of the comparison.  
         Fold (double)float1 CMP (double)float2 into float1 CMP float2.  
         (-a) CMP (-b) -> b CMP a  
             (-a) CMP CST -> a swap(CMP) (-CST)  
             IEEE doesn't distinguish +0 and -0 in comparisons.  
             a CMP (-0) -> a CMP 0  
             x != NaN is always true, other ops are always false.  
             Fold comparisons against infinity.  
         If this is a comparison of a real constant with a PLUS_EXPR
         or a MINUS_EXPR of a real constant, we can convert it into a
         comparison with a revised real constant as long as no overflow
         occurs when unsafe_math_optimizations are enabled.  
         Likewise, we can simplify a comparison of a real constant with
         a MINUS_EXPR whose first operand is also a real constant, i.e.
         (c1 - x) < c2 becomes x > c1-c2.  Reordering is allowed on
         floating-point types only if -fassociative-math is set.  
         Fold comparisons against built-in math functions.  
         If we are widening one operand of an integer comparison,
         see if the other operand is similarly being widened.  Perhaps we
         can do the comparison in the narrower type.  
         Or if we are changing signedness.  
     If this is comparing a constant with a MIN_EXPR or a MAX_EXPR of a
     constant, we can simplify it.  
     Simplify comparison of something with itself.  (For IEEE
     floating-point, we can only do some of these simplifications.)  
             For NE, we can only do this simplification if integer
             or we don't honor IEEE floating point NaNs.  
             ... fall through ...  
     If we are comparing an expression that just has comparisons
     of two integer values, arithmetic expressions of those comparisons,
     and constants, we can simplify it.  There are only three cases
     to check: the two values can either be equal, the first can be
     greater, or the second can be greater.  Fold the expression for
     those three values.  Since each value must be 0 or 1, we have
     eight possibilities, each of which corresponds to the constant 0
     or 1 or one of the six possible comparisons.

     This handles common cases like (a > b) == 0 but also handles
     expressions like  ((x > y) - (y > x)) > 0, which supposedly
     occur in macroized code.  
             Don't handle degenerate cases here; they should already
             have been handled anyway.  
             We can't just pass T to eval_subst in case cval1 or cval2
             was the same as ARG1.  
             All three of these results should be 0 or 1.  Confirm they are.
             Then use those values to select the proper code to use.  
                 Make a 3-bit mask with the high-order bit being the
                 value for `>', the next for '=', and the low for '<'.  
                     Always false.  
                     Always true.  
     We can fold X/C1 op C2 where C1 and C2 are integer constants
     into a single range test.  
     Fold ~X op ~Y as Y op X.  
     Fold ~X op C as X op' ~C, where op' is the swapped comparison.  

References constant_boolean_node().

static tree fold_cond_expr_with_comparison ( location_t  loc,
tree  type,
tree  arg0,
tree  arg1,
tree  arg2 
)
static
   Subroutine of fold, looking inside expressions of the form
   A op B ? A : C, where ARG0, ARG1 and ARG2 are the three operands
   of the COND_EXPR.  This function is being used also to optimize
   A op B ? C : A, by reversing the comparison first.

   Return a folded expression whose code is not a COND_EXPR
   anymore, or NULL_TREE if no folding opportunity is found.  
     If we have A op 0 ? A : -A, consider applying the following
     transformations:

     A == 0? A : -A    same as -A
     A != 0? A : -A    same as A
     A >= 0? A : -A    same as abs (A)
     A > 0?  A : -A    same as abs (A)
     A <= 0? A : -A    same as -abs (A)
     A < 0?  A : -A    same as -abs (A)

     None of these transformations work for modes with signed
     zeros.  If A is +/-0, the first two transformations will
     change the sign of the result (from +0 to -0, or vice
     versa).  The last four will fix the sign of the result,
     even though the original expressions could be positive or
     negative, depending on the sign of A.

     Note that all these transformations are correct if A is
     NaN, since the two alternatives (A and -A) are also NaNs.  
                In the case that A is of the form X-Y, '-A' (arg2) may
                have already been folded to Y-X, check for that. 
           Fall through.  
     A != 0 ? A : 0 is simply A, unless A is -0.  Likewise
     A == 0 ? A : 0 is always 0 unless A is -0.  Note that
     both transformations are correct when A is NaN: A != 0
     is then true, and A == 0 is false.  
     Try some transformations of A op B ? A : B.

     A == B? A : B    same as B
     A != B? A : B    same as A
     A >= B? A : B    same as max (A, B)
     A > B?  A : B    same as max (B, A)
     A <= B? A : B    same as min (A, B)
     A < B?  A : B    same as min (B, A)

     As above, these transformations don't work in the presence
     of signed zeros.  For example, if A and B are zeros of
     opposite sign, the first two transformations will change
     the sign of the result.  In the last four, the original
     expressions give different results for (A=+0, B=-0) and
     (A=-0, B=+0), but the transformed expressions do not.

     The first two transformations are correct if either A or B
     is a NaN.  In the first transformation, the condition will
     be false, and B will indeed be chosen.  In the case of the
     second transformation, the condition A != B will be true,
     and A will be chosen.

     The conversions to max() and min() are not correct if B is
     a number and A is not.  The conditions in the original
     expressions will be false, so all four give B.  The min()
     and max() versions would give a NaN instead.  
         Avoid these transformations if the COND_EXPR may be used
         as an lvalue in the C++ front-end.  PR c++/19199.  
         Avoid adding NOP_EXPRs in case this is an lvalue.  
             In C++ a ?: expression can be an lvalue, so put the
             operand which will be used if they are equal first
             so that we can convert this back to the
             corresponding COND_EXPR.  
     If this is A op C1 ? A : C2 with C1 and C2 constant integers,
     we might still be able to simplify this.  For example,
     if C1 is one less or one more than C2, this might have started
     out as a MIN or MAX and been transformed by this function.
     Only good for INTEGER_TYPEs, because we need TYPE_MAX_VALUE.  
           We can replace A with C1 in this case.  
           If C1 is C2 + 1, this is min(A, C2), but use ARG00's type for
           MIN_EXPR, to preserve the signedness of the comparison.  
           If C1 is C2 - 1, this is min(A, C2), with the same care
           as above.  
           If C1 is C2 - 1, this is max(A, C2), but use ARG00's type for
           MAX_EXPR, to preserve the signedness of the comparison.  
           If C1 is C2 + 1, this is max(A, C2), with the same care as above.  
static tree fold_convert_const ( enum  tree_code,
tree  ,
tree   
)
static
static tree fold_convert_const ( )
static
   Attempt to fold type conversion operation CODE of expression ARG1 to
   type TYPE.  If no simplification can be done return NULL_TREE.  
static tree fold_convert_const_fixed_from_fixed ( )
static
   A subroutine of fold_convert_const handling conversions a FIXED_CST
   to another fixed-point type.  
     Propagate overflow flags.  
static tree fold_convert_const_fixed_from_int ( )
static
   A subroutine of fold_convert_const handling conversions an INTEGER_CST
   to a fixed-point type.  
     Propagate overflow flags.  

References tree_int_cst_equal().

static tree fold_convert_const_fixed_from_real ( )
static
   A subroutine of fold_convert_const handling conversions a REAL_CST
   to a fixed-point type.  
     Propagate overflow flags.  
static tree fold_convert_const_int_from_fixed ( )
static
   A subroutine of fold_convert_const handling conversions of a
   FIXED_CST to an integer type.  
     Right shift FIXED_CST to temp by fbit.  
         Left shift temp to temp_trunc by fbit.  
     If FIXED_CST is negative, we need to round the value toward 0.
     By checking if the fractional bits are not zero to add 1 to temp.  
     Given a fixed-point constant, make new constant with new type,
     appropriately sign-extended or truncated.  

References build_fixed(), fixed_convert(), and FIXED_VALUE_TYPE.

static tree fold_convert_const_int_from_int ( )
static
   A subroutine of fold_convert_const handling conversions of an
   INTEGER_CST to another integer type.  
     Given an integer constant, make new constant with new type,
     appropriately sign-extended or truncated.  

References double_int::lshift(), and double_int::rshift().

static tree fold_convert_const_int_from_real ( )
static
   A subroutine of fold_convert_const handling conversions a REAL_CST
   to an integer type.  
     The following code implements the floating point to integer
     conversion rules required by the Java Language Specification,
     that IEEE NaNs are mapped to zero and values that overflow
     the target precision saturate, i.e. values greater than
     INT_MAX are mapped to INT_MAX, and values less than INT_MIN
     are mapped to INT_MIN.  These semantics are allowed by the
     C and C++ standards that simply state that the behavior of
     FP-to-integer conversion is unspecified upon overflow.  
     If R is NaN, return zero and show we have an overflow.  
     See if R is less than the lower bound or greater than the
     upper bound.  
static tree fold_convert_const_real_from_fixed ( )
static
   A subroutine of fold_convert_const handling conversions a FIXED_CST
   to a floating point type.  
static tree fold_convert_const_real_from_real ( )
static
   A subroutine of fold_convert_const handling conversions a REAL_CST
   to another floating point type.  
     If converting an infinity or NAN to a representation that doesn't
     have one, set the overflow bit so that we can produce some kind of
     error message at the appropriate point if necessary.  It's not the
     most user-friendly message, but it's better than nothing.  
     Regular overflow, conversion produced an infinity in a mode that
     can't represent them.  
bool fold_convertible_p ( )
   Returns true, if ARG is convertible to TYPE using a NOP_EXPR.  

Referenced by ipa_modify_call_arguments(), and read_replacements_section().

void fold_defer_overflow_warnings ( void  )
   Start deferring overflow warnings.  We could use a stack here to
   permit nested calls, but at present it is not necessary.  

References fold_deferring_overflow_warnings.

Referenced by bit_value_binop(), create_bb(), and rhs_to_tree().

bool fold_deferring_overflow_warnings_p ( void  )
   Whether we are deferring overflow warnings.  
static tree fold_div_compare ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Subroutine of fold() that optimizes comparisons of a division by
   a nonzero integer constant against an integer constant, i.e.
   X/C1 op C2.

   CODE is the comparison operator: EQ_EXPR, NE_EXPR, GT_EXPR, LT_EXPR,
   GE_EXPR or LE_EXPR.  TYPE is the type of the result and ARG0 and ARG1
   are the operands of the comparison.  ARG1 must be a TREE_REAL_CST.

   The function returns the constant folded tree if a simplification
   can be made, and NULL_TREE otherwise.  
     We have to do this the hard way to detect unsigned overflow.
     prod = int_const_binop (MULT_EXPR, arg01, arg1);  
         Likewise hi = int_const_binop (PLUS_EXPR, prod, tmp).  
         A negative divisor reverses the relational operators.  
tree fold_ignored_result ( )
   Strip non-trapping, non-side-effecting tree nodes from an expression
   whose result is ignored.  The type of the returned tree need not be
   the same as the original expression.  
tree fold_indirect_ref_1 ( )
   Given a pointer value OP0 and a type TYPE, return a simplified version
   of an indirection through OP0, or NULL_TREE if no simplification is
   possible.  
         *&CONST_DECL -> to the value of the const decl.  
         *&p => p;  make sure to handle *&"str"[cst] here.  
         *(foo *)&fooarray => fooarray[0] 
         *(foo *)&complexfoo => __real__ complexfoo 
         *(foo *)&vectorfoo => BIT_FIELD_REF<vectorfoo,...> 
             ((foo*)&vectorfoo)[1] => BIT_FIELD_REF<vectorfoo,...> 
             ((foo*)&complexfoo)[1] => __imag__ complexfoo 
             ((foo *)&fooarray)[1] => fooarray[1] 
     *(foo *)fooarrptr => (*fooarrptr)[0] 
tree fold_indirect_ref_loc ( )
   Given an INDIRECT_REF T, return either T or a simplified version.  
static tree fold_inf_compare ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Subroutine of fold() that optimizes comparisons against Infinities,
   either +Inf or -Inf.

   CODE is the comparison operator: EQ_EXPR, NE_EXPR, GT_EXPR, LT_EXPR,
   GE_EXPR or LE_EXPR.  TYPE is the type of the result and ARG0 and ARG1
   are the operands of the comparison.  ARG1 must be a TREE_REAL_CST.

   The function returns the constant folded tree if a simplification
   can be made, and NULL_TREE otherwise.  
     For negative infinity swap the sense of the comparison.  
         x > +Inf is always false, if with ignore sNANs.  
         x <= +Inf is always true, if we don't case about NaNs.  
         x <= +Inf is the same as x == x, i.e. isfinite(x).  
         x == +Inf and x >= +Inf are always equal to x > DBL_MAX.  
         x < +Inf is always equal to x <= DBL_MAX.  
         x != +Inf is always equal to !(x > DBL_MAX).  
static tree fold_invert_truthvalue ( )
static
   Fold the truth-negation of ARG.  This never alters ARG itself.  We
   assume that ARG is an operation that returns a truth value (0 or 1
   for scalars, 0 or -1 for vectors).  Return the folded expression if
   folding is successful.  Otherwise, return NULL_TREE.  
static tree fold_mathfn_compare ( location_t  loc,
enum built_in_function  fcode,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Subroutine of fold() that checks comparisons of built-in math
   functions against real constants.

   FCODE is the DECL_FUNCTION_CODE of the built-in, CODE is the comparison
   operator: EQ_EXPR, NE_EXPR, GT_EXPR, LT_EXPR, GE_EXPR or LE_EXPR.  TYPE
   is the type of the result and ARG0 and ARG1 are the operands of the
   comparison.  ARG1 must be a TREE_REAL_CST.

   The function returns the constant folded tree if a simplification
   can be made, and NULL_TREE otherwise.  
             sqrt(x) < y is always false, if y is negative.  
             sqrt(x) > y is always true, if y is negative and we
             don't care about NaNs, i.e. negative values of x.  
             sqrt(x) > y is the same as x >= 0, if y is negative.  
                 sqrt(x) > y is x == +Inf, when y is very large.  
                 sqrt(x) > y is always false, when y is very large
                 and we don't care about infinities.  
             sqrt(x) > c is the same as x > c*c.  
                 sqrt(x) < y is always true, when y is a very large
                 value and we don't care about NaNs or Infinities.  
                 sqrt(x) < y is x != +Inf when y is very large and we
                 don't care about NaNs.  
                 sqrt(x) < y is x >= 0 when y is very large and we
                 don't care about Infinities.  
                 sqrt(x) < y is x >= 0 && x != +Inf, when y is large.  
             sqrt(x) < c is the same as x < c*c, if we ignore NaNs.  
             sqrt(x) < c is the same as x >= 0 && x < c*c.  

References build_int_cst(), fold_convert_loc(), fold_single_bit_test_into_sign_test(), host_integerp(), integer_pow2p(), integer_zerop(), tree_log2(), lang_hooks_for_types::type_for_mode, and lang_hooks::types.

static tree fold_minmax ( )
static
   Fold a binary expression of code CODE and type TYPE with operands
   OP0 and OP1, containing either a MIN-MAX or a MAX-MIN combination.
   Return the folded expression if folding is successful.  Otherwise,
   return NULL_TREE.  
     MIN (MAX (a, b), b) == b.  
     MIN (MAX (b, a), b) == b.  
     MIN (a, MAX (a, b)) == a.  
     MIN (a, MAX (b, a)) == a.  
static tree fold_mult_zconjz ( )
static
   Subroutine of fold_binary.  Optimize complex multiplications of the
   form z * conj(z), as pow(realpart(z),2) + pow(imagpart(z),2).  The
   argument EXPR represents the expression "z" of type TYPE.  

References fold_binary_loc(), fold_convert_loc(), and integer_zerop().

static tree fold_negate_const ( tree  ,
tree   
)
static
static tree fold_negate_const ( )
static
   Return the tree for neg (ARG0) when ARG0 is known to be either
   an integer constant, real, or fixed-point constant.

   TYPE is the type of the result.  
           Propagate overflow flags.  
static tree fold_negate_expr ( )
static
   Given T, an expression, return a folded tree for -T or NULL_TREE, if no
   simplification is possible.
   If negate_expr_p would return true for T, NULL_TREE will never be
   returned.  
       Convert - (~A) to A + 1.  
         Two's complement FP formats, such as c4x, may overflow.  
             -(A + B) -> (-B) - A.  
             -(A + B) -> (-A) - B.  
         - (A - B) -> B - A  
         Fall through.  
         In general we can't negate A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
         and actually traps on some architectures.  But if overflow is
         undefined, we can negate, because - (INT_MIN / 1) is an
         overflow.  
             If overflow is undefined then we have to be careful because
             we ask whether it's ok to associate the negate with the
             division which is not ok for example for
             -((a - b) / c) where (-(a - b)) / c may invoke undefined
             overflow because of negating INT_MIN.  So do not use
             negate_expr_p here but open-code the two important cases.  
         Convert -((double)float) into (double)(-float).  
         Negate -f(x) as f(-x).  
         Optimize -((int)x >> 31) into (unsigned)x >> 31.  

References build_complex(), and negate_expr().

static tree fold_not_const ( const_tree  ,
tree   
)
static
static tree fold_not_const ( )
static
   Return the tree for not (ARG0) when ARG0 is known to be an integer
   constant.  TYPE is the type of the result.  
static void fold_overflow_warning ( )
static
   This is called when we fold something based on the fact that signed
   overflow is undefined.  
static tree fold_plusminus_mult_expr ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Fold a sum or difference of at least one multiplication.
   Returns the folded tree or NULL if no simplification could be made.  
     (A * C) +- (B * C) -> (A+-B) * C.
     (A * C) +- A -> A * (C+-1).
     We are most concerned about the case where C is a constant,
     but other combinations show up during loop reduction.  Since
     it is not difficult, try all four possibilities.  
         We cannot generate constant 1 for fract.  
         As we canonicalize A - 2 to A + -2 get rid of that sign for
         the purpose of this canonicalization.  
         We cannot generate constant 1 for fract.  
     No identical multiplicands; see if we can find a common
     power-of-two factor in non-power-of-two multiplies.  This
     can help in multi-dimensional array access.  
         Move min of absolute values to int11.  
             The remainder should not be a constant, otherwise we
             end up folding i * 4 + 2 to (i * 2 + 1) * 2 which has
             increased the number of multiplications necessary.  
static tree fold_range_test ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1 
)
static
   EXP is some logical combination of boolean tests.  See if we can
   merge it into some range test.  Return the new tree if so.  
     If this is an OR operation, invert both sides; we will invert
     again at the end.  
     If both expressions are the same, if we can merge the ranges, and we
     can build the range test, return it or it inverted.  If one of the
     ranges is always true or always false, consider it to be the same
     expression as the other.  
     On machines where the branch cost is expensive, if this is a
     short-circuited branch and the underlying object on both sides
     is the same, make a non-short-circuit operation.  
         If simple enough, just rewrite.  Otherwise, make a SAVE_EXPR
         unless we are at top level or LHS contains a PLACEHOLDER_EXPR, in
         which cases we can't do this.  

References combine_comparisons(), operand_equal_p(), and swap_tree_comparison().

tree fold_read_from_constant_string ( )
   If EXP represents referencing an element in a constant string
   (either via pointer arithmetic or array indexing), return the
   tree representing the value accessed, otherwise return NULL.  
             Optimize the special-case of a zero lower bound.

             We convert the low_bound to sizetype to avoid some problems
             with constant folding.  (E.g. suppose the lower bound is 1,
             and its mode is QI.  Without the conversion,l (ARRAY
             +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
             +INDEX), which becomes (ARRAY+255+INDEX).  Oops!)  
bool fold_real_zero_addition_p ( )
   Subroutine of fold() that checks for the addition of +/- 0.0.

   If !NEGATE, return true if ADDEND is +/-0.0 and, for all X of type
   TYPE, X + ADDEND is the same as X.  If NEGATE, return true if X -
   ADDEND is the same as X.

   X + 0 and X - 0 both give X when X is NaN, infinite, or nonzero
   and finite.  The problematic cases are when X is zero, and its mode
   has signed zeros.  In the case of rounding towards -infinity,
   X - 0 is not the same as X because 0 - 0 is -0.  In other rounding
   modes, X + 0 is not the same as X because -0 + 0 is 0.  
     Don't allow the fold with -fsignaling-nans.  
     Allow the fold if zeros aren't signed, or their sign isn't important.  
     In a vector or complex, we would need to check the sign of all zeros.  
     Treat x + -0 as x - 0 and x - -0 as x + 0.  
     The mode has signed zeros, and we have to honor their sign.
     In this situation, there is only one case we can return true for.
     X - 0 is the same as X unless rounding towards -infinity is
     supported.  
static tree fold_relational_const ( enum  tree_code,
tree  ,
tree  ,
tree   
)
static
static tree fold_relational_const ( )
static
   Given CODE, a relational operator, the target type, TYPE and two
   constant operands OP0 and OP1, return the result of the
   relational operation.  If the result is not a compile time
   constant, then return NULL_TREE.  
     From here on, the only cases we handle are when the result is
     known to be a constant.  
         Handle the cases where either operand is a NaN.  
     Handle equality/inequality of complex constants.  
     From here on we only handle LT, LE, GT, GE, EQ and NE.

     To compute GT, swap the arguments and do LT.
     To compute GE, do LT and invert the result.
     To compute LE, swap the arguments, do LT and invert the result.
     To compute NE, do EQ and invert the result.

     Therefore, the code below must handle only EQ and LT.  
     Note that it is safe to invert for real values here because we
     have already handled the one case that it matters.  
     Compute a result for LT or EQ if args permit;
     Otherwise return T.  
static tree fold_sign_changed_comparison ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Fold comparison ARG0 CODE ARG1 (with result in TYPE), where for
   ARG0 just the signedness is changed.  
     Disable this optimization if we're casting a function pointer
     type on targets that require function pointer canonicalization.  
tree fold_single_bit_test ( location_t  loc,
enum tree_code  code,
tree  arg0,
tree  arg1,
tree  result_type 
)
   If CODE with arguments ARG0 and ARG1 represents a single bit
   equality/inequality test, then return a simplified form of
   the test using shifts and logical operations.  Otherwise return
   NULL.  TYPE is the desired result type.  
     If this is testing a single bit, we can optimize the test.  
         First, see if we can fold the single bit test into a sign-bit
         test.  
         Otherwise we have (A & C) != 0 where C is a single bit,
         convert that into ((A >> C2) & 1).  Where C2 = log2(C).
         Similarly for (A & C) == 0.  
         If INNER is a right shift of a constant and it plus BITNUM does
         not overflow, adjust BITNUM and INNER.  
         If we are going to be able to omit the AND below, we must do our
         operations as unsigned.  If we must use the AND, we have a choice.
         Normally unsigned is faster, but for some machines signed is.  
         Put the AND last so it can combine with more things.  
         Make sure to return the proper type.  
static tree fold_single_bit_test_into_sign_test ( location_t  loc,
enum tree_code  code,
tree  arg0,
tree  arg1,
tree  result_type 
)
static
   If CODE with arguments ARG0 and ARG1 represents a single bit
   equality/inequality test, then return a simplified form of the test
   using a sign testing.  Otherwise return NULL.  TYPE is the desired
   result type.  
     If this is testing a single bit, we can optimize the test.  
         If we have (A & C) != 0 where C is the sign bit of A, convert
         this into A < 0.  Similarly for (A & C) == 0 into A >= 0.  
             This is only a win if casting to a signed type is cheap,
             i.e. when arg00's type is not a partial mode.  

Referenced by fold_mathfn_compare().

tree fold_strip_sign_ops ( )
   Simplify the floating point expression EXP when the sign of the
   result is not significant.  Return NULL_TREE if no simplification
   is possible.  
             Strip copysign function call, return the 1st argument. 
             Strip sign ops from the argument of "odd" math functions.  

Referenced by fold_trunc_transparent_mathfn().

tree fold_ternary_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
tree  op2 
)
   Fold a ternary expression of code CODE and type TYPE with operands
   OP0, OP1, and OP2.  Return the folded expression if folding is
   successful.  Otherwise, return NULL_TREE.  
     Strip any conversions that don't change the mode.  This is safe
     for every expression, except for a comparison expression because
     its signedness is derived from its operands.  So, in the latter
     case, only strip conversions that don't change the signedness.

     Note that this is done as an internal manipulation within the
     constant folder, in order to find the simplest representation of
     the arguments so that their form can be studied.  In any cases,
     the appropriate type conversions should be put back in the tree
     that will get out of the constant folder.  
         Pedantic ANSI C says that a conditional expression is never an lvalue,
         so all simple results must be passed through pedantic_non_lvalue.  
             Only optimize constant conditions when the selected branch
             has the same type as the COND_EXPR.  This avoids optimizing
             away "c ? x : throw", where the throw has a void type.
             Avoid throwing away that operand which contains label.  
         If we have A op B ? A : C, we may be able to convert this to a
         simpler expression, depending on the operation and the values
         of B and C.  Signed zeros prevent all of these transformations,
         for reasons given above each one.

         Also try swapping the arguments and inverting the conditional.  
         If the second operand is simpler than the third, swap them
         since that produces better jump optimization results.  
             See if this can be inverted.  If it can't, possibly because
             it was a floating-point inequality comparison, don't do
             anything.  
         Convert A ? 1 : 0 to simply A.  
             If we try to convert OP0 to our type, the
             call to fold will try to move the conversion inside
             a COND, which will recurse.  In that case, the COND_EXPR
             is probably the best choice, so leave it alone.  
         Convert A ? 0 : 1 to !A.  This prefers the use of NOT_EXPR
         over COND_EXPR in cases such as floating point comparisons.  
         A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>).  
             sign_bit_p looks through both zero and sign extensions,
             but for this optimization only sign extensions are
             usable.  
             sign_bit_p only checks ARG1 bits within A's precision.
             If <sign bit of A> has wider type than A, bits outside
             of A's precision in <sign bit of A> need to be checked.
             If they are all 0, this optimization needs to be done
             in unsigned A's type, if they are all 1 in signed A's type,
             otherwise this can't be done.  
         (A >> N) & 1 ? (1 << N) : 0 is simply A & (1 << N).  A & 1 was
         already handled above.  
         A & N ? N : 0 is simply A & N if N is a power of two.  This
         is probably obsolete because the first operand should be a
         truth value (that's why we have the two cases above), but let's
         leave it in until we can confirm this for all front-ends.  
         Disable the transformations below for vectors, since
         fold_binary_op_with_conditional_arg may undo them immediately,
         yielding an infinite loop.  
         Convert A ? B : 0 into A && B if A and B are truth values.  
         Convert A ? B : 1 into !A || B if A and B are truth values.  
             Only perform transformation if ARG0 is easily inverted.  
         Convert A ? 0 : B into !A && B if A and B are truth values.  
             Only perform transformation if ARG0 is easily inverted.  
         Convert A ? 1 : B into A || B if A and B are truth values.  
         CALL_EXPRs used to be ternary exprs.  Catch any mistaken uses
         of fold_ternary on them.  
                 Constructor elements can be subvectors.  
                 We keep an exact subset of the constructor elements.  
                 The bitfield references a single constructor element.  
         A bit-field-ref that referenced the full argument can be stripped.  
         On constants we can use native encode/interpret to constant
         fold (nearly) all BIT_FIELD_REFs.  
             This limitation should not be necessary, we just need to
             round this up to mode size.  
             Need bit-shifting of the buffer to relax the following.  
             ???  We cannot tell native_encode_expr to start at
             some random byte only.  So limit us to a reasonable amount
             of work.  
         For integers we can decompose the FMA if possible.  
static tree fold_to_nonsharp_ineq_using_bound ( )
static
   Fold A < X && A + 1 > Y to A < X && A >= Y.  Normally A + 1 > Y
   means A >= Y && A != MAX, but in this case we know that
   A < X <= MAX.  INEQ is A + 1 > Y, BOUND is A < X.  
         Convert the pointer types into integer before taking the difference.  
static tree fold_truth_andor ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1,
tree  op0,
tree  op1 
)
static
   Fold a binary bitwise/truth expression of code CODE and type TYPE with
   operands OP0 and OP1.  LOC is the location of the resulting expression.
   ARG0 and ARG1 are the NOP_STRIPed results of OP0 and OP1.
   Return the folded expression if folding is successful.  Otherwise,
   return NULL_TREE.  
     We only do these simplifications if we are optimizing.  
     Check for things like (A || B) && (A || C).  We can convert this
     to A || (B && C).  Note that either operator can be any of the four
     truth and/or operations and the transformation will still be
     valid.   Also note that we only care about order for the
     ANDIF and ORIF operators.  If B contains side effects, this
     might change the truth-value of A.  
         This case if tricky because we must either have commutative
         operators or else A10 must not have side-effects.  
     See if we can build a range comparison.  
     Check for the possibility of merging component references.  If our
     lhs is another similar operation, try to merge its rhs with our
     rhs.  Then try to merge our lhs and rhs.  
         Transform ((A AND-IF B) AND[-IF] C) into (A AND-IF (B AND C)),
         or ((A OR-IF B) OR[-IF] C) into (A OR-IF (B OR C))
         We don't want to pack more than two leafs to a non-IF AND/OR
         expression.
         If tree-code of left-hand operand isn't an AND/OR-IF code and not
         equal to IF-CODE, then we don't want to add right-hand operand.
         If the inner right-hand side of left-hand operand has
         side-effects, or isn't simple, then we can't add to it,
         as otherwise we might destroy if-sequence.  
             Needed for sequence points to handle trappings, and
             side-effects.  
           Same as abouve but for (A AND[-IF] (B AND-IF C)) -> ((A AND B) AND-IF C),
           or (A OR[-IF] (B OR-IF C) -> ((A OR B) OR-IF C).  
             Needed for sequence points to handle trappings, and
             side-effects.  
         Transform (A AND-IF B) into (A AND B), or (A OR-IF B)
         into (A OR B).
         For sequence point consistancy, we need to check for trapping,
         and side-effects.  
static tree fold_truth_andor_1 ( location_t  loc,
enum tree_code  code,
tree  truth_type,
tree  lhs,
tree  rhs 
)
static
   Find ways of folding logical expressions of LHS and RHS:
   Try to merge two comparisons to the same innermost item.
   Look for range tests like "ch >= '0' && ch <= '9'".
   Look for combinations of simple terms on machines with expensive branches
   and evaluate the RHS unconditionally.

   For example, if we have p->a == 2 && p->b == 4 and we can make an
   object large enough to span both A and B, we can do this with a comparison
   against the object ANDed with the a mask.

   If we have p->a == q->a && p->b == q->b, we may be able to use bit masking
   operations to do this with one comparison.

   We check for both normal comparisons and the BIT_AND_EXPRs made this by
   function and the one above.

   CODE is the logical operation being done.  It can be TRUTH_ANDIF_EXPR,
   TRUTH_AND_EXPR, TRUTH_ORIF_EXPR, or TRUTH_OR_EXPR.

   TRUTH_TYPE is the type of the logical operand and LHS and RHS are its
   two operands.

   We return the simplified tree or 0 if no optimization is possible.  
     If this is the "or" of two comparisons, we can do something if
     the comparisons are NE_EXPR.  If this is the "and", we can do something
     if the comparisons are EQ_EXPR.  I.e.,
        (a->b == 2 && a->c == 4) can become (a->new == NEW).

     WANTED_CODE is this operation code.  For single bit fields, we can
     convert EQ_EXPR to NE_EXPR so we need not reject the "wrong"
     comparison for one-bit fields.  
     Start by getting the comparison codes.  Fail if anything is volatile.
     If one operand is a BIT_AND_EXPR with the constant one, treat it as if
     it were surrounded with a NE_EXPR.  
     Simplify (x<y) && (x==y) into (x<=y) and related optimizations.  
     If the RHS can be evaluated unconditionally and its operands are
     simple, it wins to evaluate the RHS unconditionally on machines
     with expensive branches.  In this case, this isn't a comparison
     that can be merged.  
         Convert (a != 0) || (b != 0) into (a | b) != 0.  
         Convert (a == 0) && (b == 0) into (a | b) == 0.  
     See if the comparisons can be merged.  Then get all the parameters for
     each side.  
     It must be true that the inner operation on the lhs of each
     comparison must be the same if we are to be able to do anything.
     Then see if we have constants.  If not, the same must be true for
     the rhs's.  
     If either comparison code is not correct for our logical operation,
     fail.  However, we can convert a one-bit comparison against zero into
     the opposite comparison against that bit being set in the field.  
             Make the left operand unsigned, since we are only interested
             in the value of one bit.  Otherwise we are doing the wrong
             thing below.  
     This is analogous to the code for l_const above.  
     See if we can find a mode that contains both fields being compared on
     the left.  If we can't, fail.  Otherwise, update all constants and masks
     to be relative to a field of that size.  
     If the right sides are not constant, do the same for it.  Also,
     disallow this optimization if a size or signedness mismatch occurs
     between the left and right sides.  
             Make sure the two fields on the right
             correspond to the left without being swapped.  
         Make a mask that corresponds to both fields being compared.
         Do this for both items being compared.  If the operands are the
         same size and the bits being compared are in the same position
         then we can do this by masking both and comparing the masked
         results.  
         There is still another way we can do something:  If both pairs of
         fields being compared are adjacent, we may be able to make a wider
         field containing them both.

         Note that we still must mask the lhs/rhs expressions.  Furthermore,
         the mask must be shifted to account for the shift done by
         make_bit_field_ref.  
             Convert to the smaller type before masking out unwanted bits.  
     Handle the case of comparisons with constants.  If there is something in
     common between the masks, those bits of the constants must be the same.
     If not, the condition is always false.  Test for this to avoid generating
     incorrect code below.  
     Construct the expression we will return.  First get the component
     reference we will make.  Unless the mask is all ones the width of
     that field, perform the mask operation.  Then compare with the
     merged constant.  
static tree fold_truth_not_expr ( )
static
   Return a simplified tree node for the truth-negation of ARG.  This
   never alters ARG itself.  We assume that ARG is an operation that
   returns a truth value (0 or 1).

   FIXME: one would think we would fold the result, but it causes
   problems with the dominator optimizer.  
     If this is a comparison, we can simply invert it, except for
     floating-point non-equality comparisons, in which case we just
     enclose a TRUTH_NOT_EXPR around what we have.  
         Here we can invert either operand.  We invert the first operand
         unless the second operand is a TRUTH_NOT_EXPR in which case our
         result is the XOR of the first operand with the inside of the
         negation of the second operand.  
           A COND_EXPR may have a throw as one operand, which
           then has void type.  Just leave void operands
           as they are.  
         ... fall through ...  
tree fold_unary_ignore_overflow_loc ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0 
)
   If the operation was a conversion do _not_ mark a resulting constant
   with TREE_OVERFLOW if the original constant was not.  These conversions
   have implementation defined behavior and retaining the TREE_OVERFLOW
   flag here would confuse later passes such as VRP.  

References get_inner_reference().

tree fold_unary_loc ( )
   Fold a unary expression of code CODE and type TYPE with operand
   OP0.  Return the folded expression if folding is successful.
   Otherwise, return NULL_TREE.  
             Don't use STRIP_NOPS, because signedness of argument type
             matters.  
             Strip any conversions that don't change the mode.  This
             is safe for every expression, except for a comparison
             expression because its signedness is derived from its
             operands.

             Note that this is done as an internal manipulation within
             the constant folder, in order to find the simplest
             representation of the arguments so that their form can be
             studied.  In any cases, the appropriate type conversions
             should be put back in the tree that will get out of the
             constant folder.  
             If this was a conversion, and all we did was to move into
             inside the COND_EXPR, bring it back out.  But leave it if
             it is a conversion from integer to integer and the
             result precision is no wider than a word since such a
             conversion is cheap and may be optimized away by combine,
             while it couldn't if it were outside the COND_EXPR.  Then return
             so we don't get into an infinite recursion loop taking the
             conversion out and then back in.  
         Re-association barriers around constants and other re-association
         barriers can be removed.  
             If we have (type) (a CMP b) and type is an integral type, return
             new expression involving the new type.  Canonicalize
             (type) (a CMP b) to (a CMP b) ? (type) true : (type) false for
             non-integral type.
             Do not fold the result as that would not simplify further, also
             folding again results in recursions.  
         Handle cases of two conversions in a row.  
             In addition to the cases of two conversions in a row
             handled below, if we are converting something to its own
             type via an object of identical or wider precision, neither
             conversion is needed.  
             Likewise, if the intermediate and initial types are either both
             float or both integer, we don't need the middle conversion if the
             former is wider than the latter and doesn't change the signedness
             (for integers).  Avoid this if the final type is a pointer since
             then we sometimes need the middle conversion.  Likewise if the
             final type has a precision not equal to the size of its mode.  
             If we have a sign-extension of a zero-extended value, we can
             replace that by a single zero-extension.  Likewise if the
             final conversion does not change precision we can drop the
             intermediate conversion.  
             Two conversions in a row are not needed unless:
             - some conversion is floating-point (overstrict for now), or
             - some conversion is a vector (overstrict for now), or
             - the intermediate type is narrower than both initial and
               final, or
             - the intermediate type and innermost type differ in signedness,
               and the outermost type is wider than the intermediate, or
             - the initial type is a pointer type and the precisions of the
               intermediate and final types differ, or
             - the final type is a pointer type and the precisions of the
               initial and intermediate types differ.  
         Handle (T *)&A.B.C for A being of type T and B and C
         living at offset zero.  This occurs frequently in
         C++ upcasting and then accessing the base.  
             If the reference was to a (constant) zero offset, we can use
             the address of the base if it has the same base type
             as the result type and the pointer type is unqualified.  
             Detect assigning a bitfield.  
             Don't leave an assignment inside a conversion
             unless assigning a bitfield.  
             First do the assignment, then return converted constant.  
         Convert (T)(x & c) into (T)x & (T)c, if c is an integer
         constants (if x has signed type, the sign bit cannot be set
         in c).  This folds extension into the BIT_AND_EXPR.
         ??? We don't do it for BOOLEAN_TYPE or ENUMERAL_TYPE because they
         very likely don't have maximal range for their precision and this
         transformation effectively doesn't preserve non-maximal ranges.  
         Convert (T1)(X p+ Y) into ((T1)X p+ Y), for pointer type,
         when one of the new casts will fold away. Conservatively we assume
         that this happens when X or Y is NOP_EXPR or Y is INTEGER_CST. 
         Convert (T1)(~(T2)X) into ~(T1)X if T1 and T2 are integral types
         of the same precision, and X is an integer type not narrower than
         types T1 or T2, i.e. the cast (T2)X isn't an extension.  
         Convert (T1)(X * Y) into (T1)X * (T1)Y if T1 is narrower than the
         type of X and Y (integer types only).  
             Be careful not to introduce new overflows.  
         For integral conversions with the same precision or pointer
         conversions use a NOP_EXPR instead.  
         Strip inner integral conversions that do not change the precision.  
         Convert fabs((double)float) into (double)fabsf(float).  
         ABS_EXPR<ABS_EXPR<x>> = ABS_EXPR<x> even if flag_wrapv is on.  
         Strip sign ops from argument.  
         Convert ~ (-A) to A - 1.  
         Convert ~ (A - 1) or ~ (A + -1) to -A.  
         Convert ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify.  
         Perform BIT_NOT_EXPR on each element individually.  
         Note that the operand of this must be an int
         and its values must be 0 or 1.
         ("true" is a fixed value perhaps depending on the language,
         but we don't handle values other than 1 correctly yet.)  
         Fold *&X to X if X is an lvalue.  

Referenced by vec_cst_ctor_to_array().

tree fold_unary_to_constant ( )
   Given the components of a unary expression CODE, TYPE and OP0,
   attempt to fold the expression to a constant without modifying
   TYPE or OP0.

   If the expression could be simplified to a constant, then return
   the constant.  If the expression would not be simplified to a
   constant, then return NULL_TREE.  
void fold_undefer_and_ignore_overflow_warnings ( void  )
   Stop deferring overflow warnings, ignoring any deferred
   warnings.  
void fold_undefer_overflow_warnings ( )
   Stop deferring overflow warnings.  If there is a pending warning,
   and ISSUE is true, then issue the warning if appropriate.  STMT is
   the statement with which the warning should be associated (used for
   location information); STMT may be NULL.  CODE is the level of the
   warning--a warn_strict_overflow_code value.  This function will use
   the smaller of CODE and the deferred code when deciding whether to
   issue the warning.  CODE may be zero to mean to always use the
   deferred code.  
     Use the smallest code level when deciding to issue the
     warning.  

Referenced by bit_value_binop(), create_bb(), and rhs_to_tree().

static tree fold_vec_perm ( )
static
   Attempt to fold vector permutation of ARG0 and ARG1 vectors using SEL
   selector.  Return the folded VECTOR_CST or CONSTRUCTOR if successful,
   NULL_TREE otherwise.  
static tree fold_view_convert_expr ( )
static
   Fold a VIEW_CONVERT_EXPR of a constant expression EXPR to type
   TYPE at compile-time.  If we're unable to perform the conversion
   return NULL_TREE.  
     We support up to 512-bit values (for V8DFmode).  
     Check that the host and target are sane.  
static tree fold_widened_comparison ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Fold comparison ARG0 CODE ARG1 (with result in TYPE), where
   ARG0 is extended to a wider type.  
     Disable this optimization if we're casting a function pointer
     type on targets that require function pointer canonicalization.  
     If possible, express the comparison in the shorter mode.  
     If we are comparing with the integer that does not fit into the range
     of the shorter type, the result is known.  
static unsigned HOST_WIDE_INT get_pointer_modulus_and_residue ( tree  expr,
unsigned HOST_WIDE_INT residue,
bool  allow_func_align 
)
static
   Subroutine of fold_binary.  If P is the value of EXPR, computes
   power-of-two M and (arbitrary) N such that M divides (P-N).  This condition
   guarantees that P and N have the same least significant log2(M) bits.
   N is not otherwise constrained.  In particular, N is not normalized to
   0 <= N < M as is common.  In general, the precise value of P is unknown.
   M is chosen as large as possible such that constant N can be determined.

   Returns M and sets *RESIDUE to N.

   If ALLOW_FUNC_ALIGN is true, do take functions' DECL_ALIGN_UNIT into
   account.  This is not always possible due to PR 35705.
                 Compute the greatest power-of-2 divisor of op1.  
                 If align is non-zero and less than *modulus, replace
                 *modulus with align., If align is 0, then either op1 is 0
                 or the greatest power-of-2 divisor of op1 doesn't fit in an
                 unsigned HOST_WIDE_INT.  In either case, no additional
                 constraint is imposed.  
     If we get here, we were unable to determine anything useful about the
     expression.  
static bool int_binop_types_match_p ( )
static
   Check whether TYPE1 and TYPE2 are equivalent integer types, suitable
   for use in int_const_binop, size_binop and size_diffop.  
static tree int_const_binop_1 ( enum tree_code  code,
const_tree  arg1,
const_tree  arg2,
int  overflowable 
)
static
   Combine two integer constants ARG1 and ARG2 under operation CODE
   to produce a new constant.  Return NULL_TREE if we don't know how
   to evaluate CODE at compile-time.  
         It's unclear from the C standard whether shifts can overflow.
         The following code ignores overflow; perhaps a C standard
         interpretation ruling is needed.  
             MULT_HIGHPART_EXPR can't ever oveflow, as the multiplication
             is performed in twice the precision of arguments.  
         This is a shortcut for a common special case.  
         ... fall through ...  
         This is a shortcut for a common special case.  
         ... fall through ...  

References HOST_BITS_PER_WIDE_INT, and double_int::wide_mul_with_sign().

enum tree_code invert_tree_comparison ( )
   Given a tree comparison code, return the code that is the logical inverse.
   It is generally not safe to do this for floating-point comparisons, except
   for EQ_EXPR, NE_EXPR, ORDERED_EXPR and UNORDERED_EXPR, so we return
   ERROR_MARK in this case.  

References COMPCODE_EQ, COMPCODE_GE, COMPCODE_GT, COMPCODE_LE, COMPCODE_LT, COMPCODE_LTGT, COMPCODE_NE, COMPCODE_ORD, COMPCODE_UNEQ, COMPCODE_UNGE, COMPCODE_UNGT, COMPCODE_UNLE, COMPCODE_UNLT, and COMPCODE_UNORD.

Referenced by add_condition_to_pbb(), forward_propagate_addr_expr(), get_base_value(), get_cmp_code(), is_norm_cond_subset_of(), and simplify_using_outer_evolutions().

tree invert_truthvalue_loc ( )
   Return a simplified tree node for the truth-negation of ARG.  This
   never alters ARG itself.  We assume that ARG is an operation that
   returns a truth value (0 or 1 for scalars, 0 or -1 for vectors).  

References get_inner_reference().

static tree make_bit_field_ref ( location_t  loc,
tree  inner,
tree  type,
HOST_WIDE_INT  bitsize,
HOST_WIDE_INT  bitpos,
int  unsignedp 
)
static
   Return a BIT_FIELD_REF of type TYPE to refer to BITSIZE bits of INNER
   starting at BITPOS.  The field is unsigned if UNSIGNEDP is nonzero.  
tree make_range ( tree  exp,
int *  pin_p,
tree plow,
tree phigh,
bool *  strict_overflow_p 
)
   Given EXP, a logical expression, set the range it is testing into
   variables denoted by PIN_P, PLOW, and PHIGH.  Return the expression
   actually being tested.  *PLOW and *PHIGH will be made of the same
   type as the returned expression.  If EXP is not a comparison, we
   will most likely not be returning a useful value and range.  Set
   *STRICT_OVERFLOW_P to true if the return value is only valid
   because signed overflow is undefined; otherwise, do not change
   *STRICT_OVERFLOW_P.  
     Start with simply saying "EXP != 0" and then look at the code of EXP
     and see if we can refine the range.  Some of the cases below may not
     happen, but it doesn't seem worth worrying about this.  We "continue"
     the outer loop when we've changed something; otherwise we "break"
     the switch, which will "break" the while.  
     If EXP is a constant, we can evaluate whether this is true or false.  
tree make_range_step ( location_t  loc,
enum tree_code  code,
tree  arg0,
tree  arg1,
tree  exp_type,
tree p_low,
tree p_high,
int *  p_in_p,
bool *  strict_overflow_p 
)
   Helper routine for make_range.  Perform one step for it, return
   new expression if the loop should continue or NULL_TREE if it should
   stop.  
         We can only do something if the range is testing for zero.  
         We can only do something if the range is testing for zero
         and if the second operand is an integer constant.  Note that
         saying something is "in" the range we make is done by
         complementing IN_P since it will set in the initial case of
         being not equal to zero; "out" is leaving it alone.  
         If this is an unsigned comparison, we also know that EXP is
         greater than or equal to zero.  We base the range tests we make
         on that fact, so we record it here so we can parse existing
         range tests.  We test arg0_type since often the return type
         of, e.g. EQ_EXPR, is boolean.  
             If the high bound is missing, but we have a nonzero low
             bound, reverse the range so it goes from zero to the low bound
             minus 1.  
         If flag_wrapv and ARG0_TYPE is signed, make sure
         low and high are non-NULL, then normalize will DTRT.  
         (-x) IN [a,b] -> x in [-b, -a]  
         ~ X -> -X - 1  
         If flag_wrapv and ARG0_TYPE is signed, then we cannot
         move a constant to the other side.  
         If EXP is signed, any overflow in the computation is undefined,
         so we don't worry about it so long as our computations on
         the bounds don't overflow.  For unsigned, overflow is defined
         and this is exactly the right thing.  
           Check for an unsigned range which has wrapped around the maximum
           value thus making n_high < n_low, and normalize it.  
               If the range is of the form +/- [ x+1, x ], we won't
               be able to normalize it.  But then, it represents the
               whole range or the empty set, so make it
               +/- [ -, - ].  
         If we're converting arg0 from an unsigned type, to exp,
         a signed type,  we will be doing the comparison as unsigned.
         The tests above have already verified that LOW and HIGH
         are both positive.

         So we have to ensure that we will handle large unsigned
         values the same way that the current signed bounds treat
         negative values.  
             For fixed-point modes, we need to pass the saturating flag
             as the 2nd parameter.  
             A range without an upper bound is, naturally, unbounded.
             Since convert would have cropped a very large value, use
             the max value for the destination type.  
             If the low bound is specified, "and" the range with the
             range for which the original unsigned value will be
             positive.  
                 Otherwise, "or" the range with the range of the input
                 that will be interpreted as negative.  
static double_int mask_with_tz ( )
static
    Mask out the tz least significant bits of X of type TYPE where
    tz is the number of trailing zeroes in Y.  
bool may_negate_without_overflow_p ( )
   Check whether we may negate an integer constant T without causing
   overflow.  

Referenced by create_iv().

static tree maybe_canonicalize_comparison ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1 
)
static
   Canonicalize the comparison ARG0 CODE ARG1 with type TYPE with undefined
   overflow further.  Try to decrease the magnitude of constants involved
   by changing LE_EXPR and GE_EXPR to LT_EXPR and GT_EXPR or vice versa
   and put sole constants at the second argument position.
   Returns the canonicalized tree if changed, otherwise NULL_TREE.  
     Try canonicalization by simplifying arg0.  
     Try canonicalization by simplifying arg1 using the swapped
     comparison.  

References omit_one_operand_loc().

static tree maybe_canonicalize_comparison_1 ( location_t  loc,
enum tree_code  code,
tree  type,
tree  arg0,
tree  arg1,
bool *  strict_overflow_p 
)
static
   Helper that tries to canonicalize the comparison ARG0 CODE ARG1
   by changing CODE to reduce the magnitude of constants involved in
   ARG0 of the comparison.
   Returns a canonicalized comparison tree if a simplification was
   possible, otherwise returns NULL_TREE.
   Set *STRICT_OVERFLOW_P to true if the canonicalization is only
   valid if signed overflow is undefined.  
     Match A +- CST code arg1 and CST code arg1.  We can change the
     first form only if overflow is undefined.  
            In principle pointers also have undefined overflow behavior,
            but that causes problems elsewhere.  
     Identify the constant in arg0 and its sign.  
     Overflowed constants and zero will cause problems.  
     See if we can reduce the magnitude of the constant in
     arg0 by changing the comparison code.  
         CST <= arg1  ->  CST-1 < arg1.  
         -CST < arg1  ->  -CST-1 <= arg1.  
         CST > arg1  ->  CST-1 >= arg1.  
         -CST >= arg1  ->  -CST-1 > arg1.  
         arg1 code' CST' might be more canonical.  
         A - CST < arg1  ->  A - CST-1 <= arg1.  
         A + CST > arg1  ->  A + CST-1 >= arg1.  
         A + CST <= arg1  ->  A + CST-1 < arg1.  
         A - CST >= arg1  ->  A - CST-1 > arg1.  
     Now build the constant reduced in magnitude.  But not if that
     would produce one outside of its types range.  
       We cannot swap the comparison here as that would cause us to
       endlessly recurse.  
     If swapping might yield to a more canonical form, do so.  
static bool maybe_lvalue_p ( )
static
   Return false if expr can be assumed not to be an lvalue, true
   otherwise.  
     We only need to wrap lvalue tree codes.  
       Assume the worst for front-end tree codes.  
bool merge_ranges ( int *  pin_p,
tree plow,
tree phigh,
int  in0_p,
tree  low0,
tree  high0,
int  in1_p,
tree  low1,
tree  high1 
)
   Given two ranges, see if we can merge them into one.  Return 1 if we
   can, 0 if we can't.  Set the output range into the specified parameters.  
     Make range 0 be the range that starts first, or ends last if they
     start at the same value.  Swap them if it isn't.  
     Now flag two cases, whether the ranges are disjoint or whether the
     second range is totally subsumed in the first.  Note that the tests
     below are simplified by the ones above.  
     We now have four cases, depending on whether we are including or
     excluding the two ranges.  
         If they don't overlap, the result is false.  If the second range
         is a subset it is the result.  Otherwise, the range is from the start
         of the second to the end of the first.  
         If they don't overlap, the result is the first range.  If they are
         equal, the result is false.  If the second range is a subset of the
         first, and the ranges begin at the same place, we go from just after
         the end of the second range to the end of the first.  If the second
         range is not a subset of the first, or if it is a subset and both
         ranges end at the same place, the range starts at the start of the
         first range and ends just before the second range.
         Otherwise, we can't describe this as a single range.  
                 We are in the weird situation where high0 > high1 but
                 high1 has no successor.  Punt.  
                 low0 < low1 but low1 has no predecessor.  Punt.  
         If they don't overlap, the result is the second range.  If the second
         is a subset of the first, the result is false.  Otherwise,
         the range starts just after the first range and ends at the
         end of the second.  
                 high1 > high0 but high0 has no successor.  Punt.  
         The case where we are excluding both ranges.  Here the complex case
         is if they don't overlap.  In that case, the only time we have a
         range is if they are adjacent.  If the second is a subset of the
         first, the result is the first.  Otherwise, the range to exclude
         starts at the beginning of the first range and ends at the end of the
         second.  
                 Canonicalize - [min, x] into - [-, x].  
                       FALLTHROUGH 
                 Canonicalize - [x, max] into - [x, -].  
                       FALLTHROUGH 
                 The ranges might be also adjacent between the maximum and
                 minimum values of the given type.  For
                 - [{min,-}, x] and - [y, {max,-}] ranges where x + 1 < y
                 return + [x + 1, y - 1].  

References fold_convert_loc(), negate_expr(), pedantic_non_lvalue_loc(), signed_type_for(), and tcc_comparison.

Referenced by optimize_range_tests_diff(), and sign_bit_p().

static tree merge_truthop_with_opposite_arm ( location_t  loc,
tree  op,
tree  cmpop,
bool  rhs_only 
)
static
   For an expression that has the form
     (A && B) || ~B
   or
     (A || B) && ~B,
   we can drop one of the inner expressions and simplify to
     A || ~B
   or
     A && ~B
   LOC is the location of the resulting expression.  OP is the inner 
   logical operation; the left-hand side in the examples above, while CMPOP
   is the right-hand side.  RHS_ONLY is used to prevent us from accidentally
   removing a condition that guards another, as in
     (A != NULL && A->...) || A == NULL
   which we must not transform.  If RHS_ONLY is true, only eliminate the
   right-most operand of the inner logical operation.  
int multiple_of_p ( )
   Determine if first argument is a multiple of second argument.  Return 0 if
   it is not, or we cannot easily determined it to be.

   An example of the sort of thing we care about (at this point; this routine
   could surely be made more general, and expanded to do what the *_DIV_EXPR's
   fold cases do now) is discovering that

     SAVE_EXPR (I) * SAVE_EXPR (J * 8)

   is a multiple of

     SAVE_EXPR (J * 8)

   when we know that the two SAVE_EXPR (J * 8) nodes are the same node.

   This code also handles discovering that

     SAVE_EXPR (I) * SAVE_EXPR (J * 8)

   is a multiple of 8 so we don't have to worry about dealing with a
   possible remainder.

   Note that we *look* inside a SAVE_EXPR only to determine how it was
   calculated; it is not safe for fold to do much of anything else with the
   internals of a SAVE_EXPR, since it cannot know when it will be evaluated
   at run time.  For example, the latter example above *cannot* be implemented
   as SAVE_EXPR (I) * J or any variant thereof, since the value of J at
   evaluation time of the original SAVE_EXPR is not necessarily the same at
   the time the new expression is evaluated.  The only optimization of this
   sort that would be valid is changing

     SAVE_EXPR (I) * SAVE_EXPR (SAVE_EXPR (J) * 8)

   divided by 8 to

     SAVE_EXPR (I) * SAVE_EXPR (J)

   (where the same SAVE_EXPR (J) is used in the original and the
   transformed version).  
         Bitwise and provides a power of two multiple.  If the mask is
         a multiple of BOTTOM then TOP is a multiple of BOTTOM.  
         FALLTHRU 
             const_binop may not detect overflow correctly,
             so check for it explicitly here.  
         Can't handle conversions from non-integral or wider integral type.  
         .. fall through ...  
static int native_encode_complex ( )
static
   Subroutine of native_encode_expr.  Encode the COMPLEX_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  
int native_encode_expr ( )
   Subroutine of fold_view_convert_expr.  Encode the INTEGER_CST,
   REAL_CST, COMPLEX_CST or VECTOR_CST specified by EXPR into the
   buffer PTR of length LEN bytes.  Return the number of bytes
   placed in the buffer, or zero upon failure.  

Referenced by vn_reference_lookup_3().

static int native_encode_fixed ( )
static
   Subroutine of native_encode_expr.  Encode the FIXED_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  
static int native_encode_int ( )
static
   Subroutine of native_encode_expr.  Encode the INTEGER_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  

Referenced by try_move_mult_to_index().

static int native_encode_real ( )
static
   Subroutine of native_encode_expr.  Encode the REAL_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  
     There are always 32 bits in each long, no matter the size of
     the hosts long.  We handle floating point representations with
     up to 192 bits.  
static int native_encode_string ( )
static
   Subroutine of native_encode_expr.  Encode the STRING_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  
static int native_encode_vector ( )
static
   Subroutine of native_encode_expr.  Encode the VECTOR_CST
   specified by EXPR into the buffer PTR of length LEN bytes.
   Return the number of bytes placed in the buffer, or zero
   upon failure.  
static tree native_interpret_complex ( )
static
   Subroutine of native_interpret_expr.  Interpret the contents of
   the buffer PTR of length LEN as a COMPLEX_CST of type TYPE.
   If the buffer cannot be interpreted, return NULL_TREE.  

References fold_convert_loc(), HOST_WIDE_INT_M1U, tree_low_cst(), and unsigned_type_for().

tree native_interpret_expr ( )
   Subroutine of fold_view_convert_expr.  Interpret the contents of
   the buffer PTR of length LEN as a constant of type TYPE.  For
   INTEGRAL_TYPE_P we return an INTEGER_CST, for SCALAR_FLOAT_TYPE_P
   we return a REAL_CST, etc...  If the buffer cannot be interpreted,
   return NULL_TREE.  

References fold_convert_loc().

Referenced by vn_reference_lookup_3().

static tree native_interpret_fixed ( )
static
   Subroutine of native_interpret_expr.  Interpret the contents of
   the buffer PTR of length LEN as a FIXED_CST of type TYPE.
   If the buffer cannot be interpreted, return NULL_TREE.  
static tree native_interpret_int ( )
static
   Subroutine of native_interpret_expr.  Interpret the contents of
   the buffer PTR of length LEN as an INTEGER_CST of type TYPE.
   If the buffer cannot be interpreted, return NULL_TREE.  
static tree native_interpret_real ( )
static
   Subroutine of native_interpret_expr.  Interpret the contents of
   the buffer PTR of length LEN as a REAL_CST of type TYPE.
   If the buffer cannot be interpreted, return NULL_TREE.  
     There are always 32 bits in each long, no matter the size of
     the hosts long.  We handle floating point representations with
     up to 192 bits.  

References build_fold_addr_expr_loc(), fold_convert_loc(), get_inner_reference(), offset, and TYPE_UNQUALIFIED.

static tree native_interpret_vector ( )
static
   Subroutine of native_interpret_expr.  Interpret the contents of
   the buffer PTR of length LEN as a VECTOR_CST of type TYPE.
   If the buffer cannot be interpreted, return NULL_TREE.  

References fold_convert_loc(), force_fit_type_double(), and tree_to_double_int().

static tree negate_expr ( )
static
   Like fold_negate_expr, but return a NEGATE_EXPR tree, if T can not be
   negated in a simpler way.  Also allow for T to be NULL_TREE, in which case
   return NULL_TREE. 
static bool negate_expr_p ( tree  )
static
static bool negate_expr_p ( )
static
   Determine whether an expression T can be cheaply negated using
   the function negate_expr without introducing undefined overflow.  
         Check that -CST will not overflow type.  
         We want to canonicalize to positive real constants.  Pretend
         that only negative ones can be easily negated.  
         -(A + B) -> (-B) - A.  
         -(A + B) -> (-A) - B.  
         We can't turn -(A-B) into B-A when we honor signed zeros.  
         Fall through.  
         In general we can't negate A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
         and actually traps on some architectures.  But if overflow is
         undefined, we can negate, because - (INT_MIN / 1) is an
         overflow.  
             If overflow is undefined then we have to be careful because
             we ask whether it's ok to associate the negate with the
             division which is not ok for example for
             -((a - b) / c) where (-(a - b)) / c may invoke undefined
             overflow because of negating INT_MIN.  So do not use
             negate_expr_p here but open-code the two important cases.  
         Negate -((double)float) as (double)(-float).  
         Negate -f(x) as f(-x).  
         Optimize -((int)x >> 31) into (unsigned)x >> 31.  
static bool negate_mathfn_p ( enum  built_in_function)
static
static bool negate_mathfn_p ( )
static
   Return true if the built-in mathematical function specified by CODE
   is odd, i.e. -f(x) == f(-x).  
tree non_lvalue_loc ( )
   Return an expr equal to X but certainly not valid as an lvalue.  
     While we are in GIMPLE, NON_LVALUE_EXPR doesn't mean anything to
     us.  
tree omit_one_operand_loc ( )
   Return a tree for the case when the result of an expression is RESULT
   converted to TYPE and OMITTED was previously an operand of the expression
   but is now not needed (e.g., we folded OMITTED * 0).

   If OMITTED has side effects, we must evaluate it.  Otherwise, just do
   the conversion of RESULT to TYPE.  
     If the resulting operand is an empty statement, just return the omitted
     statement casted to void. 

Referenced by fold_builtin_fputs(), fold_builtin_n(), and maybe_canonicalize_comparison().

tree omit_two_operands_loc ( location_t  loc,
tree  type,
tree  result,
tree  omitted1,
tree  omitted2 
)
   Return a tree for the case when the result of an expression is RESULT
   converted to TYPE and OMITTED1 and OMITTED2 were previously operands
   of the expression but are now not needed.

   If OMITTED1 or OMITTED2 has side effects, they must be evaluated.
   If both OMITTED1 and OMITTED2 have side effects, OMITTED1 is
   evaluated before OMITTED2.  Otherwise, if neither has side effects,
   just do the conversion of RESULT to TYPE.  

Referenced by build_call_expr().

static int operand_equal_for_comparison_p ( tree  ,
tree  ,
tree   
)
static
static int operand_equal_for_comparison_p ( )
static
   Similar to operand_equal_p, but see if ARG0 might have been made by
   shorten_compare from ARG1 when ARG1 was being compared with OTHER.

   When in doubt, return 0.  
     Discard any conversions that don't change the modes of ARG0 and ARG1
     and see if the inner values are the same.  This removes any
     signedness comparison, which doesn't matter here.  
     Duplicate what shorten_compare does to ARG1 and see if that gives the
     actual comparison operand, ARG0.

     First throw away any conversions to wider types
     already present in the operands.  
         Make sure shorter operand is extended the right way
         to match the longer operand.  

References eval_subst(), operand_equal_p(), tcc_binary, tcc_comparison, tcc_expression, and tcc_unary.

int operand_equal_p ( )
   Return nonzero if two operands (typically of the same tree node)
   are necessarily equal.  If either argument has side-effects this
   function returns zero.  FLAGS modifies behavior as follows:

   If OEP_ONLY_CONST is set, only return nonzero for constants.
   This function tests whether the operands are indistinguishable;
   it does not test whether they are equal using C's == operation.
   The distinction is important for IEEE floating point, because
   (1) -0.0 and 0.0 are distinguishable, but -0.0==0.0, and
   (2) two NaNs may be indistinguishable, but NaN!=NaN.

   If OEP_ONLY_CONST is unset, a VAR_DECL is considered equal to itself
   even though it may hold multiple values during a function.
   This is because a GCC tree node guarantees that nothing else is
   executed between the evaluation of its "operands" (which may often
   be evaluated in arbitrary order).  Hence if the operands themselves
   don't side-effect, the VAR_DECLs, PARM_DECLs etc... must hold the
   same value in each operand/subexpression.  Hence leaving OEP_ONLY_CONST
   unset means assuming isochronic (or instantaneous) tree equivalence.
   Unless comparing arbitrary expression trees, such as from different
   statements, this flag can usually be left unset.

   If OEP_PURE_SAME is set, then pure functions with identical arguments
   are considered the same.  It is used when the caller has other ways
   to ensure that global memory is unchanged in between.  
     If either is ERROR_MARK, they aren't equal.  
     Similar, if either does not have a type (like a released SSA name), 
     they aren't equal.  
     Check equality of integer constants before bailing out due to
     precision differences.  
     If both types don't have the same signedness, then we can't consider
     them equal.  We must check this before the STRIP_NOPS calls
     because they may change the signedness of the arguments.  As pointers
     strictly don't have a signedness, require either two pointers or
     two non-pointers as well.  
     We cannot consider pointers to different address space equal.  
     If both types don't have the same precision, then it is not safe
     to strip NOPs.  
     In case both args are comparisons but with different comparison
     code, try to swap the comparison operands of one arg to produce
     a match and compare that variant.  
         NOP_EXPR and CONVERT_EXPR are considered equal.  
     This is needed for conversions and for COMPONENT_REF.
     Might as well play it safe and always test this.  
     If ARG0 and ARG1 are the same SAVE_EXPR, they are necessarily equal.
     We don't care about side effects in that case because the SAVE_EXPR
     takes care of that for us. In all other cases, two expressions are
     equal if they have no side effects.  If we have two identical
     expressions with side effects that should be treated the same due
     to the only side effects being identical SAVE_EXPR's, that will
     be detected in the recursive calls below.
     If we are taking an invariant address of two identical objects
     they are necessarily equal as well.  
     Next handle constant cases, those for which we can return 1 even
     if ONLY_CONST is set.  
               If we do not distinguish between signed and unsigned zero,
               consider them equal.  
   Define macros to test an operand from arg0 and arg1 for equality and a
   variant that allows null and views null as being different from any
   non-null value.  In the latter case, if either is null, the both
   must be; otherwise, do the normal comparison.  
         Two conversions are equal only if signedness and modes match.  
         For commutative ops, allow the other order.  
         If either of the pointer (or reference) expressions we are
         dereferencing contain a side effect, these cannot be equal,
         but their addresses can be.  
             Require equal extra operands and then fall through to MEM_REF
             handling of the two common operands.  
             Fallthru.  
             Require equal access sizes, and similar pointer types.
             We can have incomplete types for array references of
             variable-sized arrays from the Fortran frontend
             though.  Also verify the types are compatible.  
             Operands 2 and 3 may be null.
             Compare the array index by value if it is constant first as we
             may have different types but same value here.  
             Handle operand 2 the same as for ARRAY_REF.  Operand 0
             may be NULL when we're called to compare MEM_EXPRs.  
             The multiplcation operands are commutative.  
             FALLTHRU 
             Otherwise take into account this is a commutative operation.  
             If the CALL_EXPRs call different functions, then they
             clearly can not be equal.  
             Now see if all the arguments are the same.  
               If we get here and both argument lists are exhausted
               then the CALL_EXPRs are equal.  
         Consider __builtin_sqrt equal to sqrt.  

Referenced by allocate_vn_table(), analyze_increments(), analyze_overlapping_iterations(), dse_optimize_stmt(), dump_value_range(), final_range_test_p(), fold_builtin_constant_p(), fold_builtin_fputs(), fold_builtin_logarithm(), fold_range_test(), fold_stmt_inplace(), asan_mem_ref_hasher::hash(), initialize_hash_element_from_expr(), make_invariant_chain(), move_pointer_to_base(), ncd_of_cand_and_phis(), operand_equal_for_comparison_p(), paradoxical_subreg_p(), print_graphite_statistics(), profitable_increment_p(), rewrite_use_nonlinear_expr(), same_phi_args_p(), valueize_val(), vect_build_slp_tree_1(), vn_reference_lookup_3(), vrp_meet_1(), vrp_val_max(), and vrp_val_min().

static tree optimize_bit_field_compare ( location_t  loc,
enum tree_code  code,
tree  compare_type,
tree  lhs,
tree  rhs 
)
static
   Optimize a bit-field compare.

   There are two cases:  First is a compare against a constant and the
   second is a comparison of two items where the fields are at the same
   bit position relative to the start of a chunk (byte, halfword, word)
   large enough to contain it.  In these cases we can avoid the shift
   implicit in bitfield extractions.

   For constants, we emit a compare of the shifted constant with the
   BIT_AND_EXPR of a mask and a byte, halfword, or word of the operand being
   compared.  For two fields at the same position, we do the ANDs with the
   similar mask and compare the result of the ANDs.

   CODE is the comparison code, known to be either NE_EXPR or EQ_EXPR.
   COMPARE_TYPE is the type of the comparison, and LHS and RHS
   are the left and right operands of the comparison, respectively.

   If the optimization described above can be done, we return the resulting
   tree.  Otherwise we return zero.  
     Get all the information about the extractions being done.  If the bit size
     if the same as the size of the underlying object, we aren't doing an
     extraction at all and so can do nothing.  We also don't want to
     do anything if the inner expression is a PLACEHOLDER_EXPR since we
     then will no longer be able to replace it.  
        If this is not a constant, we can only do something if bit positions,
        sizes, and signedness are the same.  
     See if we can find a mode to refer to this field.  We should be able to,
     but fail if we can't.  
     Set signed and unsigned types of the precision of this mode for the
     shifts below.  
     Compute the bit position and size for the new reference and our offset
     within it. If the new reference is the same size as the original, we
     won't optimize anything, so return zero.  
     Make the mask to be used against the extracted field.  
       If not comparing with constant, just rework the comparison
       and return.  
     Otherwise, we are handling the constant case. See if the constant is too
     big for the field.  Warn and return a tree of for 0 (false) if so.  We do
     this not only for its own sake, but to avoid having to test for this
     error case below.  If we didn't, we might generate wrong code.

     For unsigned fields, the constant shifted right by the field length should
     be all zero.  For signed fields, the high-order bits should agree with
     the sign bit.  
     Single-bit compares should always be against zero.  
     Make a new bitfield reference, shift the constant over the
     appropriate number of bits and mask it with the computed mask
     (in case this was a signed field).  If we changed it, make a new one.  
static tree optimize_minmax_comparison ( location_t  loc,
enum tree_code  code,
tree  type,
tree  op0,
tree  op1 
)
static
   Optimize T, which is a comparison of a MIN_EXPR or MAX_EXPR with a
   constant.  
     If something does not permit us to optimize, return the original tree.  
     Now handle all the various comparison codes.  We only handle EQ_EXPR
     and GT_EXPR, doing the rest with recursive calls using logical
     simplifications.  
           MAX (X, 0) == 0  ->  X <= 0  
           MAX (X, 0) == 5  ->  X == 5   
           MAX (X, 0) == -1  ->  false  
           MIN (X, 0) == 0  ->  X >= 0  
           MIN (X, 0) == 5  ->  false  
           MIN (X, 0) == -1  ->  X == -1  
           MAX (X, 0) > 0  ->  X > 0
           MAX (X, 0) > 5  ->  X > 5  
           MAX (X, 0) > -1  ->  true  
           MIN (X, 0) > 0  ->  false
           MIN (X, 0) > 5  ->  false  
           MIN (X, 0) > -1  ->  X > -1  

References negate_expr().

static tree pedantic_non_lvalue_loc ( )
static
   When pedantic, return an expr equal to X but certainly not valid as a
   pedantic lvalue.  Otherwise, return X.  

Referenced by merge_ranges().

static tree pedantic_omit_one_operand_loc ( location_t  loc,
tree  type,
tree  result,
tree  omitted 
)
static
   Similar, but call pedantic_non_lvalue instead of non_lvalue.  
     If the resulting operand is an empty statement, just return the omitted
     statement casted to void. 
static bool pointer_may_wrap_p ( )
static
   Return whether BASE + OFFSET + BITPOS may wrap around the address
   space.  This is used to avoid issuing overflow warnings for
   expressions like &p->x which can not wrap.  
     We can do slightly better for SIZE if we have an ADDR_EXPR of an
     array.  
void print_fold_checksum ( const_tree  )
void print_fold_checksum ( )
static tree protected_set_expr_location_unshare ( )
inlinestatic
   Similar to protected_set_expr_location, but never modify x in place,
   if location can and needs to be set, unshare it.  

References copy_node().

bool ptr_difference_const ( )
   Returns true if addresses of E1 and E2 differ by a constant, false
   otherwise.  If they do, E1 - E2 is stored in *DIFF.  
         If only one of the offsets is non-constant, the difference cannot
         be a constant.  
static tree range_binop ( enum tree_code  code,
tree  type,
tree  arg0,
int  upper0_p,
tree  arg1,
int  upper1_p 
)
static
   The following functions are subroutines to fold_range_test and allow it to
   try to change a logical combination of comparisons into a range test.

   For example, both
        X == 2 || X == 3 || X == 4 || X == 5
   and
        X >= 2 && X <= 5
   are converted to
        (unsigned) (X - 2) <= 3

   We describe each set of comparisons as being either inside or outside
   a range, using a variable named like IN_P, and then describe the
   range with a lower and upper bound.  If one of the bounds is omitted,
   it represents either the highest or lowest value of the type.

   In the comments below, we represent a range by two numbers in brackets
   preceded by a "+" to designate being inside that range, or a "-" to
   designate being outside that range, so the condition can be inverted by
   flipping the prefix.  An omitted bound is represented by a "-".  For
   example, "- [-, 10]" means being outside the range starting at the lowest
   possible value and ending at 10, in other words, being greater than 10.
   The range "+ [-, -]" is always true and hence the range "- [-, -]" is
   always false.

   We set up things so that the missing bounds are handled in a consistent
   manner so neither a missing bound nor "true" and "false" need to be
   handled using a special case.  
   Return the result of applying CODE to ARG0 and ARG1, but handle the case
   of ARG0 and/or ARG1 being omitted, meaning an unlimited range. UPPER0_P
   and UPPER1_P are nonzero if the respective argument is an upper bound
   and zero for a lower.  TYPE, if nonzero, is the type of the result; it
   must be specified for a comparison.  ARG1 will be converted to ARG0's
   type if both are specified.  
     If neither arg represents infinity, do the normal operation.
     Else, if not a comparison, return infinity.  Else handle the special
     comparison rules. Note that most of the cases below won't occur, but
     are handled for consistency.  
     Set SGN[01] to -1 if ARG[01] is a lower bound, 1 for upper, and 0
     for neither.  In real maths, we cannot assume open ended ranges are
     the same. But, this is computer arithmetic, where numbers are finite.
     We can therefore make the transformation of any unbounded range with
     the value Z, Z being greater than any representable number. This permits
     us to treat unbounded ranges as equal.  

Referenced by simple_operand_p().

static tree range_predecessor ( tree  )
static
static tree range_predecessor ( )
static
   Return the predecessor of VAL in its type, handling the infinite case.  
static tree range_successor ( tree  )
static
static tree range_successor ( )
static
   Return the successor of VAL in its type, handling the infinite case.  
static bool reorder_operands_p ( const_tree  ,
const_tree   
)
static
static bool reorder_operands_p ( )
static
   Check whether we are allowed to reorder operands arg0 and arg1,
   such that the evaluation of arg1 occurs before arg0.  
tree round_down_loc ( )
   Likewise, but round down.  
     See if VALUE is already a multiple of DIVISOR.  If so, we don't
     have to do anything.  Only do this when we are not given a const,
     because in that case, this check is more expensive than just
     doing it.  
     If divisor is a power of two, simplify this to bit manipulation.  
tree round_up_loc ( )
   Return the value of VALUE, rounded up to a multiple of DIVISOR.
   This can only be applied to objects of a sizetype.  
     See if VALUE is already a multiple of DIVISOR.  If so, we don't
     have to do anything.  Only do this when we are not given a const,
     because in that case, this check is more expensive than just
     doing it.  
     If divisor is a power of two, simplify this to bit manipulation.  
static tree sign_bit_p ( tree  ,
const_tree   
)
static
static tree sign_bit_p ( )
static
   Subroutine for fold: determine if VAL is the INTEGER_CONST that
   represents the sign bit of EXP's type.  If EXP represents a sign
   or zero extension, also test VAL against the unextended type.
   The return value is the (sub)expression whose sign bit is VAL,
   or NULL_TREE otherwise.  
     Tree EXP must have an integral type.  
     Tree VAL must be an integer constant.  
     We mask off those bits beyond TREE_TYPE (exp) so that we can
     treat VAL as if it were unsigned.  
     Handle extension from a narrower type.  

References integer_zerop(), and merge_ranges().

static int simple_operand_p ( const_tree  )
static
static int simple_operand_p ( )
static
   Subroutine for fold_truth_andor_1: determine if an operand is simple enough
   to be evaluated unconditionally.  
     Strip any conversions that don't change the machine mode.  
                 Don't regard global variables as simple.  They may be
                 allocated in ways unknown to the compiler (shared memory,
                 #pragma weak, etc).  
                 Weakrefs are not safe to be read, since they can be NULL.
                 They are !TREE_PUBLIC && !DECL_EXTERNAL but still
                 have DECL_WEAK flag set.  
                 Loading a static variable is unduly expensive, but global
                 registers aren't expensive.  

References build_int_cst(), and range_binop().

static bool simple_operand_p_2 ( tree  )
static
static bool simple_operand_p_2 ( )
static
   Subroutine for fold_truth_andor: determine if an operand is simple enough
   to be evaluated unconditionally.
   I addition to simple_operand_p, we assume that comparisons, conversions,
   and logic-not operations are simple, if their operands are simple, too.  
tree size_binop_loc ( )
   Combine operands OP1 and OP2 with arithmetic operation CODE.  CODE
   is a tree code.  The type of the result is taken from the operands.
   Both must be equivalent integer types, ala int_binop_types_match_p.
   If the operands are constant, so is the result.  
     Handle the special case of two integer constants faster.  
         And some specific cases even faster than that.  
         Handle general case of two integer constants.  For sizetype
         constant calculations we always want to know about overflow,
         even in the unsigned case.  
tree size_diffop_loc ( )
   Given two values, either both of sizetype or both of bitsizetype,
   compute the difference between the two values.  Return the value
   in signed type corresponding to the type of the operands.  
     If the type is already signed, just do the simple thing.  
     If either operand is not a constant, do the conversions to the signed
     type and subtract.  The hardware will do the right thing with any
     overflow in the subtraction.  
     If ARG0 is larger than ARG1, subtract and return the result in CTYPE.
     Otherwise, subtract the other way, convert to CTYPE (we know that can't
     overflow) and negate (which can't either).  Special-case a result
     of zero while we're here.  

Referenced by expand_expr_real_1().

tree size_int_kind ( )
   Create a sizetype INT_CST node with NUMBER sign extended.  KIND
   indicates which particular sizetype to create.  
static tree split_address_to_core_and_offset ( tree  exp,
HOST_WIDE_INT pbitpos,
tree poffset 
)
static
   Returns the pointer to the base of the object addressed by EXP and
   extracts the information about the offset of the access, storing it
   to PBITPOS and POFFSET.  
static tree split_tree ( tree  in,
enum tree_code  code,
tree conp,
tree litp,
tree minus_litp,
int  negate_p 
)
static
   Split a tree IN into a constant, literal and variable parts that could be
   combined with CODE to make IN.  "constant" means an expression with
   TREE_CONSTANT but that isn't an actual constant.  CODE must be a
   commutative arithmetic operation.  Store the constant part into *CONP,
   the literal in *LITP and return the variable part.  If a part isn't
   present, set it to null.  If the tree does not decompose in this way,
   return the entire tree as the variable part and the other parts as null.

   If CODE is PLUS_EXPR we also split trees that use MINUS_EXPR.  In that
   case, we negate an operand that was subtracted.  Except if it is a
   literal for which we use *MINUS_LITP instead.

   If NEGATE_P is true, we are negating all of IN, again except a literal
   for which we use *MINUS_LITP instead.

   If IN is itself a literal or constant, return it as appropriate.

   Note that we do not guarantee that any of the three values will be the
   same type as IN, but they will have the same signedness and mode.  
     Strip any conversions that don't change the machine mode or signedness.  
                  We can associate addition and subtraction together (even
                  though the C standard doesn't say so) for integers because
                  the value is not affected.  For reals, the value might be
                  affected, so we can't.  
         First see if either of the operands is a literal, then a constant.  
         If we haven't dealt with either operand, this is not a case we can
         decompose.  Otherwise, VAR is either of the ones remaining, if any.  
         Now do any needed negations.  
         -X - 1 is folded to ~X, undo that here.  
enum tree_code swap_tree_comparison ( )
   Similar, but return the comparison that results if the operands are
   swapped.  This is safe for floating-point.  

References comparison_to_compcode(), COMPCODE_EQ, COMPCODE_LTGT, COMPCODE_NE, COMPCODE_ORD, COMPCODE_TRUE, and COMPCODE_UNORD.

Referenced by dump_affine_iv(), fold_range_test(), range_includes_zero_p(), and tree_single_nonnegative_warnv_p().

bool tree_binary_nonnegative_warnv_p ( enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
bool *  strict_overflow_p 
)
   Return true if (CODE OP0 OP1) is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  
         zero_extend(x) + zero_extend(y) is non-negative if x and y are
         both unsigned and at least 2 bits shorter than the result.  
             x * x is always non-negative for floating point x
             or without overflow.  
         zero_extend(x) * zero_extend(y) is non-negative if x and y are
         both unsigned and their total bits is shorter than the result.  
     We don't know sign of `t', so be conservative and return false.  
bool tree_binary_nonzero_warnv_p ( enum tree_code  code,
tree  type,
tree  op0,
tree  op1,
bool *  strict_overflow_p 
)
   Return true when (CODE OP0 OP1) is an address and is known to be nonzero.
   For floating point we further ensure that T is not denormal.
   Similar logic is present in nonzero_address in rtlanal.h.

   If the return value is based on the assumption that signed overflow
   is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
   change *STRICT_OVERFLOW_P.  
             With the presence of negative values it is hard
             to say something.  
             One of operands must be positive and the other non-negative.  
             We don't set *STRICT_OVERFLOW_P here: even if this value
             overflows, on a twos-complement machine the sum of two
             nonnegative numbers can never be zero.  
             When both operands are nonzero, then MAX must be too.  
             MAX where operand 0 is positive is positive.  
         MAX where operand 1 is positive is positive.  
bool tree_call_nonnegative_warnv_p ( tree  type,
tree  fndecl,
tree  arg0,
tree  arg1,
bool *  strict_overflow_p 
)
   Return true if T is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  
           Always true.  
           sqrt(-0.0) is -0.0.  
           True if the 1st argument is nonnegative.  
           True if the 1st OR 2nd arguments are nonnegative.  
           True if the 1st AND 2nd arguments are nonnegative.  
           True if the 2nd argument is nonnegative.  
           True if the 1st argument is nonnegative or the second
           argument is an even integer.  
           True if the 1st argument is nonnegative or the second
           argument is an even integer valued real.  

Referenced by symbolic_range_p().

bool tree_expr_nonnegative_p ( )
   Return true if `t' is known to be non-negative.  Handle warnings
   about undefined signed overflow.  

References double_int::high.

Referenced by fold_builtin_int_roundingfn(), and integer_valued_real_p().

bool tree_expr_nonnegative_warnv_p ( )
   Return true if T is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  

Referenced by create_iv().

bool tree_expr_nonzero_p ( )
   Return true when T is an address and is known to be nonzero.
   Handle warnings about undefined signed overflow.  
bool tree_expr_nonzero_warnv_p ( )
   Return true when T is an address and is known to be nonzero.
   For floating point we further ensure that T is not denormal.
   Similar logic is present in nonzero_address in rtlanal.h.

   If the return value is based on the assumption that signed overflow
   is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
   change *STRICT_OVERFLOW_P.  
     Doing something useful for floating point would need more work.  

Referenced by fold_build2_stat_loc().

bool tree_invalid_nonnegative_warnv_p ( )
   Return true if T is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  
           If the initializer is non-void, then it's a normal expression
           that will be assigned to the slot.  
           Otherwise, the initializer sets the slot in some way.  One common
           way is an assignment statement at the end of the initializer.  
     We don't know sign of `t', so be conservative and return false.  
static bool tree_simple_nonnegative_warnv_p ( )
static
   Return true if CODE or TYPE is known to be non-negative. 
       Truth values evaluate to 0 or 1, which is nonnegative unless we
       have a signed:1 type (where the value is -1 and 0).  
bool tree_single_nonnegative_warnv_p ( )
   Return true if T is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  
     We don't know sign of `t', so be conservative and return false.  

References swap_tree_comparison().

bool tree_single_nonzero_warnv_p ( )
   Return true when T is an address and is known to be nonzero.
   For floating point we further ensure that T is not denormal.
   Similar logic is present in nonzero_address in rtlanal.h.

   If the return value is based on the assumption that signed overflow
   is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
   change *STRICT_OVERFLOW_P.  
           Weak declarations may link to NULL.  Other things may also be NULL
           so protect with -fdelete-null-pointer-checks; but not variables
           allocated on the stack.  
           Constants are never weak.  
bool tree_swap_operands_p ( )
   Test whether it is preferable two swap two operands, ARG0 and
   ARG1, for example because ARG0 is an integer constant and ARG1
   isn't.  If REORDER is true, only recommend swapping if we can
   evaluate the operands in reverse order.  
     It is preferable to swap two SSA_NAME to ensure a canonical form
     for commutative and comparison operators.  Ensuring a canonical
     form allows the optimizers to find additional redundancies without
     having to explicitly check for both orderings.  
     Put SSA_NAMEs last.  
     Put variables last.  

Referenced by vn_reference_lookup().

bool tree_unary_nonnegative_warnv_p ( enum tree_code  code,
tree  type,
tree  op0,
bool *  strict_overflow_p 
)
   Return true if (CODE OP0) is known to be non-negative.  If the return
   value is based on the assumption that signed overflow is undefined,
   set *STRICT_OVERFLOW_P to true; otherwise, don't change
   *STRICT_OVERFLOW_P.  
         We can't return 1 if flag_wrapv is set because
         ABS_EXPR<INT_MIN> = INT_MIN.  
     We don't know sign of `t', so be conservative and return false.  

References build_fixed(), build_real(), fixed_arithmetic(), FIXED_VALUE_TYPE, force_fit_type_double(), double_int::neg_with_overflow(), real_value_negate(), and tree_to_double_int().

Referenced by range_is_null().

bool tree_unary_nonzero_warnv_p ( enum tree_code  code,
tree  type,
tree  op0,
bool *  strict_overflow_p 
)
   Return true when (CODE OP0) is an address and is known to be nonzero.
   For floating point we further ensure that T is not denormal.
   Similar logic is present in nonzero_address in rtlanal.h.

   If the return value is based on the assumption that signed overflow
   is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
   change *STRICT_OVERFLOW_P.  
static tree try_move_mult_to_index ( )
static
   Tries to replace &a[idx] p+ s * delta with &a[idx + delta], if s is
   step of the array.  Reconstructs s and delta in the case of s *
   delta being an integer constant (and thus already folded).  ADDR is
   the address. MULT is the multiplicative expression.  If the
   function succeeds, the new address expression is returned.
   Otherwise NULL_TREE is returned.  LOC is the location of the
   resulting expression.  
      Strip the nops that might be added when converting op1 to sizetype. 
     Canonicalize op1 into a possibly non-constant delta
     and an INTEGER_CST s.  
         Simulate we are delta * 1.  
     Handle &x.array the same as we would handle &x.array[0].  
         Remember if this was a multi-dimensional array.  
             Try if delta is a multiple of step.  
         Only fold here if we can verify we do not overflow one
         dimension of a multi-dimensional array.  
         We found a suitable component reference.  
             Remember if this was a multi-dimensional array.  
                 Try if delta is a multiple of step.  
             Only fold here if we can verify we do not overflow one
             dimension of a multi-dimensional array.  
     We found the suitable array reference.  So copy everything up to it,
     and replace the index.  

References double_int_to_tree(), FIXED_VALUE_TYPE, native_encode_int(), lang_hooks_for_types::type_for_size, and lang_hooks::types.

static int twoval_comparison_p ( tree  ,
tree ,
tree ,
int *   
)
static
static int twoval_comparison_p ( )
static
   See if ARG is an expression that is either a comparison or is performing
   arithmetic on comparisons.  The comparisons must only be comparing
   two different values, which will be stored in *CVAL1 and *CVAL2; if
   they are nonzero it means that some operands have already been found.
   No variables may be used anywhere else in the expression except in the
   comparisons.  If SAVE_P is true it means we removed a SAVE_EXPR around
   the expression and save_expr needs to be called with CVAL1 and CVAL2.

   If this is true, return 1.  Otherwise, return zero.  
     We can handle some of the tcc_expression cases here.  
         If we've already found a CVAL1 or CVAL2, this expression is
         two complex to handle.  
         First see if we can handle the first operand, then the second.  For
         the second operand, we know *CVAL1 can't be zero.  It must be that
         one side of the comparison is each of the values; test for the
         case where this isn't true by failing if the two operands
         are the same.  
static tree unextend ( tree  ,
int  ,
int  ,
tree   
)
static
static tree unextend ( )
static
   Subroutine for fold_truth_andor_1: C is an INTEGER_CST interpreted as a P
   bit value.  Arrange things so the extra bits will be set to zero if and
   only if C is signed-extended to its full width.  If MASK is nonzero,
   it is an INTEGER_CST that should be AND'ed with the extra bits.  
     We work by getting just the sign bit into the low-order bit, then
     into the high-order bit, then sign-extend.  We then XOR that value
     with C.  
     We must use a signed type in order to get an arithmetic right shift.
     However, we must also avoid introducing accidental overflows, so that
     a subsequent call to integer_zerop will work.  Hence we must
     do the type conversion here.  At this point, the constant is either
     zero or one, and the conversion to a signed type can never overflow.
     We could get an overflow if this conversion is done anywhere else.  
     If necessary, convert the type back to match the type of C.  

References integer_pow2p(), and integer_zerop().

static bool vec_cst_ctor_to_array ( tree  ,
tree  
)
static
static bool vec_cst_ctor_to_array ( )
static
   Helper function for fold_vec_perm.  Store elements of VECTOR_CST or
   CONSTRUCTOR ARG into array ELTS and return true if successful.  

References fold_unary_loc(), and real_zerop().


Variable Documentation

enum warn_strict_overflow_code fold_deferred_overflow_code
static
   If a warning about undefined overflow is deferred, this is the
   level at which the warning should be emitted.  
const char* fold_deferred_overflow_warning
static
   If a warning about undefined overflow is deferred, this is the
   warning.  Note that this may cause us to turn two warnings into
   one, but that is fine since it is sufficient to only give one
   warning per expression.  
int fold_deferring_overflow_warnings
static
   This is nonzero if we should defer warnings about undefined
   overflow.  This facility exists because these warnings are a
   special case.  The code to estimate loop iterations does not want
   to issue any warnings, since it works with expressions which do not
   occur in user code.  Various bits of cleanup code call fold(), but
   only use the result if it has certain characteristics (e.g., is a
   constant); that code only wants to issue a warning if the result is
   used.  

Referenced by fold_defer_overflow_warnings().

int folding_initializer = 0
@verbatim 

Fold a constant sub-tree into a single node for C-compiler Copyright (C) 1987-2013 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/.

   The entry points in this file are fold, size_int_wide and size_binop.

   fold takes a tree as argument and returns a simplified tree.

   size_binop takes a tree code for an arithmetic operation
   and two operands that are trees, and produces a tree for the
   result, assuming the type comes from `sizetype'.

   size_int takes an integer value, and creates a tree constant
   with type from `sizetype'.

   Note: Since the folders get called on non-gimple code as well as
   gimple code, we need to handle GIMPLE tuples as well as their
   corresponding tree equivalents.  
   Nonzero if we are folding constants inside an initializer; zero
   otherwise.  
int pedantic_lvalues
   Nonzero means lvalues are limited to those valid in pedantic ANSI C.
   Zero means allow extended lvalues.