]> git.ipfire.org Git - thirdparty/gcc.git/commit
PHIOPT: factor out unary operations instead of just conversions
authorAndrew Pinski <apinski@marvell.com>
Thu, 27 Apr 2023 19:21:54 +0000 (12:21 -0700)
committerAndrew Pinski <apinski@marvell.com>
Mon, 8 May 2023 07:36:19 +0000 (00:36 -0700)
commit6d6c17e45f62cfe0b7de502af299348fca548b01
treea87a92b2dfa86e83ebb3d874e5200e0b3967b334
parent01f3e3768fffa73dc63c261426ebaaf4b9add74b
PHIOPT: factor out unary operations instead of just conversions

After using factor_out_conditional_conversion with diamond bb,
we should be able do use it also for all normal unary gimple and not
just conversions. This allows to optimize PR 59424 for an example.
This is also a start to optimize PR 64700 and a few others.

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

An example of this is:
```
static inline unsigned long long g(int t)
{
  unsigned t1 = t;
  return t1;
}
static int abs1(int a)
{
  if (a < 0)
    a = -a;
  return a;
}
unsigned long long f(int c, int d, int e)
{
  unsigned long long t;
  if (d > e)
    t = g(abs1(d));
  else
    t = g(abs1(e));
  return t;
}
```

Which should be optimized to:
  _9 = MAX_EXPR <d_5(D), e_6(D)>;
  _4 = ABS_EXPR <_9>;
  t_3 = (long long unsigned intD.16) _4;

gcc/ChangeLog:

* tree-ssa-phiopt.cc (factor_out_conditional_conversion): Rename to ...
(factor_out_conditional_operation): This and add support for all unary
operations.
(pass_phiopt::execute): Update call to factor_out_conditional_conversion
to call factor_out_conditional_operation instead.

PR tree-optimization/109424
PR tree-optimization/59424

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/abs-2.c: Update tree scan for
details change in wording.
* gcc.dg/tree-ssa/minmax-17.c: Likewise.
* gcc.dg/tree-ssa/pr103771.c: Likewise.
* gcc.dg/tree-ssa/minmax-18.c: New test.
* gcc.dg/tree-ssa/minmax-19.c: New test.
gcc/testsuite/gcc.dg/tree-ssa/abs-2.c
gcc/testsuite/gcc.dg/tree-ssa/minmax-17.c
gcc/testsuite/gcc.dg/tree-ssa/minmax-18.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/minmax-19.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103771.c
gcc/tree-ssa-phiopt.cc