This is the mail archive of the
mailing list for the GCC project.
Re: Instructions vs Expressions in the backend (was Re: RFA: Rework FOR_BB_INSNS iterators)
- From: Jeff Law <law at redhat dot com>
- To: Oleg Endo <oleg dot endo at t-online dot de>, David Malcolm <dmalcolm at redhat dot com>, Steven Bosscher <stevenb dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, rdsandiford at googlemail dot com
- Date: Wed, 25 Jun 2014 14:39:10 -0600
- Subject: Re: Instructions vs Expressions in the backend (was Re: RFA: Rework FOR_BB_INSNS iterators)
- Authentication-results: sourceware.org; auth=none
- References: <87vbscppva dot fsf at talisman dot default> <CABu31nPovtFLwmOAuiqT5EadJZCqg+U7RqOMYAZimf3ykVE=OA at mail dot gmail dot com> <87d2ehq3p6 dot fsf at talisman dot default> <1403549659 dot 16446 dot 43 dot camel at surprise> <1403555889 dot 27443 dot 121 dot camel at yam-132-YW-E178-FTW> <87bnthgwku dot fsf at talisman dot default>
On 06/25/14 03:36, Richard Sandiford wrote:
Historical coding style :( It's particularly bad in RTL land, but you
see the same problems in places like fold-const.
I think this is an example of another problem with gcc coding style:
that we're far too afraid of temporary variables. In David's scheme
I think this would be:
There was some talk of revamping the rules of parens for member function
calls. I don't recall what the final outcome was.
if (rtx_mem *mem = as_a <rtx_mem *> (XEXP (x, 0)))
*total = address_cost (XEXP (mem, 0), GET_MODE (mem),
MEM_ADDR_SPACE (mem), true);
which with members would become:
if (rtx_mem *mem = as_a <rtx_mem *> (...))
*total = address_cost (mem->address (), mem->mode (), mem->address_space (),
(although if we go down that route, I hope we can add an exception to the
formatting rule so that no space should be used before "()".)
I prefer the latter, but I tend to worry about making David's patches
even more invasive than they already are :-)
I suppose with the magic values it would be:
if (rtx_mem mem = as_a <rtx_mem> (x))
*total = address_cost (mem, mem.mode (), mem.address_space (), true);
but I'm not sure that that would really be more readable.
And probably faster as well since we've CSE'd the memory reference. In
this specific example it probably doesn't matter, but often there's a
call somewhere between XEXPs that we'd like to CSE that destroys our
ability to CSE away memory references.
But like you say, I'm not sure whether it would really be a win in the end.
I think what makes this example so hard to read is again that we refuse
to put XEXP (x, 0) in a temporary variable and just write it out in full
4 times instead.
if ((GET_CODE (op0) == SMAX || GET_CODE (op0) == SMIN)
&& CONST_INT_P (XEXP (op0, 1))
&& REG_P (XEXP (op0, 0))
&& CONST_INT_P (op1))
is a bit more obvious.
This kind of problem is prevasive in the RTL analysis/optimizers.