Automatic optimizations (profile-feedback) (Ariel Faigon)
Tue, 12 Dec 89 16:52:29 EET

          From comp.compilers

Related articles
Automatic optimizations (profile-feedback) (1989-12-12)
Re: Automatic optimizations (profile-feedback) soi! (1989-12-17)
| List of all articles for this month |

Date: Tue, 12 Dec 89 16:52:29 EET
From: (Ariel Faigon)
Organization: National Semiconductor, Israel (Home of the 32532)

In a recent article, Liam Quin <> wrote:
| Subject: Re: dynamic optimization -- summary
| I asked whether there were any compilers (esp. on Unix) which took into
| account statistics gathered from profiling runs when optimising programs.

National Semiconductor's GNX family of compilers, Version 4.0, does it:
Version 4.0 is scheduled for customer-release on February but we've already
used it extensively for about a year now, in house.

The technique was presented in IEEE ICCD (International Conference on
Computer Design) 1988, By Chaim Bendelac & Gadi Erlich.
The title of the presentation was:
"CTP - A family of Optimizing Compilers for the NS32532 Microprocessor"
  Computer society order no. 872
  Library of congress no. 88-82095
  IEEE catalog no. 88CH2643-5
  ISBN 0-8186-0872-2
The following is an excerpt from the manual;

      The Profiling-information can be used for automatic optimization. i.e.
      the GNX optimizer can utilize it in order to perform better optimizations
      like register-allocation and branch-prediction without user intervention.

Each basic-block is assigned a value called 'exec_odds' (for execution-odds)
to estimate the odds that this basic-block will be executed relatively
to other basic-blocks. In the default-mode operation of the optimizer,
'exec_odds' is estimated by few heuristics (e.g. an inner loop is given
more odds than an external one, each 'case' in a 'switch' statement is
given the same odds etc.). When a special optimization option is used
(and a profiling-information file exists from previous executions and
some sanity checks verify that it is indeed of the same program that was
previously compiled for profile-feedback), the 'exec_odds' values are
calculated from that information.

The sad news is that except in very rare cases, or some contrived ones,
(e.g. a program that its inner loop is almost never executed), the
automatic profile-feedback adds near to nothing to the optimizations
that are normally performed by the optimizer (according to the heuristics).

Yet, it may be that one wants to tune his program for very specific conditions
(e.g. a very specific set of inputs which one foresees to be the most
frequent in some environment) - then, this technique may prove worthwhile.

And to the good news: We use the same profile-information for conventional
profiling by marking source-lines with their respective number-of-executions.
This, proved to be very helpful in studying runtime behavior of programs
especially for white-box testing: detecting areas of low coverage
(e.g. basic-blocks -> lines that are seldom/never executed).
Ariel Faigon, CTP group, NSTA
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Hertzlia 46104, Israel Tel. (972)52-522312 @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.