Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Optimizing C code for speed

Author: Bruce Moreland

Date: 17:50:32 01/01/03

Go up one level in this thread


On January 01, 2003 at 19:28:01, Uri Blass wrote:

>I agree.
>
>I think that in cases that you care about speed then it is more important to
>care first about speed of the logic and not about speed of C.
>
>It means that if you have a condition A&&B and it is usually wrong because of B
>then it may be better to change it to B&&A.
>
>It is something that the compiler cannot do by itself because the compiler is
>not going to take the risk that B can cause a crash when A is false and the
>compiler has no way to know that B cannot cause a crash.

C is defined such that if you have (A && B), A will be evaluated first always.

The case where you get undefined execution order is this one:

  func(A(), B());

The order in which A() and B() are called is undefined.

bruce



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.