From 3bb22aee136865d9eb1d0b34875fd10a130bdec3 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sat, 18 Apr 1992 19:56:04 +0000 Subject: [PATCH] *** empty log message *** From-SVN: r783 --- gcc/config/a29k/a29k.h | 4 ++-- gcc/config/convex/convex.h | 4 ++-- gcc/config/i386/i386.h | 16 ++++++++-------- gcc/config/m68k/m68k.h | 7 ++++--- gcc/config/m88k/m88k.h | 4 ++-- gcc/config/ns32k/ns32k.h | 2 +- gcc/config/pyr/pyr.h | 2 +- gcc/config/romp/romp.h | 29 +++++++++++++++++++--------- gcc/config/rs6000/rs6000.h | 4 ++-- gcc/config/sparc/sparc.h | 4 ++-- gcc/config/tahoe/tahoe.h | 2 +- gcc/config/vax/vax.h | 47 ++++++++++++++++++++++++++-------------------- gcc/loop.c | 4 ++-- 13 files changed, 74 insertions(+), 55 deletions(-) diff --git a/gcc/config/a29k/a29k.h b/gcc/config/a29k/a29k.h index ba92bd8..446a841 100644 --- a/gcc/config/a29k/a29k.h +++ b/gcc/config/a29k/a29k.h @@ -1221,7 +1221,7 @@ extern char *a29k_function_name; 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: \ @@ -1239,7 +1239,7 @@ extern char *a29k_function_name; 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: \ diff --git a/gcc/config/convex/convex.h b/gcc/config/convex/convex.h index e916987..760539f 100644 --- a/gcc/config/convex/convex.h +++ b/gcc/config/convex/convex.h @@ -751,7 +751,7 @@ enum reg_class { 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: \ @@ -764,7 +764,7 @@ enum reg_class { 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; \ diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 0d49e77..e689541 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1093,14 +1093,18 @@ while (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 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 @@ -1108,7 +1112,7 @@ while (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) \ +#define CONST_COSTS(RTX,CODE,OUTER_CODE) \ case CONST_INT: \ case CONST: \ case LABEL_REF: \ @@ -1120,11 +1124,7 @@ while (0) 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 diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 88997bc..44a1b73 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -1285,7 +1285,7 @@ __transfer_from_trampoline () \ 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; \ @@ -1293,7 +1293,8 @@ __transfer_from_trampoline () \ 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: \ @@ -1310,7 +1311,7 @@ __transfer_from_trampoline () \ #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 \ diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h index 850a466..96a4a55 100644 --- a/gcc/config/m88k/m88k.h +++ b/gcc/config/m88k/m88k.h @@ -1482,7 +1482,7 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, 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; \ @@ -1516,7 +1516,7 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, /* 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: \ diff --git a/gcc/config/ns32k/ns32k.h b/gcc/config/ns32k/ns32k.h index 43e2ce9..e672b92 100644 --- a/gcc/config/ns32k/ns32k.h +++ b/gcc/config/ns32k/ns32k.h @@ -999,7 +999,7 @@ __transfer_from_trampoline () \ 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) \ diff --git a/gcc/config/pyr/pyr.h b/gcc/config/pyr/pyr.h index 127d077..c057b76 100644 --- a/gcc/config/pyr/pyr.h +++ b/gcc/config/pyr/pyr.h @@ -1030,7 +1030,7 @@ extern int current_function_calls_alloca; 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: \ diff --git a/gcc/config/romp/romp.h b/gcc/config/romp/romp.h index 3de640f..5e2bc7e 100644 --- a/gcc/config/romp/romp.h +++ b/gcc/config/romp/romp.h @@ -1225,19 +1225,29 @@ struct rt_cargs {int gregs, fregs; }; 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. @@ -1245,11 +1255,12 @@ struct rt_cargs {int gregs, fregs; }; 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: \ diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 2177083..d639807 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1200,7 +1200,7 @@ struct rs6000_args {int words, fregno, nargs_prototype; }; 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: \ @@ -1211,7 +1211,7 @@ struct rs6000_args {int words, fregno, nargs_prototype; }; /* 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) \ diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 9ca49af..51c221c 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -1281,7 +1281,7 @@ extern struct rtx_def *legitimize_pic_address (); 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; \ @@ -1322,7 +1322,7 @@ extern struct rtx_def *legitimize_pic_address (); 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: \ diff --git a/gcc/config/tahoe/tahoe.h b/gcc/config/tahoe/tahoe.h index aec2c4b..d38f06e 100644 --- a/gcc/config/tahoe/tahoe.h +++ b/gcc/config/tahoe/tahoe.h @@ -647,7 +647,7 @@ enum reg_class {NO_REGS,GENERAL_REGS,FPP_REG,ALL_REGS,LIM_REG_CLASSES}; /* 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; \ diff --git a/gcc/config/vax/vax.h b/gcc/config/vax/vax.h index 459eb55..bc578b3 100644 --- a/gcc/config/vax/vax.h +++ b/gcc/config/vax/vax.h @@ -835,32 +835,39 @@ gen_rtx (PLUS, Pmode, frame, gen_rtx (CONST_INT, VOIDmode, 12)) 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. diff --git a/gcc/loop.c b/gcc/loop.c index 526c6fd..cd01b25 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -299,7 +299,7 @@ init_loop () 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 @@ -4796,7 +4796,7 @@ general_induction_var (x, src_reg, add_val, mult_val) 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 -- 2.7.4