GCC Middle and Back End API Reference
simplify-rtx.c File Reference

Data Structures

struct  simplify_plus_minus_op_data

Enumerations

enum  {
  CMP_EQ = 1, CMP_LT = 2, CMP_GT = 4, CMP_LTU = 8,
  CMP_GTU = 16
}

Functions

static rtx neg_const_int (enum machine_mode, const_rtx)
static bool plus_minus_operand_p (const_rtx)
static bool simplify_plus_minus_op_data_cmp (rtx, rtx)
static rtx simplify_plus_minus (enum rtx_code, enum machine_mode, rtx, rtx)
static rtx simplify_immed_subreg (enum machine_mode, rtx, enum machine_mode, unsigned int)
static rtx simplify_associative_operation (enum rtx_code, enum machine_mode, rtx, rtx)
static rtx simplify_relational_operation_1 (enum rtx_code, enum machine_mode, enum machine_mode, rtx, rtx)
static rtx simplify_unary_operation_1 (enum rtx_code, enum machine_mode, rtx)
static rtx simplify_binary_operation_1 (enum rtx_code, enum machine_mode, rtx, rtx, rtx, rtx)
static rtx neg_const_int ()
bool mode_signbit_p ()
bool val_signbit_p ()
bool val_signbit_known_set_p ()
bool val_signbit_known_clear_p ()
rtx simplify_gen_binary (enum rtx_code code, enum machine_mode mode, rtx op0, rtx op1)
rtx avoid_constant_pool_reference ()
rtx delegitimize_mem_from_attrs ()
rtx simplify_gen_unary (enum rtx_code code, enum machine_mode mode, rtx op, enum machine_mode op_mode)
rtx simplify_gen_ternary (enum rtx_code code, enum machine_mode mode, enum machine_mode op0_mode, rtx op0, rtx op1, rtx op2)
rtx simplify_gen_relational (enum rtx_code code, enum machine_mode mode, enum machine_mode cmp_mode, rtx op0, rtx op1)
rtx simplify_replace_fn_rtx (rtx x, const_rtx old_rtx, rtx(*fn)(rtx, const_rtx, void *), void *data)
rtx simplify_replace_rtx ()
static rtx simplify_truncation (enum machine_mode mode, rtx op, enum machine_mode op_mode)
rtx simplify_unary_operation (enum rtx_code code, enum machine_mode mode, rtx op, enum machine_mode op_mode)
static rtx simplify_unary_operation_1 ()
rtx simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode, rtx op, enum machine_mode op_mode)
static rtx simplify_byte_swapping_operation (enum rtx_code code, enum machine_mode mode, rtx op0, rtx op1)
rtx simplify_binary_operation (enum rtx_code code, enum machine_mode mode, rtx op0, rtx op1)
rtx simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode, rtx op0, rtx op1)
static bool simplify_plus_minus_op_data_cmp ()
static bool plus_minus_operand_p ()
rtx simplify_relational_operation (enum rtx_code code, enum machine_mode mode, enum machine_mode cmp_mode, rtx op0, rtx op1)
static rtx comparison_result ()
rtx simplify_const_relational_operation (enum rtx_code code, enum machine_mode mode, rtx op0, rtx op1)
rtx simplify_ternary_operation (enum rtx_code code, enum machine_mode mode, enum machine_mode op0_mode, rtx op0, rtx op1, rtx op2)
rtx simplify_subreg (enum machine_mode outermode, rtx op, enum machine_mode innermode, unsigned int byte)
rtx simplify_gen_subreg (enum machine_mode outermode, rtx op, enum machine_mode innermode, unsigned int byte)
rtx simplify_rtx ()

Enumeration Type Documentation

anonymous enum
Enumerator:
CMP_EQ 
CMP_LT 
CMP_GT 
CMP_LTU 
CMP_GTU 

Function Documentation

rtx avoid_constant_pool_reference ( )
If X is a MEM referencing the constant pool, return the real value.
   Otherwise return X.   

References avoid_constant_pool_reference(), get_pool_constant(), get_pool_mode(), HOST_WIDE_INT, offset, simplify_subreg(), and targetm.

static rtx comparison_result ( )
static
Convert the known results for EQ, LT, GT, LTU, GTU contained in
   KNOWN_RESULT to a CONST_INT, based on the requested comparison CODE
   For KNOWN_RESULT to make sense it should be either CMP_EQ, or the
   logical OR of one of (CMP_LT, CMP_GT) and one of (CMP_LTU, CMP_GTU).
   For floating-point comparisons, assume that the operands were ordered.   

References CMP_EQ, CMP_GT, CMP_GTU, CMP_LT, CMP_LTU, and const_true_rtx.

Referenced by simplify_const_relational_operation().

rtx delegitimize_mem_from_attrs ( )
Simplify a MEM based on its attributes.  This is the default
   delegitimize_address target hook, and it's recommended that every
   overrider call it.   

References get_inner_reference(), host_integerp(), HOST_WIDE_INT, offset, and rtx_equal_p().

bool mode_signbit_p ( )
Test whether expression, X, is an immediate constant that represents
   the most significant bit of machine mode MODE.   

References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.

static rtx neg_const_int ( enum  machine_mode,
const_rtx   
)
static
static rtx neg_const_int ( )
static
Negate a CONST_INT rtx, truncating (because a conversion from a
   maximally negative number can overflow).   

References gen_int_mode(), and HOST_WIDE_INT.

static bool plus_minus_operand_p ( const_rtx  )
static
static bool plus_minus_operand_p ( )
static
Check whether an operand is suitable for calling simplify_plus_minus.   
static rtx simplify_associative_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op0,
rtx  op1 
)
static
Subroutine of simplify_binary_operation to simplify a commutative,
   associative binary operation CODE with result mode MODE, operating
   on OP0 and OP1.  CODE is currently one of PLUS, MULT, AND, IOR, XOR,
   SMIN, SMAX, UMIN or UMAX.  Return zero if no simplification or
   canonicalization is possible.   

References simplify_binary_operation(), simplify_gen_binary(), and swap_commutative_operands_p().

Referenced by simplify_binary_operation_1().

rtx simplify_binary_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op0,
rtx  op1 
)
static rtx simplify_byte_swapping_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op0,
rtx  op1 
)
static
Subroutine of simplify_binary_operation to simplify a binary operation
   CODE that can commute with byte swapping, with result mode MODE and
   operating on OP0 and OP1.  CODE is currently one of AND, IOR or XOR.
   Return zero if no simplification or canonicalization is possible.   

References simplify_gen_binary(), and simplify_gen_unary().

Referenced by simplify_binary_operation_1().

rtx simplify_const_relational_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op0,
rtx  op1 
)
rtx simplify_const_unary_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op,
enum machine_mode  op_mode 
)
rtx simplify_gen_binary ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op0,
rtx  op1 
)
Make a binary operation by properly ordering the operands and
   seeing if the expression folds.   

References RTX_COMM_ARITH, simplify_binary_operation(), and swap_commutative_operands_p().

Referenced by anti_adjust_stack_and_probe(), apply_distributive_law(), break_out_memory_refs(), canon_reg_for_combine(), combine_simplify_rtx(), combine_var_copies_in_loop_exit(), distribute_and_simplify_rtx(), doloop_modify(), emit_block_move_via_loop(), expand_debug_expr(), expand_expr_addr_expr_1(), expand_expr_real_1(), expand_expr_real_2(), expand_field_assignment(), expand_shift_1(), extract_left_shift(), find_split_point(), fold_rtx(), force_to_mode(), gen_addr_rtx(), get_biv_step_1(), get_iv_value(), if_then_else_cond(), implies_p(), instantiate_virtual_regs_in_insn(), instantiate_virtual_regs_in_rtx(), iv_add(), iv_analyze_biv(), iv_mult(), iv_number_of_iterations(), iv_shift(), iv_subreg(), make_compound_operation(), noce_try_bitop(), offset_address(), probe_stack_range(), process_address(), propagate_rtx_1(), reverse_op(), simplify_and_const_int(), simplify_and_const_int_1(), simplify_associative_operation(), simplify_binary_operation_1(), simplify_byte_swapping_operation(), simplify_comparison(), simplify_if_then_else(), simplify_relational_operation_1(), simplify_replace_fn_rtx(), simplify_rtx(), simplify_set(), simplify_shift_const(), simplify_shift_const_1(), simplify_truncation(), simplify_unary_operation_1(), simplify_while_replacing(), split_iv(), try_combine(), unroll_loop_runtime_iterations(), and use_narrower_mode().

rtx simplify_gen_ternary ( enum rtx_code  code,
enum machine_mode  mode,
enum machine_mode  op0_mode,
rtx  op0,
rtx  op1,
rtx  op2 
)
static rtx simplify_immed_subreg ( enum machine_mode  outermode,
rtx  op,
enum machine_mode  innermode,
unsigned int  byte 
)
static
Evaluate a SUBREG of a CONST_INT or CONST_DOUBLE or CONST_FIXED
   or CONST_VECTOR,
   returning another CONST_INT or CONST_DOUBLE or CONST_FIXED or CONST_VECTOR.

   Works by unpacking OP into a collection of 8-bit values
   represented as a little-endian array of 'unsigned char', selecting by BYTE,
   and then repacking them again for OUTERMODE.   

References CONST_FIXED_FROM_FIXED_VALUE, FIXED_VALUE_TYPE, gen_int_mode(), gen_rtx_CONST_VECTOR(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, immed_double_const(), simplify_plus_minus_op_data::op, real_from_target(), real_to_target(), and rtvec_alloc().

Referenced by simplify_subreg().

static bool simplify_plus_minus_op_data_cmp ( rtx  ,
rtx   
)
static

Referenced by simplify_plus_minus().

static bool simplify_plus_minus_op_data_cmp ( )
static
rtx simplify_relational_operation ( enum rtx_code  code,
enum machine_mode  mode,
enum machine_mode  cmp_mode,
rtx  op0,
rtx  op1 
)
Like simplify_binary_operation except used for relational operators.
   MODE is the mode of the result. If MODE is VOIDmode, both operands must
   not also be VOIDmode.

   CMP_MODE specifies in which mode the comparison is done in, so it is
   the mode of the operands.  If CMP_MODE is VOIDmode, it is taken from
   the operands or, if both are VOIDmode, the operands are compared in
   "infinite precision".   

References avoid_constant_pool_reference(), rtvec_alloc(), simplify_const_relational_operation(), simplify_gen_relational(), simplify_relational_operation_1(), swap_commutative_operands_p(), and swap_condition().

Referenced by combine_simplify_rtx(), cselib_expand_value_rtx_1(), do_compare_rtx_and_jump(), expand_doubleword_shift(), fold_rtx(), simplify_gen_relational(), simplify_rtx(), simplify_set(), and simplify_ternary_operation().

static rtx simplify_relational_operation_1 ( enum rtx_code  code,
enum machine_mode  mode,
enum machine_mode  cmp_mode,
rtx  op0,
rtx  op1 
)
static
This part of simplify_relational_operation is only used when CMP_MODE
   is not in class MODE_CC (i.e. it is a real comparison).

   MODE is the mode of the result, while CMP_MODE specifies in which
   mode the comparison is done in, so it is the mode of the operands.   

References copy_rtx(), lowpart_subreg(), nonzero_bits(), reversed_comparison_code(), rtx_equal_p(), side_effects_p(), simplify_gen_binary(), simplify_gen_relational(), simplify_gen_unary(), and simplify_rtx().

Referenced by simplify_relational_operation().

rtx simplify_replace_fn_rtx ( rtx  x,
const_rtx  old_rtx,
rtx(*)(rtx, const_rtx, void *)  fn,
void *  data 
)
rtx simplify_replace_rtx ( )
Replace all occurrences of OLD_RTX in X with NEW_RTX and try to simplify the
   resulting RTX.  Return a new RTX which is as simplified as possible.   

References simplify_replace_fn_rtx().

rtx simplify_rtx ( )
Simplify X, an rtx expression.

   Return the simplified expression or NULL if no simplifications
   were possible.

   This is the preferred entry point into the simplification routines;
   however, we still allow passes to call the more specific routines.

   Right now GCC has three (yes, three) major bodies of RTL simplification
   code that need to be unified.

        1. fold_rtx in cse.c.  This code uses various CSE specific
           information to aid in RTL simplification.

        2. simplify_rtx in combine.c.  Similar to fold_rtx, except that
           it uses combine specific information to aid in RTL
           simplification.

        3. The routines in this file.


   Long term we want to only have one body of simplification code; to
   get to that state I recommend the following steps:

        1. Pour over fold_rtx & simplify_rtx and move any simplifications
           which are not pass dependent state into these routines.

        2. As code is moved by #1, change fold_rtx & simplify_rtx to
           use this routine whenever possible.

        3. Allow for pass dependent state to be provided to these
           routines and add simplifications based on the pass dependent
           state.  Remove code from cse.c & combine.c that becomes
           redundant/dead.

    It will take time, but ultimately the compiler will be easier to
    maintain and improve.  It's totally silly that when we add a
    simplification that it needs to be added to 4 places (3 for RTL
    simplification and 1 for tree simplification.   

References RTX_BIN_ARITH, RTX_BITFIELD_OPS, RTX_COMM_ARITH, RTX_COMM_COMPARE, RTX_COMPARE, rtx_equal_p(), RTX_EXTRA, RTX_OBJ, RTX_TERNARY, RTX_UNARY, simplify_binary_operation(), simplify_gen_binary(), simplify_relational_operation(), simplify_subreg(), simplify_ternary_operation(), simplify_unary_operation(), and swap_commutative_operands_p().

rtx simplify_ternary_operation ( enum rtx_code  code,
enum machine_mode  mode,
enum machine_mode  op0_mode,
rtx  op0,
rtx  op1,
rtx  op2 
)
static rtx simplify_truncation ( enum machine_mode  mode,
rtx  op,
enum machine_mode  op_mode 
)
static
Try to simplify a MODE truncation of OP, which has OP_MODE.
   Only handle cases where the truncated value is inherently an rvalue.

   RTL provides two ways of truncating a value:

   1. a lowpart subreg.  This form is only a truncation when both
      the outer and inner modes (here MODE and OP_MODE respectively)
      are scalar integers, and only then when the subreg is used as
      an rvalue.

      It is only valid to form such truncating subregs if the
      truncation requires no action by the target.  The onus for
      proving this is on the creator of the subreg -- e.g. the
      caller to simplify_subreg or simplify_gen_subreg -- and typically
      involves either TRULY_NOOP_TRUNCATION_MODES_P or truncated_to_mode.

   2. a TRUNCATE.  This form handles both scalar and compound integers.

   The first form is preferred where valid.  However, the TRUNCATE
   handling in simplify_unary_operation turns the second form into the
   first form when TRULY_NOOP_TRUNCATION_MODES_P or truncated_to_mode allow,
   so it is generally safe to form rvalue truncations using:

      simplify_gen_unary (TRUNCATE, ...)

   and leave simplify_unary_operation to work out which representation
   should be used.

   Because of the proof requirements on (1), simplify_truncation must
   also use simplify_gen_unary (TRUNCATE, ...) to truncate parts of OP,
   regardless of whether the outer truncation came from a SUBREG or a
   TRUNCATE.  For example, if the caller has proven that an SImode
   truncation of:

      (and:DI X Y)

   is a no-op and can be represented as a subreg, it does not follow
   that SImode truncations of X and Y are also no-ops.  On a target
   like 64-bit MIPS that requires SImode values to be stored in
   sign-extended form, an SImode truncation of:

      (and:DI (reg:DI X) (const_int 63))

   is trivially a no-op because only the lower 6 bits can be set.
   However, X is still an arbitrary 64-bit number and so we cannot
   assume that truncating it too is a no-op.   

References loop::inner, mode_dependent_address_p(), simplify_gen_binary(), simplify_gen_subreg(), simplify_gen_unary(), subreg_lowpart_offset(), and subreg_lowpart_p().

Referenced by simplify_subreg(), and simplify_unary_operation_1().

rtx simplify_unary_operation ( enum rtx_code  code,
enum machine_mode  mode,
rtx  op,
enum machine_mode  op_mode 
)
static rtx simplify_unary_operation_1 ( enum  rtx_code,
enum  machine_mode,
rtx   
)
static
bool val_signbit_known_clear_p ( )
Test whether the most significant bit of mode MODE is clear in VAL.
   Returns false if the precision of MODE is too large to handle.   

References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.

bool val_signbit_known_set_p ( )
Test whether the most significant bit of mode MODE is set in VAL.
   Returns false if the precision of MODE is too large to handle.   

References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.

bool val_signbit_p ( )
Test whether VAL is equal to the most significant bit of mode MODE
   (after masking with the mode mask of MODE).  Returns false if the
   precision of MODE is too large to handle.   

References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.