[Bug tree-optimization/45216] Rotate expressions not recognized at tree level
mickflemm at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 1 01:38:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45216
Nick Kossifidis <mickflemm at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mickflemm at gmail dot com
--- Comment #7 from Nick Kossifidis <mickflemm at gmail dot com> 2012-12-01 01:37:35 UTC ---
In my case it does detect an even more complex scenario but it doesn't detect
it when using integer typedefs from <sys/types.h>, more specifically:
unsigned long rotate_left(unsigned long a, unsigned int shift)
{
return a << shift | a >> (sizeof(a) * 8 - shift);
}
results
080483d4 <rotate_left>:
80483d4: 55 push %ebp
80483d5: 89 e5 mov %esp,%ebp
80483d7: 53 push %ebx
80483d8: 8b 45 0c mov 0xc(%ebp),%eax
80483db: 8b 55 08 mov 0x8(%ebp),%edx
80483de: 89 d3 mov %edx,%ebx
80483e0: 89 c1 mov %eax,%ecx
80483e2: d3 c3 rol %cl,%ebx
80483e4: 89 d8 mov %ebx,%eax
80483e6: 5b pop %ebx
80483e7: 5d pop %ebp
80483e8: c3 ret
but
u_int64_t rotate_left(u_int64_t a, u_int32_t shift)
{
return a << shift | a >> (sizeof(a) * 8 - shift);
}
results
080483d4 <rotate_left>:
80483d4: 55 push %ebp
80483d5: 89 e5 mov %esp,%ebp
80483d7: 56 push %esi
80483d8: 53 push %ebx
80483d9: 83 ec 10 sub $0x10,%esp
80483dc: 8b 45 08 mov 0x8(%ebp),%eax
80483df: 89 45 f0 mov %eax,-0x10(%ebp)
80483e2: 8b 45 0c mov 0xc(%ebp),%eax
80483e5: 89 45 f4 mov %eax,-0xc(%ebp)
80483e8: 8b 45 f0 mov -0x10(%ebp),%eax
80483eb: 8b 55 f4 mov -0xc(%ebp),%edx
80483ee: 8b 4d 10 mov 0x10(%ebp),%ecx
80483f1: 89 c3 mov %eax,%ebx
80483f3: 89 d6 mov %edx,%esi
80483f5: 0f a5 de shld %cl,%ebx,%esi
80483f8: d3 e3 shl %cl,%ebx
80483fa: f6 c1 20 test $0x20,%cl
80483fd: 74 04 je 8048403 <ed_rotate_left+0x2f>
80483ff: 89 de mov %ebx,%esi
8048401: 31 db xor %ebx,%ebx
8048403: b9 40 00 00 00 mov $0x40,%ecx
8048408: 2b 4d 10 sub 0x10(%ebp),%ecx
804840b: 0f ad d0 shrd %cl,%edx,%eax
804840e: d3 ea shr %cl,%edx
8048410: f6 c1 20 test $0x20,%cl
8048413: 74 04 je 8048419 <ed_rotate_left+0x45>
8048415: 89 d0 mov %edx,%eax
8048417: 31 d2 xor %edx,%edx
8048419: 89 c1 mov %eax,%ecx
804841b: 09 d9 or %ebx,%ecx
804841d: 89 4d e8 mov %ecx,-0x18(%ebp)
8048420: 89 d1 mov %edx,%ecx
8048422: 09 f1 or %esi,%ecx
8048424: 89 4d ec mov %ecx,-0x14(%ebp)
8048427: 8b 45 e8 mov -0x18(%ebp),%eax
804842a: 8b 55 ec mov -0x14(%ebp),%edx
804842d: 83 c4 10 add $0x10,%esp
8048430: 5b pop %ebx
8048431: 5e pop %esi
8048432: 5d pop %ebp
8048433: c3 ret
Here are the typedefs from <sys/types.h>:
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
I also tried with u_int32_t/u_int16_t and other combinations but I get the same
results.
gcc version 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7)
More information about the Gcc-bugs
mailing list