view gcc/testsuite/gcc.dg/extract_recip_4.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */

/* Don't expect any of these divisions to be extracted.  */
double f (double x, int p)
{
  if (p > 0)
    {
      return 1.0/(x * x);
    }

  if (p > -1)
    {
      return x * x * x;
    }
  return  1.0 /(x);
}

/* Expect a reciprocal to be extracted here.  */
double g (double *a, double x, double y)
{
  *a = 3 / y;
  double k = x / (y * y);

  if (y * y == 2.0)
    return k + 1 / y;
  else
    return k - 1 / y;
}

/* Expect 2 divisions in 'f' and 1 in 'g'.  */
/* { dg-final { scan-tree-dump-times "rdiv_expr" 3 "optimized" } } */
/* Expect 3 multiplications in 'f' and 4 in 'g'.  */
/* { dg-final { scan-tree-dump-times "mult_expr" 7 "optimized" } } */