Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: assembly--not really that fast

Author: Robert Hyatt

Date: 07:43:26 01/14/02

Go up one level in this thread


On January 13, 2002 at 10:46:27, David Rasmussen wrote:

>On January 13, 2002 at 10:22:52, Robert Hyatt wrote:
>
>>
>>
>>I've always sais that the people that say that C is just as fast as assembly
>>simply don't know "how to do it right".  Cray has the _best_ optimizing
>>FORTRAN compiler on the planet, _bar_ _none_.  Yet the assembly version of
>>Cray Blitz was roughly 5x faster when we started and even at the end of the
>>project it was still 3x faster.
>>
>>There are several reasons:
>>
>>1.  You know more about the program than the compiler.  No bounds-checking
>>on "switch" type statements is necessary.
>>
>>2.  you know whether a value can be positive, negative, or both.  The
>>compiler can't.
>>
>>3.  you know whether a value can exceed (say) 127 or not.  The compiler can't.
>>
>>4.  You know how many registers the CPU has and can design code around that,
>>while C doesn't give you such control.
>>
>>5.  you know exactly which registers procedure "x" will destroy, so you don't
>>have to save everything before calling it.  If you are careful, you don't have
>>to save _anything_.
>>
>
>This last point is not valid I think. The compiler also knows which registers
>procedure "x" destroys. Or it can, anyway.
>
>I've always thought that features should be added to C/C++ so that the
>programmer is able to tell the compiler more about the types, values and
>functions, and that this information could and should be used for optimizing and
>debugging purposes.
>
>For example, I could tell the compiler that my Square type (which is an int), is
>always 0-63. If it can use this information for optimizing, good. And in debug
>builds, it could check whether it is satisfied. I know assert can do this last
>thing, but the compiler doesnt use the information that one calls assert with.
>There should be keywords "invariant" and "precondition" and "postcondition", I
>think. That would be really cool. MSVC++ have such an extension, sort of. But I
>don't know if it works well or not. I haven
>t tried using it.
>
>/David


You can do that with enumerated types.  But the compiler _still_ has to check
the bounds on such types when needed, to avoid a "bad assumption"...



This page took 0.01 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.