[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] efficiency of assigning bits
From: |
Graham Davies |
Subject: |
Re: [avr-gcc-list] efficiency of assigning bits |
Date: |
Sat, 19 Mar 2005 15:09:25 -0500 |
Jim Brain wrote:
> My understanding was that C only
> promotes to integer when doing negation
> or when other operands are integer.
This is the sort of thing you should probably go back and check on before
posting here.
> I've never seen constants promoted
> to int in a normal (1<<X) mode.
This has nothing to do with what the ANSI C specification requires. This
just indicates that the optimizer has determined that the result will be the
same whether the operands are processed as integers or at their declared
size. By the way, the expression you give as an example contains an object
of type integer (the literal constant 1), so even by your flawed
understanding of C you should realize that C requires the promotion of X to
int in the abstract machine. If you don't see this in the generated machine
code, it is because the optimizer is at least half-way decent.
> And, when I negate, I do:
> PORT &=(unsigned char)~ADDR_CLK;
> to cancel the promotion.
You can't "cancel" promotions. All you can do it take the result of an
operand or expression evaluation and cast (perform an explicit conversion)
to some type. This is what you are doing here.
Graham.
- Re: [avr-gcc-list] efficiency of assigning bits, (continued)
- Re: [avr-gcc-list] efficiency of assigning bits, Dave Hansen, 2005/03/18
- Re: [avr-gcc-list] efficiency of assigning bits, David Brown, 2005/03/21
- Re: [avr-gcc-list] efficiency of assigning bits, Dave Hansen, 2005/03/21
- 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 <=
- 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, 2005/03/21
- 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