This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Strict aliasing affects glibc 2.1.1 as well as Linux


On Tue, 20 Jul 1999, Mark Mitchell wrote:

> You are right that there is high-performance code that will need to
> violate the type-system.  I would guess that most such code is a
> relatively small proportion of its applications; for example, in some
> complex nuclear simulation, a few inner loops somewhere, or, in the
> Linux kernel, on a few hot paths.
> 
> Your example of copying around floating-point values using integer
> operations (perhaps while twiddling sign bits or some such) is a good
> one.  But, that kind of code is not only application-specific, but
> processor specific; the kind of thing that, even today, could
> reasonably be written in assembly code.  After all, if cycles really
> count, and you're talking about small loops, then it still makes sense
> to right them by hand, if you really know what you're doing.  That
> will probably always be true.

I've written lots of code that violates the typesystem when doing
software rasterization, bitblits and other real-time graphics stuff. You
usually need to write to video memory in 32 bit writes, or you get abysmal
performance. 

You say this is processor specific code and should be written in asm. I
don't agree with that, I usually code it pretty fast and portable in C.
It *is* portable (if you take care of integer sizes and byte-order) to
real 'normal' machines (ie. almost all). Sometimes i have to write x86
asm to get some extra performance, but it feels good to leave the C
version conditionally compiled on non x86 platforms.

/ Alex



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]