This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] no lowering of &a.b (and &a->b) in the C front-end
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 22 Aug 2004 17:07:35 -0700
- Subject: Re: [PATCH] no lowering of &a.b (and &a->b) in the C front-end
- References: <AAD1EF8A-F496-11D8-95FD-00039351ED8A@physics.uc.edu>
Andrew Pinski <pinskia@physics.uc.edu> writes:
> I found that both the C and C++ front-ends do lower &a.b into a +
> offsetof(b,a) which is really not good for some optimizations which
> can change the struct a into scaler values.
>
> This patch changes the C front-end so there is no lowering and fixes
> a bug found in c_finish_return with the no lowering turned on.
> Warning about returning a temporary which is true for &a->b.
Can you give an example of code which is optimized better with your
patch?
> + addr2 = build1 (ADDR_EXPR, argtype, arg);
> +
> + if (!TREE_CONSTANT (addr) || TREE_CONSTANT (addr2))
> + addr = addr2;
Why isn't this
if (!TREE_CONSTANT (addr))
addr = build1 (ADDR_EXPR, argtype, arg);
That avoids constructing a junk tree node in the majority of cases.
zw