This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/45813] [4.5 Regression] alias analysis problem with -mthumb
- From: "mikpe at it dot uu.se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 15 Mar 2012 08:10:55 +0000
- Subject: [Bug rtl-optimization/45813] [4.5 Regression] alias analysis problem with -mthumb
- Auto-submitted: auto-generated
- References: <bug-45813-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45813
--- Comment #15 from Mikael Pettersson <mikpe at it dot uu.se> 2012-03-15 08:10:55 UTC ---
-fno-strict-aliasing makes no difference to the code generated by 4.5-20120308.
Replacing the type-punning with a union results in both correct-looking and
much tighter code:
unsigned short ReadLE16U_union( volatile unsigned char * ptr )
{
union {
unsigned short value;
unsigned char bytes[2];
} u;
u.bytes[0] = ptr[0];
u.bytes[1] = ptr[1];
return u.value;
}
ReadLE16U_union:
push {r7, lr}
ldrb r3, [r0]
ldrb r0, [r0, #1]
add r7, sp, #0
mov sp, r7
lsl r0, r0, #8
orr r0, r0, r3
@ sp needed for prologue
pop {r7, pc}
.size ReadLE16U_union, .-ReadLE16U_union
.ident "GCC: (GNU) 4.5.4 20120308 (prerelease)"