programmer optimizations?

"Afsal C. Majeed" <afsal@genius.tisl.soft.net>
Wed, 28 Dec 1994 11:32:48 GMT

          From comp.compilers

Related articles
programmer optimizations? afsal@genius.tisl.soft.net (Afsal C. Majeed) (1994-12-28)
Re: programmer optimizations? davidm@Rational.COM (1994-12-31)
Re: programmer optimizations? fjh@munta.cs.mu.OZ.AU (1995-01-01)
Re: programmer optimizations? jhowat@lucifer.cs.waikato.ac.nz (1995-01-02)
Re: programmer optimizations? jbuck@Synopsys.COM (1995-01-02)
Re: programmer optimizations? eru@tele.nokia.fi (Erkki Ruohtula) (1995-01-11)
Re: programmer optimizations? conway@munta.cs.mu.OZ.AU (1995-01-05)
[13 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: "Afsal C. Majeed" <afsal@genius.tisl.soft.net>
Keywords: optimize, question, comment
Organization: Software Technology Park, Bangalore
Date: Wed, 28 Dec 1994 11:32:48 GMT

Hi,


We are having small debate here as to the use of some of the
code optimizations by the programmer himself.


e.g.
replacing (n / 4)
by (n >> 2)


replacing if ((i < 0) || (j < 0) || (k < 0))
                by if ((i | j | k) < 0)


as you can well imagine, the list is endless


Since this produces somewhat non portable code, the view is that
such optimizations should be discouraged.


What I want to know is your view on using such "cryptic" optimizations
and whether any of the commercial compilers attempt to do such "target
machine" specific optimizations. The compiler we have here does not
seem to do it.(I am using the compiler XLC which comes with AIX on
IBM RS/6000 machines)


Ciao,
Afsal
[One reason that such optimizations are discouraged is that they're often
wrong. Turning n/4 into n>>2 is only correct if n is unsigned. For the tests
vs. or's, in the POWER it may well be faster to test and use the condition
registers than to fetch all three values each time and store results. I find
that my time is usually much better spent looking for algorithmic improvements,
changing a linear O(n) table search to a binary O(log n) or hashed O(1)
version. -John]
--


Post a followup to this message

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