Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2190

Re: Optimization techniques

From George Neuner <gneuner2@comcast.net>
Newsgroups comp.compilers
Subject Re: Optimization techniques
Date 2019-04-18 04:07 -0400
Organization A noiseless patient Spider
Message-ID <19-04-006@comp.compilers> (permalink)
References <19-04-004@comp.compilers>

Show all headers | View raw


On Wed, 17 Apr 2019 09:42:21 -0400 (EDT), "Rick C. Hodgin"
<rick.c.hodgin@gmail.com> wrote:

>Are there resources someone can point me to for learning more about
>time-honored, long-established, safely applied, optimization
>techniques for a C/C++ like language?

There really aren't many "safe" optimizations you can do before you
run into pointer aliasing problems in C.  Almost any modern compiler
text will cover the bulk of them.

The "Dragon" books by Aho & Sethi (and others) are very good ... I
have a couple of them ... but my favorite intro book is:

  Cooper & Torczon, "Engineering a Compiler", Morgan Kaufman

I have the 1st edition. There is a 2nd edition now.  Very well written
and quite advanced for an introduction.


There are a lot of good intro level compiler texts.  I suggest you
find one that you think is easy to read.  The writing style is as
important to your learning as what information is presented.


>I'm walking the abstract syntax tree and am able to find many kinds of
>optimizations, but I would like to learn some theory or pitfalls of
>various types of optimizations applied.
>
>Thank you in advance.

If you are seriously interested, I'd like to suggest:

  Allen & Kennedy, "Optimizing Compilers for Modern Architectures",
    Academic Press, 2002.

Be aware that this book may be rough sledding.  Most performance
optimizations have their roots in *Fortran* - not C - and this book
deals with high performance Fortran.  Once you understand what they
are doing, it's not terribly hard to figure out how you'd handle it
with C, but it won't be spelled out for you.  This book is graduate
level, and I am not aware of anything similar that is C oriented.


Looking into an existing C compiler to see what it does may be more
confusing than enlightening if you are lacking some prerequisites. You
should understand the "single static assignment" (SSA) code
transformation.  You should know some graph theory - particularly
domination, matching and fusion.  You should understand how to
identify location aliasing (not just by pointers directly, but also
aliasing within memory blocks they refer to).  You need a good
understanding of C's aliasing rules, which take into account not just
data location but also data type(s).

And you need to understand what *shoudn't* be done with floating
point. Floating point operations do not commute, so in general you
can't reorder operations or spill register temporaries without
affecting the result.  Some understanding of numerical analysis is
recommended.


Any modern compiler text should cover SSA.  Alias identification is
touched on in some texts, but I personally have not seen a really
thorough treatment outside of Allen & Kennedy.  If you can interpolate
from the Fortran based discussion, everything you need to know is
there.

C's aliasing rules: you really need to get a copy of the standard
document - they aren't in any other text that I am aware of.

Floating point: if you can get a copy of IEEE-754 (2008), it talks
about what optimizations are possible.  Again, this is not light
reading.  Some further reading is suggested at:
https://en.wikipedia.org/wiki/IEEE_754


Hope this helps.
George
[Great reading list, thanks.  Floating add and multiply commute but
they don't associate.  a+b should be the sams as b+a, but (a+b)+c not
the same as a+(b+c).  -John]

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Optimization techniques "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-04-17 09:42 -0400
  Re: Optimization techniques Hans Aberg <haberg-news@telia.com> - 2019-04-17 18:11 +0200
  Re: Optimization techniques George Neuner <gneuner2@comcast.net> - 2019-04-18 04:07 -0400
    Re: Optimization techniques "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-04-18 11:22 -0400
      Re: Optimization techniques George Neuner <gneuner2@comcast.net> - 2019-04-19 15:48 -0400
    Re: Optimization techniques Hans Aberg <haberg-news@telia.com> - 2019-04-19 00:52 +0200
  Re: Optimization techniques Kaz Kylheku <847-115-0292@kylheku.com> - 2019-04-19 08:49 +0000
    Re: Optimization techniques "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-04-19 11:48 -0400
      Re: Optimization techniques David Brown <david.brown@hesbynett.no> - 2019-04-23 09:38 +0200
    Re: Optimization techniques David Brown <david.brown@hesbynett.no> - 2019-04-23 09:18 +0200
  Re: Optimization techniques Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2019-04-20 00:27 +0200
    Re: Optimization techniques "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-04-19 16:11 -0700
      Re: Optimization techniques Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2019-04-20 19:47 +0200
        Re: Optimization techniques "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-04-24 10:16 -0400
    Re: Optimization techniques George Neuner <gneuner2@comcast.net> - 2019-04-20 18:59 -0400
    Re: Optimization techniques David Brown <david.brown@hesbynett.no> - 2019-04-23 09:43 +0200
      Re: Optimization techniques Martin Ward <martin@gkc.org.uk> - 2019-04-26 20:10 +0100
        Re: Optimization techniques Kaz Kylheku <847-115-0292@kylheku.com> - 2019-04-26 21:11 +0000
        Re: Optimization techniques David Brown <david.brown@hesbynett.no> - 2019-04-28 17:22 +0200
          Re: Optimization techniques Gene Wirchenko <genew@telus.net> - 2019-04-30 18:07 -0700
            Re: Optimization techniques David Brown <david.brown@hesbynett.no> - 2019-05-01 09:03 +0200
    Re: Optimization techniques "Derek M. Jones" <derek@_NOSPAM_knosof.co.uk> - 2019-04-26 13:39 +0100
  Re: Optimization techniques rockbrentwood@gmail.com - 2019-09-26 20:35 -0700

csiph-web