Hi guys,
I have a small program with the following statements -
DDRB = 0x1;
DDRB = DDRB<<2;
DDRB += 5;
I am compiling it with "avr-gcc -mmcu=atmega8 -O3 -fdump-tree-all ledchase.c". As you can see, I am dumping the content after each pass in avr-gcc.
In the dumps, I see that neither statement 2 nor 3
is optimized i.e. I don't see "DDRB = 4 (from 2nd statement)" or "DDRB = 5 (from 3rd statement)".
My question is - Is it possible to achieve such optimizations with avr-gcc? if not, why?
Another important things I would like to know if programs for AVR devices are written with such statements i.e. "DDRB = DDRB<<2" or "DDRB += 5".
Or it is mostly a direct constant value assignment to registers?
Please let me know. It would help me a lot. Thanks in advance !
Thanks and regards,
Sandeep.