This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Reduce effective sizeof(struct basic_block) 108 -> 80
- From: Arend Bayer <arend dot bayer at web dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 7 Feb 2005 16:24:27 +0100 (CET)
- Subject: Reduce effective sizeof(struct basic_block) 108 -> 80
This extremely simple patch gives a 3% speedup for insn-attrtab.i; for
the whole of cc1 still 1% (i.e. s.th. around 0.5% outside of
insn-attrtab.i); and around 0.1% for some other testcases (my own
project; a couple of the big C++-files from the various compile time
PRs). This was on a Pentium-M.
The frequence is always between 0 and 10000, so a short int is enough to
store it; please enlighten me if I need to use a different type to
ensure this for all platforms.
Also, for flags, a bitfield of size 9 is enough. This is interesting,
because it brings the size of struct basic_block_def down to a multiplie
of 16 (i.e. 80) on 32-bit platforms. This, plus adding it's size to the
list of special sizes in the page-based GGC makes traversing basic block
lists much more cache-friendly.
The big speedup of insn-attrtab.i is mostly due to compute_transp(), which
is not so surprising as it is doing a lot of FOR_EACH_BB().
Testes with make bootstrap and make check with no regression for all
default languages on i686-pc-linux-gnu; plus testing that applying the
patch after stage 1 of bootstrap does not lead to comparison failures.
Arend
2005-02-07 Arend Bayer <arend.bayer@web.de>
* basic-block.h (struct basic_block_def): Change frequency to
short int, and flags to a bitfield of size 9.
* ggc-page.c (extra_order_size_tab): Add sizeof(struct
basic_block_def).
Index: basic-block.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.237
diff -u -p -c -r1.237 basic-block.h
*** basic-block.h 1 Feb 2005 10:03:02 -0000 1.237
--- basic-block.h 7 Feb 2005 15:06:20 -0000
*************** struct basic_block_def GTY((chain_next (
*** 257,266 ****
int loop_depth;
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
! int frequency;
/* Various flags. See BB_* below. */
! int flags;
};
typedef struct basic_block_def *basic_block;
--- 257,266 ----
int loop_depth;
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
! short int frequency;
/* Various flags. See BB_* below. */
! unsigned int flags : 9;
};
typedef struct basic_block_def *basic_block;
Index: ggc-page.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.98
diff -u -p -c -r1.98 ggc-page.c
*** ggc-page.c 18 Jan 2005 11:36:14 -0000 1.98
--- ggc-page.c 7 Feb 2005 15:06:20 -0000
*************** static const size_t extra_order_size_tab
*** 188,193 ****
--- 188,194 ----
sizeof (struct stmt_ann_d),
sizeof (struct tree_decl),
sizeof (struct tree_list),
+ sizeof (struct basic_block_def),
TREE_EXP_SIZE (2),
RTL_SIZE (2), /* MEM, PLUS, etc. */
RTL_SIZE (9), /* INSN */