This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
genattrtab resource usage reduction + insn-attrtab on diet
- To: rth at cygnus dot com, patches at x86-64 dot org, gcc-patches at gcc dot gnu dot org
- Subject: genattrtab resource usage reduction + insn-attrtab on diet
- From: Jan Hubicka <jh at suse dot cz>
- Date: Fri, 15 Dec 2000 14:01:22 +0100
Hi
This is updated version of my "insn-attrtab on diet" patch that makes simplifications
on the temporary obstack.
This patch cuts insn-attrtab to roughtly 700Kb on x86_64 port and memory usage
of genattrtab to 45MB. (originally 2MB and 140MB).
For i386 it reduces insn-attrtab from 1.3MB to 590KB and memory usage from 100MB
to 30MB.
I've measured no performance regressions with new insn-attrtab (after my
insn_extract caching that went in some time ago) and genattrtab still seems to
run in resonable time (probably faster than the original).
Honza
Fri Dec 15 14:00:45 MET 2000 Jan Hubicka <jh@suse.cz>
* genattrtab (attr_rtx_cost): New function.
(simplify_test_exp): Avoid overactive inlining; use temporary
obstacks for tests.
Index: gcc/gcc/genattrtab.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/genattrtab.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 genattrtab.c
*** gcc/gcc/genattrtab.c 2000/11/27 18:25:42 1.3
--- gcc/gcc/genattrtab.c 2000/12/15 12:55:11
*************** static rtx attr_eq PARAMS ((const char
*** 460,465 ****
--- 460,466 ----
static const char *attr_numeral PARAMS ((int));
static int attr_equal_p PARAMS ((rtx, rtx));
static rtx attr_copy_rtx PARAMS ((rtx));
+ static int attr_rtx_cost PARAMS ((rtx));
#define oballoc(size) obstack_alloc (hash_obstack, size)
*************** simplify_or_tree (exp, pterm, insn_code,
*** 3151,3156 ****
--- 3152,3204 ----
return exp;
}
+ /* Compute approximate cost of the expression. Used to decide whether
+ expression is cheap enought for inline. */
+ static int
+ attr_rtx_cost (x)
+ rtx x;
+ {
+ int cost = 0;
+ enum rtx_code code;
+ if (!x)
+ return 0;
+ code = GET_CODE (x);
+ switch (code)
+ {
+ case MATCH_OPERAND:
+ if (XSTR (x, 1)[0])
+ return 10;
+ else
+ return 0;
+ case EQ_ATTR:
+ /* Alternatives don't result into function call. */
+ if (!strcmp (XSTR (x, 0), "alternative"))
+ return 0;
+ else
+ return 5;
+ default:
+ {
+ int i, j;
+ const char *fmt = GET_RTX_FORMAT (code);
+ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+ {
+ switch (fmt[i])
+ {
+ case 'V':
+ case 'E':
+ for (j = 0; j < XVECLEN (x, i); j++)
+ cost += attr_rtx_cost (XVECEXP (x, i, j));
+ break;
+ case 'e':
+ cost += attr_rtx_cost (XEXP (x, i));
+ break;
+ }
+ }
+ }
+ break;
+ }
+ return cost;
+ }
/* Given an expression, see if it can be simplified for a particular insn
code based on the values of other attributes being tested. This can
*************** simplify_test_exp (exp, insn_code, insn_
*** 3407,3413 ****
for (av = attr->first_value; av; av = av->next)
for (ie = av->first_insn; ie; ie = ie->next)
if (ie->insn_code == insn_code)
! return evaluate_eq_attr (exp, av->value, insn_code, insn_index);
break;
default:
--- 3455,3470 ----
for (av = attr->first_value; av; av = av->next)
for (ie = av->first_insn; ie; ie = ie->next)
if (ie->insn_code == insn_code)
! {
! rtx x;
! struct obstack *old = rtl_obstack;
! rtl_obstack = temp_obstack;
! x = evaluate_eq_attr (exp, av->value, insn_code, insn_index);
! x = SIMPLIFY_TEST_EXP (x, insn_code, insn_index);
! rtl_obstack = old;
! if (attr_rtx_cost(x) < 20)
! return attr_copy_rtx (x);
! }
break;
default: