]> git.ipfire.org Git - thirdparty/gcc.git/commit
complex-lowering: Better handling of PAREN_EXPR [PR68855]
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 20 Jun 2024 22:52:05 +0000 (15:52 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Fri, 21 Jun 2024 06:38:32 +0000 (23:38 -0700)
commit59221dc587f369695d9b0c2f73aedf8458931f0f
tree4f821ac13a6d57f610339e869609e139ac38788b
parent1f974c3a24b76e25a2b7f31a6c7f4aee93a9eaab
complex-lowering: Better handling of PAREN_EXPR [PR68855]

When PAREN_EXPR tree code was added in r0-85884-gdedd42d511b6e4,
a simplified handling was added to complex lowering. Which means
we would get:
```
  _9 = COMPLEX_EXPR <_15, _14>;
  _11 = ((_9));
  _19 = REALPART_EXPR <_11>;
  _20 = IMAGPART_EXPR <_11>;
```

In many cases instead of just simply:
```
  _19 = ((_15));
  _20 = ((_14));
```

So this adds full support for PAREN_EXPR to complex lowering.
It is handled very similar as NEGATE_EXPR; except creating PAREN_EXPR
instead of NEGATE_EXPR for the real/imag parts. This allows for
more optimizations including vectorization, especially with
-ffast-math.
gfortran.dg/vect/pr68855.f90 is an example where this could show up.
It also shows up in SPEC CPU 2006's 465.tonto; though I have not done
any benchmarking there.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/68855
* tree-complex.cc (init_dont_simulate_again): Handle PAREN_EXPR
like NEGATE_EXPR.
(complex_propagate::visit_stmt): Likewise.
(expand_complex_move): Don't handle PAREN_EXPR.
(expand_complex_paren): New function.
(expand_complex_operations_1): Handle PAREN_EXPR like
NEGATE_EXPR. And call expand_complex_paren for PAREN_EXPR.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr68855.c: New test.
* gfortran.dg/vect/pr68855.f90: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/vect/pr68855.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/pr68855.f90 [new file with mode: 0644]
gcc/tree-complex.cc