[PATCH] Speed up CONSTANT_P (1.3% on bootstrap)
Bonzini
bonzini@gnu.org
Sat Jan 31 13:39:00 GMT 2004
This one introduces a new RTL class C for constant objects, thus speeding up
CONSTANT_P. Then it goes over all places that were checking the class
to be 'o' and converts it to use OBJECT_P, a new macro.
user time w/o patch: 17m39s
user time with patch: 17m25s
system time in both cases: 0m48s
That's 1.3% on a bootstrap.
Ok for mainline?
Paolo
2004-01-31 Paolo Bonzini <bonzini@gnu.org>
* alias.c (find_symbolic_term): Use OBJECT_P.
* combine.c (find_split_point, subst,
combine_simplify_rtx): Likewise.
* reload.c (find_reloads): Likewise.
* reload1.c (gen_reload): Likewise.
* cse.c (fold_rtx): Treat class 'C' as 'o'.
* ra-debug.c (ra_print_rtx): Likewise.
* rtl.def (CONST_INT, CONST_DOUBLE, CONST,
LABEL_REF, SYMBOL_REF, HIGH): Move to class
'C'.
* rtl.h (OBJECT_P): New macro.
(CONSTANT_P): Check class of rtx first.
* rtlanal.c (commutative_operand_precedence):
* config/ia64/ia64.h (PREFERRED_RELOAD_CLASS):
Use OBJECT_P.
* config/pa/pa.c (hppa_legitimize_address):
Use OBJECT_P.
-------------- next part --------------
Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.212
diff -u -r1.212 alias.c
--- alias.c 22 Jan 2004 11:35:58 -0000 1.212
+++ alias.c 31 Jan 2004 10:18:17 -0000
@@ -1263,7 +1263,7 @@
code = GET_CODE (x);
if (code == SYMBOL_REF || code == LABEL_REF)
return x;
- if (GET_RTX_CLASS (code) == 'o')
+ if (OBJECT_P (x))
return 0;
fmt = GET_RTX_FORMAT (code);
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.406
diff -u -r1.406 combine.c
--- combine.c 31 Jan 2004 09:21:13 -0000 1.406
+++ combine.c 31 Jan 2004 10:18:18 -0000
@@ -2949,10 +2949,9 @@
This will occur on machines that just support REG + CONST
and have a constant moved through some previous computation. */
- else if (GET_RTX_CLASS (GET_CODE (XEXP (XEXP (x, 0), 0))) != 'o'
+ else if (!OBJECT_P (XEXP (XEXP (x, 0), 0))
&& ! (GET_CODE (XEXP (XEXP (x, 0), 0)) == SUBREG
- && (GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (XEXP (x, 0), 0))))
- == 'o')))
+ && OBJECT_P (SUBREG_REG (XEXP (XEXP (x, 0), 0)))))
return &XEXP (XEXP (x, 0), 0);
}
break;
@@ -2967,9 +2966,9 @@
if (SET_DEST (x) == cc0_rtx
&& GET_CODE (SET_SRC (x)) != COMPARE
&& GET_CODE (SET_SRC (x)) != ZERO_EXTRACT
- && GET_RTX_CLASS (GET_CODE (SET_SRC (x))) != 'o'
+ && !OBJECT_P (SET_SRC (x))
&& ! (GET_CODE (SET_SRC (x)) == SUBREG
- && GET_RTX_CLASS (GET_CODE (SUBREG_REG (SET_SRC (x)))) == 'o'))
+ && OBJECT_P (SUBREG_REG (SET_SRC (x)))))
return &SET_SRC (x);
#endif
@@ -3164,10 +3163,9 @@
|| GET_RTX_CLASS (GET_CODE (SET_SRC (x))) == 'c'
|| GET_RTX_CLASS (GET_CODE (SET_SRC (x))) == '<')
&& CONSTANT_P (XEXP (SET_SRC (x), 1))
- && (GET_RTX_CLASS (GET_CODE (XEXP (SET_SRC (x), 0))) == 'o'
+ && (OBJECT_P (XEXP (SET_SRC (x), 0))
|| (GET_CODE (XEXP (SET_SRC (x), 0)) == SUBREG
- && (GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (SET_SRC (x), 0))))
- == 'o'))))
+ && OBJECT_P (SUBREG_REG (XEXP (SET_SRC (x), 0))))))
return &XEXP (SET_SRC (x), 1);
/* Finally, see if this is a simple operation with its first operand
@@ -3303,7 +3301,7 @@
/* If this is an object, we are done unless it is a MEM or LO_SUM, both
of which may contain things that can be combined. */
- if (code != MEM && code != LO_SUM && GET_RTX_CLASS (code) == 'o')
+ if (code != MEM && code != LO_SUM && OBJECT_P (x))
return x;
/* It is possible to have a subexpression appear twice in the insn.
@@ -3608,19 +3606,16 @@
if (((GET_RTX_CLASS (code) == '2' || GET_RTX_CLASS (code) == 'c'
|| GET_RTX_CLASS (code) == '<')
- && ((GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) != 'o'
+ && ((!OBJECT_P (XEXP (x, 0))
&& ! (GET_CODE (XEXP (x, 0)) == SUBREG
- && (GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (x, 0))))
- == 'o')))
- || (GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) != 'o'
+ && OBJECT_P (SUBREG_REG (XEXP (x, 0)))))
+ || (!OBJECT_P (XEXP (x, 1))
&& ! (GET_CODE (XEXP (x, 1)) == SUBREG
- && (GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (x, 1))))
- == 'o')))))
+ && OBJECT_P (SUBREG_REG (XEXP (x, 1)))))))
|| (GET_RTX_CLASS (code) == '1'
- && ((GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) != 'o'
+ && (!OBJECT_P (XEXP (x, 0))
&& ! (GET_CODE (XEXP (x, 0)) == SUBREG
- && (GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (x, 0))))
- == 'o'))))))
+ && OBJECT_P (SUBREG_REG (XEXP (x, 0)))))))
{
rtx cond, true_rtx, false_rtx;
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.284
diff -u -r1.284 cse.c
--- cse.c 31 Jan 2004 09:21:18 -0000 1.284
+++ cse.c 31 Jan 2004 10:18:19 -0000
@@ -4246,6 +4246,7 @@
break;
case 'o':
+ case 'C':
/* (lo_sum (high X) X) is simply X. */
if (code == LO_SUM && const_arg0 != 0
&& GET_CODE (const_arg0) == HIGH
Index: ra-debug.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-debug.c,v
retrieving revision 1.14
diff -u -r1.14 ra-debug.c
--- ra-debug.c 11 Dec 2003 00:20:46 -0000 1.14
+++ ra-debug.c 31 Jan 2004 10:18:20 -0000
@@ -195,7 +195,7 @@
}
}
-/* Print rtx X, which represents an object (class 'o' or some constructs
+/* Print rtx X, which represents an object (class 'o', 'C', or some constructs
of class 'x' (e.g. subreg)), to FILE.
(reg XX) rtl is represented as "pXX", of XX was a pseudo,
as "name" it name is the nonnull hardreg name, or as "hXX", if XX
@@ -497,7 +497,7 @@
ra_print_rtx_2op (file, x);
else if (class == '3' || class == 'b')
ra_print_rtx_3op (file, x);
- else if (class == 'o')
+ else if (class == 'o' || class == 'C')
ra_print_rtx_object (file, x);
else
print_inline_rtx (file, x, 0);
Index: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.233
diff -u -r1.233 reload.c
--- reload.c 30 Jan 2004 20:42:24 -0000 1.233
+++ reload.c 31 Jan 2004 10:18:21 -0000
@@ -2699,7 +2699,7 @@
/* If we now have a simple operand where we used to have a
PLUS or MULT, re-recognize and try again. */
- if ((GET_RTX_CLASS (GET_CODE (*recog_data.operand_loc[i])) == 'o'
+ if ((OBJECT_P (*recog_data.operand_loc[i])
|| GET_CODE (*recog_data.operand_loc[i]) == SUBREG)
&& (GET_CODE (recog_data.operand[i]) == MULT
|| GET_CODE (recog_data.operand[i]) == PLUS))
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.422
diff -u -r1.422 reload1.c
--- reload1.c 31 Jan 2004 08:02:48 -0000 1.422
+++ reload1.c 31 Jan 2004 10:18:22 -0000
@@ -7475,7 +7475,7 @@
#endif
/* If IN is a simple operand, use gen_move_insn. */
- else if (GET_RTX_CLASS (GET_CODE (in)) == 'o' || GET_CODE (in) == SUBREG)
+ else if (OBJECT_P (in) || GET_CODE (in) == SUBREG)
emit_insn (gen_move_insn (out, in));
#ifdef HAVE_reload_load_address
Index: rtl.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.def,v
retrieving revision 1.78
diff -u -r1.78 rtl.def
--- rtl.def 22 Jan 2004 00:15:25 -0000 1.78
+++ rtl.def 31 Jan 2004 10:18:22 -0000
@@ -46,18 +46,19 @@
4. The class of the rtx. These are stored in rtx_class and are accessed
via the GET_RTX_CLASS macro. They are defined as follows:
- "o" an rtx code that can be used to represent an object (e.g, REG, MEM)
- "<" an rtx code for a comparison (e.g, EQ, NE, LT)
- "1" an rtx code for a unary arithmetic expression (e.g, NEG, NOT)
- "c" an rtx code for a commutative binary operation (e.g,, PLUS, MULT)
- "3" an rtx code for a non-bitfield three input operation (IF_THEN_ELSE)
- "2" an rtx code for a non-commutative binary operation (e.g., MINUS, DIV)
- "b" an rtx code for a bit-field operation (ZERO_EXTRACT, SIGN_EXTRACT)
- "i" an rtx code for a machine insn (INSN, JUMP_INSN, CALL_INSN)
- "m" an rtx code for something that matches in insns (e.g, MATCH_DUP)
- "g" an rtx code for grouping insns together (e.g, GROUP_PARALLEL)
- "a" an rtx code for autoincrement addressing modes (e.g. POST_DEC)
- "x" everything else
+ 'C' an rtx code that can be used to represent a constant object (e.g, CONST_INT)
+ 'o' an rtx code that can be used to represent an object (e.g, REG, MEM)
+ '<' an rtx code for a comparison (e.g, EQ, NE, LT)
+ '1' an rtx code for a unary arithmetic expression (e.g, NEG, NOT)
+ 'c' an rtx code for a commutative binary operation (e.g,, PLUS, MULT)
+ '3' an rtx code for a non-bitfield three input operation (IF_THEN_ELSE)
+ '2' an rtx code for a non-commutative binary operation (e.g., MINUS, DIV)
+ 'b' an rtx code for a bit-field operation (ZERO_EXTRACT, SIGN_EXTRACT)
+ 'i' an rtx code for a machine insn (INSN, JUMP_INSN, CALL_INSN)
+ 'm' an rtx code for something that matches in insns (e.g, MATCH_DUP)
+ 'g' an rtx code for grouping insns together (e.g, GROUP_PARALLEL)
+ 'a' an rtx code for autoincrement addressing modes (e.g. POST_DEC)
+ 'x' everything else
*/
@@ -781,12 +782,12 @@
---------------------------------------------------------------------- */
/* numeric integer constant */
-DEF_RTL_EXPR(CONST_INT, "const_int", "w", 'o')
+DEF_RTL_EXPR(CONST_INT, "const_int", "w", 'C')
/* numeric floating point constant.
Operands hold the value. They are all 'w' and there may be from 2 to 6;
see real.h. */
-DEF_RTL_EXPR(CONST_DOUBLE, "const_double", CONST_DOUBLE_FORMAT, 'o')
+DEF_RTL_EXPR(CONST_DOUBLE, "const_double", CONST_DOUBLE_FORMAT, 'C')
/* Describes a vector constant. */
DEF_RTL_EXPR(CONST_VECTOR, "const_vector", "E", 'x')
@@ -798,7 +799,7 @@
(such as the sum of a SYMBOL_REF and a CONST_INT) so that it will be
recognized as a constant operand rather than by arithmetic instructions. */
-DEF_RTL_EXPR(CONST, "const", "e", 'o')
+DEF_RTL_EXPR(CONST, "const", "e", 'C')
/* program counter. Ordinary jumps are represented
by a SET whose first operand is (PC). */
@@ -861,14 +862,14 @@
The operand is a CODE_LABEL found in the insn chain.
The unprinted fields 1 and 2 are used in flow.c for the
LABEL_NEXTREF and CONTAINING_INSN. */
-DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00", 'o')
+DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00", 'C')
/* Reference to a named label:
Operand 0: label name
Operand 1: flags (see SYMBOL_FLAG_* in rtl.h)
Operand 2: tree from which this symbol is derived, or null.
This is either a DECL node, or some kind of constant. */
-DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s00", 'o')
+DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s00", 'C')
/* The condition code register is represented, in our imagination,
as a register holding a value that can be compared to zero.
@@ -1103,7 +1104,7 @@
/* For RISC machines. These save memory when splitting insns. */
/* HIGH are the high-order bits of a constant expression. */
-DEF_RTL_EXPR(HIGH, "high", "e", 'o')
+DEF_RTL_EXPR(HIGH, "high", "e", 'C')
/* LO_SUM is the sum of a register and the low-order bits
of a constant expression. */
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.453
diff -u -r1.453 rtl.h
--- rtl.h 31 Jan 2004 09:21:18 -0000 1.453
+++ rtl.h 31 Jan 2004 10:18:22 -0000
@@ -291,11 +291,14 @@
/* 1 if X is a constant value that is an integer. */
#define CONSTANT_P(X) \
- (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
- || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE \
- || GET_CODE (X) == CONST || GET_CODE (X) == HIGH \
+ (GET_RTX_CLASS (GET_CODE (X)) == 'C' \
|| GET_CODE (X) == CONST_VECTOR \
|| GET_CODE (X) == CONSTANT_P_RTX)
+
+/* 1 if X can be used to represent an object. */
+#define OBJECT_P(X) \
+ (GET_RTX_CLASS (GET_CODE (X)) == 'C' \
+ || GET_RTX_CLASS (GET_CODE (X)) == 'o')
/* General accessor macros for accessing the fields of an rtx. */
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.173
diff -u -r1.173 rtlanal.c
--- rtlanal.c 22 Jan 2004 12:44:54 -0000 1.173
+++ rtlanal.c 31 Jan 2004 10:18:23 -0000
@@ -3036,7 +3045,7 @@
/* SUBREGs of objects should come second. */
if (GET_CODE (op) == SUBREG
- && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op))) == 'o')
+ && OBJECT_P (SUBREG_REG (op)))
return -2;
/* If only one operand is a `neg', `not',
@@ -3049,7 +3058,7 @@
/* Complex expressions should be the first, so decrease priority
of objects. */
- if (GET_RTX_CLASS (GET_CODE (op)) == 'o')
+ if (OBJECT_P (op))
return -1;
return 0;
}
Index: config/ia64/ia64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.h,v
retrieving revision 1.165
diff -u -r1.165 ia64.h
--- config/ia64/ia64.h 30 Jan 2004 23:16:06 -0000 1.165
+++ config/ia64/ia64.h 31 Jan 2004 10:18:25 -0000
@@ -1009,7 +1009,7 @@
#define PREFERRED_RELOAD_CLASS(X, CLASS) \
(CLASS == FR_REGS && GET_CODE (X) == MEM && MEM_VOLATILE_P (X) ? NO_REGS \
: CLASS == FR_REGS && GET_CODE (X) == CONST_DOUBLE ? NO_REGS \
- : GET_RTX_CLASS (GET_CODE (X)) != 'o' \
+ : !OBJECT_P (X) \
&& (CLASS == AR_M_REGS || CLASS == AR_I_REGS) ? NO_REGS \
: CLASS)
Index: config/pa/pa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.c,v
retrieving revision 1.240
diff -u -r1.240 pa.c
--- config/pa/pa.c 30 Jan 2004 23:16:15 -0000 1.240
+++ config/pa/pa.c 31 Jan 2004 10:18:26 -0000
@@ -1100,7 +1100,7 @@
if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 0)) == MULT
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& shadd_constant_p (INTVAL (XEXP (XEXP (x, 0), 1)))
- && (GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) == 'o'
+ && (OBJECT_P (XEXP (x, 1))
|| GET_CODE (XEXP (x, 1)) == SUBREG)
&& GET_CODE (XEXP (x, 1)) != CONST)
{
More information about the Gcc-patches
mailing list