[Bug target/54089] [SH] Refactor shift patterns
olegendo at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Dec 17 11:11:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54089
--- Comment #30 from Oleg Endo <olegendo at gcc dot gnu.org> ---
A case from libmpeg2/slice.c:
mov.b @(1,r10),r0 // load of shift amount
shld r7,r6
add #1,r6
extu.b r0,r0 // zero extend shift amount
shld r0,r1 // r1 <<= r0
mov r1,r0
The zero extension of the shift amount variable could be omitted because shift
amounts > 31 are undefined behavior. If the shift amount is in the valid range
of 0...31 the zero extension won't do anything.
A reduced test case:
int test33 (unsigned char* x, int y)
{
return y << x[4];
}
results in:
mov.b @(4,r4),r0
extu.b r0,r0
shld r0,r5
rts
mov r5,r0
More information about the Gcc-bugs
mailing list