This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

struct-reorg optimization


This patch implements structure peeling, that is one of struct-reorg
optimizations developed on struct-reorg-branch. A structure type can be
peeled into separate fields, or groups of them, according to profile
information, or  deliberately. The gain is to utilize spatial locality,
when, for example, one of the fields is sequentially accessed through
array elements. Then separating this field from others allows to make
separation in array allocation, and thus release cache from irrelevant
data fetched with other fields.

The full description of this optimization is at the beginning of
struct-reorg.c (attached below).

The optimization is global, both types of accesses - through pointers
and  array refs - are handled. When allocation is made through malloc,
it is replaced by allocations of peeled structures. Only build-in malloc
is supported right now, but it can be easily extended.

In this patch, the decision how to peel is made by frequency based model,
where frequency of field accesses can be calculated through profiling or
statically predicted as with -fbranch-probabilitied flag. When there is
no such info, structure gets completely peeled. (The struct-reorg-branch
contains much more accurate model which is based on the calculation of
distance between accesses, but it's also heavier.)
The -fipa-struct-reorg flag activates this optimization.

The patch makes strong use of ipa-type-escape analysis, that provide
safety of this optimization. Also changes required for ipa-type-escape
to support POITER_PLUS_EXPR are part of this patch.

With this patch:
      - two structures f1_neuron and  xyz got peeled in 179. art ,
      +44% w/o profiling and +33% with profiling

      - the structures  NEXT_MOVE got peeled, the structure CHESS_POSITION
      can be peeled, but interfere with another optimization that
      generated BIT_FIELD_REFs in 186.crafty; many other structures escape,
      no influence on performance

      - the structure MMNODE got peeled; many others escape,
      no influence on performance

Bootstraped and tested (except  fortran) on ppc .

:ADDPATCH ipa ssa:

Ok for mainline?

2007-07-09  Olga Golovanevsky  <olga@il.ibm.com>

      * struct-reorg.c, struct-reorg.h: New files.
      * ipa-type-escape.h: Expose function
      is_array_access_through_pointer_and_index.
      * ipa-type-escape.c
      (is_array_access_through_pointer_and_index):
      Add three new parameters. Add support of
      POINTER_PLUS_EXPR code.
      * tree.h: Add pass_ipa_struct_reorg.
      * common.opt: Add ipa-struct-reorg flag.
      * Makefile.in: Add strcut-reorg.o compilation.
      * passes.c: Add pass pass_ipa_struct_reorg.

(See attached file: struct-reorg.txt)(See attached file: struct-reorg.c)
(See attached file: struct-reorg.h)

Attachment: struct-reorg.txt
Description: Text document

Attachment: struct-reorg.c
Description: Binary data

Attachment: struct-reorg.h
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]