mbox series

[0/4] Some improvements to complex lowering (cabs related)

Message ID 20240701214657.3163066-1-quic_apinski@quicinc.com
Headers show
Series Some improvements to complex lowering (cabs related) | expand

Message

Andrew Pinski July 1, 2024, 9:46 p.m. UTC
This patch series includes some improvements to complex lowering,
all related to cabs.
History of the cabs folding
cabs folding was originally add in builtins.c ( and 4.3 [r0-78875-gd1ad84c20452e6])
The expansion to `sqrt(r*r+i*i)` added to cse sincos pass in GCC 4.7
(r0-109444-gd7e2a1c13835e7) to fix an lto issue where `r*r` would be convert
into `pow(r, 2.0)` after the cse_sincos pass (which at the time also did pow
expansion).
The other cabs folding for the constant/same value optimization was moved
to match in GCC 6 (r6-4111-gabcc43f5323869). This series moves all possible
cabs expansion/simplifications to complex lowering which already has a decent
lattice and folding which allows `cabs(x+xI)` and `cabs(x+0.0I)` and `cabs(0.0+xI)`
be detected.

Andrew Pinski (4):
  Small optimization for complex addition, real/imag parts the same
  Move cabs expansion from powcabs to complex lowering [PR115710]
  Add some optimizations to gimple_expand_builtin_cabs
  Rename expand_powcabs pass to expand_pow

 gcc/passes.def                              |   2 +-
 gcc/testsuite/gcc.dg/pow-sqrt-synth-1.c     |   4 +-
 gcc/testsuite/gcc.dg/tree-ssa/cabs-1.c      |  14 +++
 gcc/testsuite/gcc.dg/tree-ssa/cabs-2.c      |  13 +++
 gcc/testsuite/gcc.dg/tree-ssa/cabs-3.c      |  24 +++++
 gcc/testsuite/gcc.dg/tree-ssa/cabs-4.c      |  16 +++
 gcc/testsuite/gcc.dg/tree-ssa/cabs-5.c      |  22 ++++
 gcc/testsuite/gcc.dg/tree-ssa/cabs-6.c      |  16 +++
 gcc/testsuite/gcc.dg/tree-ssa/complex-8.c   |  12 +++
 gcc/testsuite/gfortran.dg/vect/pr115710.f90 |  18 ++++
 gcc/timevar.def                             |   2 +-
 gcc/tree-complex.cc                         | 109 +++++++++++++++++++-
 gcc/tree-pass.h                             |   2 +-
 gcc/tree-ssa-math-opts.cc                   |  91 +++-------------
 14 files changed, 258 insertions(+), 87 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-1.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-2.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-3.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-4.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-5.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cabs-6.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/complex-8.c
 create mode 100644 gcc/testsuite/gfortran.dg/vect/pr115710.f90