This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] no lowering of &a.b (and &a->b) in the C front-end


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]