[Top][All Lists]
[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
>
- Re: [avr-gcc-list] efficiency of assigning bits, (continued)
- Re: [avr-gcc-list] efficiency of assigning bits, Royce & Sharal Pereira, 2005/03/18
- Re: [avr-gcc-list] efficiency of assigning bits, E. Weddington, 2005/03/18
- Re: [avr-gcc-list] efficiency of assigning bits, Jim Brain, 2005/03/18
- Re: [avr-gcc-list] efficiency of assigning bits, Graham Davies, 2005/03/19
- Re: [avr-gcc-list] efficiency of assigning bits, Jim Brain, 2005/03/19
- Re: [avr-gcc-list] efficiency of assigning bits, David Brown, 2005/03/21
- Re: [avr-gcc-list] efficiency of assigning bits (getting OT), Graham Davies, 2005/03/21
- Re: [avr-gcc-list] efficiency of assigning bits (getting OT),
David Brown <=
- Re: [avr-gcc-list] efficiency of assigning bits (getting OT), Jim Brain, 2005/03/21
- Re: [avr-gcc-list] efficiency of assigning bits (getting OT), E. Weddington, 2005/03/21
- Re: [avr-gcc-list] efficiency of assigning bits (getting OT), E. Weddington, 2005/03/21