Skip to content
Snippets Groups Projects
Commit 6d6c17e4 authored by Andrew Pinski's avatar Andrew Pinski
Browse files

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.
parent 01f3e376
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment