[Patch,AVR]: Fix PR39386 (x << x and x >> x)
Georg-Johann Lay
avr@gjlay.de
Mon Jul 25 13:02:00 GMT 2011
This is a fix for pathological, variable shift offset shifts of
the form x << x resp. x >> x.
Such shifts need a shift register which might overlap with the
shift operand.
unsigned char shift (unsigned int x)
{
return x << x;
}
Without patch, note r24 is part of operand and used in loop:
shift:
rjmp 2f
1: lsl r24
rol r25
2: dec r24
brpl 1b
ret
With patch use tmp_reg (R0) as counter:
shift:
mov r0,r24
rjmp 2f
1: lsl r24
rol r25
2: dec r0
brpl 1b
ret
Patch as obvious. Increased instruction length is already
taken into account because the RO = Rx will be needed if
Rx is used afterwards, anyway.
Ok to install?
Johann
PR target/39386
* config/avr/avr.c (out_shift_with_cnt): Use tmp_reg as
shift counter for x << x and x >> x shifts.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr39386.diff
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110725/5c9ff71e/attachment.bin>
More information about the Gcc-patches
mailing list