instruction are those involving floating-point or address. So
only these need be expensive. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
return 0; \
case CONST: \
The multiply cost depends on whether this is a 29050 or not. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MULT: \
return TARGET_29050 ? COSTS_N_INSNS (2) : COSTS_N_INSNS (40); \
case DIV: \
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
switch on CODE.
On C1 and C2, multiply is faster than shift. */
-#define RTX_COSTS(RTX,CODE) \
+#define RTX_COSTS(RTX,CODE,OUTER_CODE) \
case MULT: \
total = COSTS_N_INSNS (4); \
break; \
/* Provide the costs of a rtl expression. This is in the body of a
switch on CODE. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MULT: \
return COSTS_N_INSNS (10); \
case DIV: \
case UDIV: \
case MOD: \
case UMOD: \
- return COSTS_N_INSNS (40);
+ return COSTS_N_INSNS (40); \
+ case PLUS: \
+ if (GET_CODE (XEXP (RTX, 0)) == REG \
+ && GET_CODE (XEXP (RTX, 1)) == CONST_INT) \
+ return 1;
/* Compute the cost of computing a constant rtl expression RTX
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
case CONST: \
case LABEL_REF: \
return code == 1 ? 0 : \
code == 2 ? 1 : \
2; \
- } \
- case PLUS: \
- if (GET_CODE (XEXP (RTX, 0)) == REG \
- && GET_CODE (XEXP (RTX, 1)) == CONST_INT) \
- return 1;
+ }
/* Compute the cost of an address. This is meant to approximate the size
and/or execution delay of an insn using that address. If the cost is
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
/* Constant zero is super cheap due to clr instruction. */ \
if (RTX == const0_rtx) return 0; \
if (INTVAL (RTX) >= -128 && INTVAL (RTX) <= 127) return 1; \
/* Constants between -136 and 254 are easily generated */ \
/* by intelligent uses of moveq, add[q], and subq */ \
- if (INTVAL (RTX) >= -136 && INTVAL (RTX) <= 254) return 2; \
+ if (OUTER_CODE == SET && INTVAL (RTX) >= -136 \
+ && INTVAL (RTX) <= 254) return 2; \
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
#define MULL_COST (TARGET_68040 ? 5 : 13)
#define MULW_COST (TARGET_68040 ? 3 : 8)
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case PLUS: \
/* An lea costs about three times as much as a simple add. */ \
if (GET_MODE (X) == SImode \
is as good as a register; since it can't be placed in any insn, it
won't do anything in cse, but it will cause expand_binop to pass the
constant to the define_expands). */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
if (SMALL_INT (RTX)) \
return 0; \
/* Provide the costs of a rtl expression. This is in the body of a
switch on CODE. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MEM: \
return COSTS_N_INSNS (2); \
case MULT: \
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
if (INTVAL (RTX) <= 7 && INTVAL (RTX) >= -8) return 0; \
if (INTVAL (RTX) < 0x4000 && INTVAL (RTX) >= -0x4000) \
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
if (CONST_OK_FOR_LETTER_P (INTVAL (RTX),'I')) return 0; \
case CONST: \
few bits. */
#define SHIFT_COUNT_TRUNCATED
-/* Compute the cost of computing a constant rtl expression RTX
- whose rtx-code is CODE. The body of this macro is a portion
- of a switch statement. If the code is computed here,
- return it with a return statement. Otherwise, break from the switch. */
+/* Compute the cost of computing a constant rtl expression RTX whose
+ rtx-code is CODE, contained within an expression of code OUTER_CODE.
+ The body of this macro is a portion of a switch statement. If the
+ code is computed here, return it with a return statement. Otherwise,
+ break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
- return 0; \
+ if (OUTER_CODE == IOR && exact_log2 (INTVAL (RTX)) >= 0 \
+ || OUTER_CODE == AND && exact_log2 (~INTVAL (RTX)) >= 0 \
+ || ((OUTER_CODE == PLUS || OUTER_CODE == MINUS) \
+ && (unsigned int) (INTVAL (RTX) + 15) < 31) \
+ || (OUTER_CODE == SET && (unsigned int) INTVAL (RTX) < 16))\
+ return 0; \
+ return ((unsigned)(INTVAL(RTX) + 0x8000) < 0x10000 || (INTVAL (RTX) & 0xffff0000) == 0) ? 0 : COSTS_N_INSNS (2);\
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
- case CONST_DOUBLE: \
+ if (current_function_operand (RTX, Pmode)) return 0; \
return COSTS_N_INSNS (2);
+ case CONST_DOUBLE: \
+ if ((RTX) == CONST0_RTX (GET_MODE (RTX))) return 2; \
+ return (GET_MODE_CLASS (GET_MODE (RTX)) == MODE_FLOAT) ? COSTS_N_INSNS (5) : COSTS_N_INSNS (4);
/* Provide the costs of a rtl expression. This is in the body of a
switch on CODE.
References to our own data area are really references to r14, so they
are very cheap. Multiples and divides are very expensive. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MEM: \
return current_function_operand (X, Pmode) ? 0 : COSTS_N_INSNS (2); \
case MULT: \
- return TARGET_IN_LINE_MUL ? COSTS_N_INSNS (19) : COSTS_N_INSNS (25); \
+ return (TARGET_IN_LINE_MUL && GET_MODE_CLASS (GET_MODE (X)) == MODE_INT)\
+ ? COSTS_N_INSNS (19) : COSTS_N_INSNS (25); \
case DIV: \
case UDIV: \
case MOD: \
On the RS/6000, if it is legal in the insn, it is free. So this
always returns 0. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
case CONST: \
case LABEL_REF: \
/* Provide the costs of a rtl expression. This is in the body of a
switch on CODE. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MULT: \
return (GET_CODE (XEXP (X, 1)) != CONST_INT \
? COSTS_N_INSNS (5) \
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
if (INTVAL (RTX) == 0) \
return 0; \
If we need more than 12 insns to do a multiply, then go out-of-line,
since the call overhead will be < 10% of the cost of the multiply. */
-#define RTX_COSTS(X,CODE) \
+#define RTX_COSTS(X,CODE,OUTER_CODE) \
case MULT: \
return COSTS_N_INSNS (25); \
case DIV: \
/* specify the costs of various sorts of constants,
and also indicate that multiplication is cheap on this machine. */
-#define CONST_COSTS(RTX,CODE) \
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
/* Constant zero is super cheap due to clr instruction. */ \
if (RTX == const0_rtx) return 0; \
of a switch statement. If the code is computed here,
return it with a return statement. Otherwise, break from the switch. */
-#define CONST_COSTS(RTX,CODE) \
+/* On a VAX, constants from 0..63 are cheap because they can use the
+ 1 byte literal constant format. compare to -1 should be made cheap
+ so that decrement-and-branch insns can be formed more easily (if
+ the value -1 is copied to a register some decrement-and-branch patterns
+ will not match). */
+
+#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
case CONST_INT: \
- /* Constant zero is super cheap due to clr instruction. */ \
- if ((RTX) == const0_rtx) return 0; \
- /* Constants of +/- 1 should also be super cheap since \
- may be used in decl/incl/aob/sob insns. */ \
- if ((RTX) == const1_rtx || (RTX) == constm1_rtx) return 0; \
- if ((unsigned) INTVAL (RTX) < 077) return 1; \
+ if (INTVAL (RTX) == 0) return 0; \
+ if (OUTER_CODE == AND) \
+ return ((unsigned) ~INTVAL (RTX) <= 077) ? 1 : 2; \
+ if ((unsigned) INTVAL (RTX) <= 077) return 1; \
+ if (OUTER_CODE == COMPARE && INTVAL (RTX) == -1) return 1; \
+ if (OUTER_CODE == PLUS && (unsigned) -INTVAL (RTX) <= 077) return 1;\
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
return 3; \
case CONST_DOUBLE: \
- return 5;
-
-/* On most VAX models, shift are almost as expensive as multiplies, so
- we'd rather use multiply unless it can be done in an extremely small
- sequence. */
-#define RTX_COSTS(RTX,CODE) \
- case LSHIFT: \
- case ASHIFT: \
- case ASHIFTRT: \
- case LSHIFTRT: \
- case ROTATE: \
- case ROTATERT: \
- return COSTS_N_INSNS (4);
+ if (GET_MODE_CLASS (GET_MODE (RTX)) == MODE_FLOAT) \
+ return vax_float_literal (RTX) ? 5 : 8; \
+ else return \
+ (CONST_DOUBLE_HIGH (RTX) == 0 && (unsigned)CONST_DOUBLE_LOW (RTX) < 64 \
+ || OUTER_CODE == PLUS && CONST_DOUBLE_HIGH (RTX) == -1 && (unsigned)-CONST_DOUBLE_LOW (RTX) < 64) ? 2 : 5;
+
+#define RTX_COSTS(RTX,CODE,OUTER_CODE) case FIX: case FLOAT: \
+ case MULT: case DIV: case UDIV: case MOD: case UMOD: \
+ case LSHIFT: case ASHIFT: case LSHIFTRT: case ASHIFTRT: \
+ case ROTATE: case ROTATERT: case PLUS: case MINUS: case IOR: \
+ case XOR: case AND: case NEG: case NOT: case ZERO_EXTRACT: \
+ case SIGN_EXTRACT: case MEM: return vax_rtx_cost(RTX)
+
+#define ADDRESS_COST(RTX) (1 + (GET_CODE (RTX) == REG ? 0 : vax_address_cost(RTX)))
/* Specify the cost of a branch insn; roughly the number of extra insns that
should be added to avoid a branch.
rtx lea;
int i;
- add_cost = rtx_cost (gen_rtx (PLUS, SImode, reg, reg));
+ add_cost = rtx_cost (gen_rtx (PLUS, SImode, reg, reg), SET);
/* We multiply by 2 to reconcile the difference in scale between
these two ways of computing costs. Otherwise the cost of a copy
if (GET_CODE (*mult_val) == USE)
*mult_val = XEXP (*mult_val, 0);
- benefit += rtx_cost (orig_x);
+ benefit += rtx_cost (orig_x, SET);
/* Always return some benefit if this is a giv so it will be detected
as such. This allows elimination of bivs that might otherwise