Re: Optimization Wanted

Michael Meissner <meissner@cygnus.com>
14 Feb 1996 21:32:58 -0500

          From comp.compilers

Related articles
Optimization Wanted rrhauser@ingr.com (Robert R. Hauser) (1996-02-09)
Re: Optimization Wanted meissner@cygnus.com (Michael Meissner) (1996-02-14)
| List of all articles for this month |
From: Michael Meissner <meissner@cygnus.com>
Newsgroups: comp.compilers
Date: 14 Feb 1996 21:32:58 -0500
Organization: Compilers Central
References: 96-02-095
Keywords: C, optimize

| Do any C compilers support the following optimization (below).
|
| (Desc: I want to inline functions without introducing a forced
| branch. See how the optimized codeflow races straight for the
| return statement in 99.99% of the cases. This avoids branching
| reduces the instruction cache consumption, etc, etc,).


GNU C will do it if you reorder your functions such that Func2 occurs
before Func1 and you use -O3 (or -O/-O2 with the -finline-functions
switch or -O/-O2 and add the __inline__ keyword to the Func2
declaration). GNU C will not do it in the order you wrote because GNU
processes a function at a time, and writes out the resulting assembly
language at the end of the function. If the function is inlinable
(see above switches), it will keep the function around in virtual
memory, rather than freeing it up at the end. For best results, you
probably want to use the static keyword on Func2 so that the compiler
will not generate an outline function if it inlines it.


--
Michael Meissner, Cygnus Support (East Coast)
Suite 105, 48 Grove Street, Somerville, MA 02144, USA
meissner@cygnus.com, 617-629-3016 (office), 617-629-3010 (fax)
--


Post a followup to this message

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