This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: MS/CW-style inline assembly for GCC
- From: dewar at gnat dot com (Robert Dewar)
- To: ian at wasabisystems dot com, lloyd at randombit dot net
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 10 May 2004 12:45:58 -0400 (EDT)
- Subject: Re: MS/CW-style inline assembly for GCC
> Is this really true? What about the simple case of unlimited-
> precision addition on a processor which has a carry flag? Do we
> expect the compiler to be smart enough to turn a loop like
> c = 0;
> for (i = 0; i < len; i++)
> {
> r[i] = a[i] + b[i] + c;
> c = (int) (((long long) a[i] + (long long) b[i]) >> 32);
> }
> into code which uses the "add with carry" instruction?
>
> Sure, there is no algorithmic advantage. But the code in assembler
> will be at least twice as fast.
Not only will the ASM code be twice as fast, but it will be much
clearer than C code.
Of course it is always possibloe to have the compiler have enough
smarts to handle one particular case like this correctly :-)