Re: Optimization techniques

David Brown <david.brown@hesbynett.no>
Tue, 23 Apr 2019 09:43:17 +0200

          From comp.compilers

Related articles
[8 earlier articles]
Re: Optimization techniques DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-04-20)
Re: Optimization techniques rick.c.hodgin@gmail.com (Rick C. Hodgin) (2019-04-19)
Re: Optimization techniques DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-04-20)
Re: Optimization techniques gneuner2@comcast.net (George Neuner) (2019-04-20)
Re: Optimization techniques david.brown@hesbynett.no (David Brown) (2019-04-23)
Re: Optimization techniques david.brown@hesbynett.no (David Brown) (2019-04-23)
Re: Optimization techniques david.brown@hesbynett.no (David Brown) (2019-04-23)
Re: Optimization techniques rick.c.hodgin@gmail.com (Rick C. Hodgin) (2019-04-24)
Re: Optimization techniques martin@gkc.org.uk (Martin Ward) (2019-04-25)
Re: Optimization techniques david.brown@hesbynett.no (David Brown) (2019-04-25)
Re: Optimization techniques 847-115-0292@kylheku.com (Kaz Kylheku) (2019-04-25)
Re: Optimization techniques 847-115-0292@kylheku.com (Kaz Kylheku) (2019-04-26)
Re: Optimization techniques 847-115-0292@kylheku.com (Kaz Kylheku) (2019-04-26)
[20 later articles]
| List of all articles for this month |
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.compilers
Date: Tue, 23 Apr 2019 09:43:17 +0200
Organization: A noiseless patient Spider
References: 19-04-004 19-04-012
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="73393"; mail-complaints-to="abuse@iecc.com"
Keywords: C, optimize
Posted-Date: 24 Apr 2019 10:20:51 EDT
In-Reply-To: 19-04-012
Content-Language: en-GB

On 20/04/2019 00:27, Hans-Peter Diettrich wrote:
> Am 17.04.2019 um 15:42 schrieb Rick C. Hodgin:
>> 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?
>
> I'm always a bit sceptic when C/C++ and "safe" occur in the same
> sentence.


C and C++ can certainly be used safely. But the programmer needs to
know what they are doing, and want to write safe code.


> AFAIR a C compiler is allowed to ignore parentheses when
> reordering expressions, what can lead to numeric instabilities.


For floating point operations, such re-arrangements could lead to
numeric instabilities - and they are not allowed.


For signed integer operations, brackets that affect calculations can't
be removed. The compiler can't change "(a * b) / c" into "a * (b / c)".
  But mathematical identities such as associativity and commutativity are
valid because signed integer overflow does not happen - thus "a * (b +
c)" can be changed to "(a * b) + (a * c)".


And of course the evaluation of sub-expressions can be done in any order.


Post a followup to this message

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