This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/69047] memcpy is not as optimized as union is
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Aug 2016 05:33:56 +0000
- Subject: [Bug tree-optimization/69047] memcpy is not as optimized as union is
- Auto-submitted: auto-generated
- References: <bug-69047-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69047
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|arm, aarch64 |
Component|rtl-optimization |tree-optimization
Summary|memcpy of 64-bit integer to |memcpy is not as optimized
|32-bit integer causes |as union is
|pointless stack operations |
|on ARM |
Severity|normal |enhancement
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take:
union li
{
int a[2];
long long b;
};
int f(long long b) {
int a;
__builtin_memcpy(&a, &b, sizeof a);
return a;
}
int f1(long long b) {
union li a;
a.b = b;
return a.a[0];
}
These two functions should produce the same code but f produces worse.
Also f1 is optimized at the tree level while f is optimized at the RTL level
leaving behind the stack location that is used to store b.