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] Improve Gimplification of return for vectors and complex variables


On 12/19/06, Andrew Pinski <pinskia@gmail.com> wrote:
Hi,
  When DECL_COMPLEX_GIMPLE_REG_P was added, we made function that
returned complex types gimplify in a no longer optimal way, we produce a
temporary decl as a non gimple register which causes us to produce an
extra decls.

For an example take this GNU C code:
_Complex int f(int a, int b)
{
  if (a)
    return a;
  return b;
}
---------------
Without this patch, we get the following in .final_cleanup at -O2:
  int SR.12;
  int SR.11;
  <unnamed type> D.1613;
  <unnamed type> D.1612;
  <unnamed type> D.1611;

<bb 2>:
  if (a != 0) goto <L0>; else goto <L1>;

<L0>:;
  D.1612 = COMPLEX_EXPR <a, 0>;
  SR.12 = IMAGPART_EXPR <D.1612>;
  SR.11 = REALPART_EXPR <D.1612>;
  goto <bb 5> (<L2>);

<L1>:;
  D.1613 = COMPLEX_EXPR <b, 0>;
  SR.12 = IMAGPART_EXPR <D.1613>;
  SR.11 = REALPART_EXPR <D.1613>;

<L2>:;
  IMAGPART_EXPR <D.1611> = SR.12;
  REALPART_EXPR <D.1611> = SR.11;
  return D.1611;

With this patch:
  <unnamed type> D.1614;

<bb 2>:
  if (a != 0) goto <L0>; else goto <L1>;

<L0>:;
  D.1614 = COMPLEX_EXPR <a, 0>;
  goto <bb 5> (<L2>);

<L1>:;
  D.1614 = COMPLEX_EXPR <b, 0>;

<L2>:;
  return D.1614;

Yes this is still can be improved so there is only one COMPLEX_EXPR, but
that is a bug for another time.

OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

This is ok. Can you produce a followup to make the test for COMPLEX or VECTOR type a predicate GIMPLE_REG_TYPE_P? (or rather GIMPLE_REG_TYPE_POSSIBLE_P - but that's so long...)

Thanks,
Richard.


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