https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90878

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
We have

-- Target Hook: bool TARGET_RTX_COSTS (rtx X, machine_mode MODE, int
          OUTER_CODE, int OPNO, int *TOTAL, bool SPEED)
     This target hook describes the relative costs of RTL expressions.

     The cost may depend on the precise form of the expression, which is
     available for examination in X, and the fact that X appears as
     operand OPNO of an expression with rtx code OUTER_CODE.  That is,
     the ho-- Target Hook: bool TARGET_RTX_COSTS (rtx X, machine_mode MODE, int
          OUTER_CODE, int OPNO, int *TOTAL, bool SPEED)
     This target hook describes the relative costs of RTL expressions.

     The cost may depend on the precise form of the expression, which is
     available for examination in X, and the fact that X appears as
     operand OPNO of an expression with rtx code OUTER_CODE.  That is,
     the hook can assume that there is some rtx Y such that 'GET_CODE
     (Y) == OUTER_CODE' and such that either (a) 'XEXP (Y, OPNO) == X'
     or (b) 'XVEC (Y, OPNO)' contains X.

     MODE is X's machine mode, or for cases like 'const_int' that do not
     have a mode, the mode in which X is used.

     In implementing this hook, you can use the construct 'COSTS_N_INSNS
     (N)' to specify a cost equal to N fast instructions.

     On entry to the hook, '*TOTAL' contains a default estimate for the
     cost of the expression.  The hook should modify this value as
     necessary.  Traditionally, the default costs are 'COSTS_N_INSNS
     (5)' for multiplications, 'COSTS_N_INSNS (7)' for division and
     modulus operations, and 'COSTS_N_INSNS (1)' for all other
     operations.

     When optimizing for code size, i.e. when 'speed' is false, this
     target hook should be used to estimate the relative size cost of an
     expression, again relative to 'COSTS_N_INSNS'.

     The hook returns true when all subexpressions of X have been
     processed, and false when 'rtx_cost' should recurse.
ok can assume that there is some rtx Y such that 'GET_CODE
     (Y) == OUTER_CODE' and such that either (a) 'XEXP (Y, OPNO) == X'
     or (b) 'XVEC (Y, OPNO)' contains X.

     MODE -- Target Hook: bool TARGET_RTX_COSTS (rtx X, machine_mode MODE, int
          OUTER_CODE, int OPNO, int *TOTAL, bool SPEED)
     This target hook describes the relative costs of RTL expressions.

     The cost may depend on the precise form of the expression, which is
     available for examination in X, and the fact that X appears as
     operand OPNO of an expression with rtx code OUTER_CODE.  That is,
     the hook can assume that there is some rtx Y such that 'GET_CODE
     (Y) == OUTER_CODE' and such that either (a) 'XEXP (Y, OPNO) == X'
     or (b) 'XVEC (Y, OPNO)' contains X.

     MODE is X's machine mode, or for cases like 'const_int' that do not
     have a mode, the mode in which X is used.

     In implementing this hook, you can use the construct 'COSTS_N_INSNS
     (N)' to specify a cost equal to N fast instructions.

     On entry to the hook, '*TOTAL' contains a default estimate for the
     cost of the expression.  The hook should modify this value as
     necessary.  Traditionally, the default costs are 'COSTS_N_INSNS
     (5)' for multiplications, 'COSTS_N_INSNS (7)' for division and
     modulus operations, and 'COSTS_N_INSNS (1)' for all other
     operations.

     When optimizing for code size, i.e. when 'speed' is false, this
     target hook should be used to estimate the relative size cost of an
     expression, again relative to 'COSTS_N_INSNS'.

     The hook returns true when all subexpressions of X have been
     processed, and false when 'rtx_cost' should recurse.
is X's machine mode, or for cases like 'const_int' that do not
     have a mode, the mode in which X is used.

     In implementing this hook, you can use the construct 'COSTS_N_INSNS
     (N)' to specify a cost equal to N fast instructions.

     On entry to the hook, '*TOTAL' contains a default estimate for the
     cost of the expression.  The hook should modify this value as
     necessary.  Traditionally, the default costs are 'COSTS_N_INSNS
     (5)' for multiplications, 'COSTS_N_INSNS (7)' for division and
     modulus operations, and 'COSTS_N_INSNS (1)' for all other
     operations.

     When optimizing for code size, i.e. when 'speed' is false, this
     target hook should be used to estimate the relative size cost of an
     expression, again relative to 'COSTS_N_INSNS'.

     The hook returns true when all subexpressions of X have been
     processed, and false when 'rtx_cost' should recurse.

-- Target Hook: int TARGET_REGISTER_MOVE_COST (machine_mode MODE,
          reg_class_t FROM, reg_class_t TO)
     This target hook should return the cost of moving data of mode MODE
     from a register in class FROM to one in class TO.  The classes are
     expressed using the enumeration values such as 'GENERAL_REGS'.  A
     value of 2 is the default; other values are interpreted relative to
     that.

     It is not required that the cost always equal 2 when FROM is the
     same as TO; on some machines it is expensive to move between
     registers if they are not general registers.

     If reload sees an insn consisting of a single 'set' between two
     hard registers, and if 'TARGET_REGISTER_MOVE_COST' applied to their
     classes returns a value of 2, reload does not check to ensure that
     the constraints of the insn are met.  Setting a cost of other than
     2 will allow reload to verify that the constraints are met.  You
     should do this if the 'movM' pattern's constraints do not allow
     such copying.

     The default version of this function returns 2.

TARGET_REGISTER_MOVE_COST and TARGET_RTX_COSTS serve different purposes
with different formulas.  TARGET_REGISTER_MOVE_COST is used by register
allocator.  TARGET_RTX_COSTS describes the relative costs of RTL
expressions.  Using values intended for register allocator for
TARGET_RTX_COSTS isn't appropriate.

Reply via email to