avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] efficiency of assigning bits (getting OT)


From: David Brown
Subject: Re: [avr-gcc-list] efficiency of assigning bits (getting OT)
Date: Mon, 21 Mar 2005 15:08:27 +0100

> David Brown wrote:
>
> > I don't know about you, but I consider the optimizer to be part of my
> > tool set, just like the compiler itself.  If the compiler is capable of
> > generating good object code from my preferred form of source code
> > expression, then I don't care whether ANSI says it is "sort of cheating
> > but all right in this case".
>
> I agree.  But, I think you've lost track of the discussion (sub-)topic.
>

Could well be...

> Jim Brain implied that because you can't see evidence of integer
promotions
> in generated code that the C language definition does not require them.
My
> point in my reply was that this is not true.  Jim's reply to that suggests
> that he thinks my position is mere pedantry.  During discussions of
> programming language definitions I have found that an accusation of
pedantry
> is usually a signal to give up the thread.  You will have to decide for
> youself who is right and whether or not you care.
>
> > ... There are times when C's integer promotion is a PITA ...
>
> Which is why I personally insist on a full understanding.

Yes, an understanding is necessary - both of the rules of C, and of the
idiosyncracies of your compiler/architecture.

>
> > ... but for simple bit manipulation, all the compilers I have
> > used on 8-bit architectures have been smart enough to
> > generate sensible code.
>
> But not all 8-bit compilers in the world.
>

Agreed - for some, casts *are* necessary.  That's one of the reasons for
using bit macros such as Dave Hansen's, where messy details like that are
hidden in a single header file.  You do your testing and examination of the
generated assembly once, and then re-use the header file.  The middle of
"user" code is the wrong place to have such casts (when it can be avoided).

David

> > Unnecessarily sprinkling the code
> > with (unsigned char) casts does nothing for the code efficiency, or code
> > portability, and detracts from code readability - so don't do it.
>
> Right - with emphasis on the first word of your sentence.
>
> Graham.
>
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]