view gcc/testsuite/gcc.dg/extract_recip_4.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +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" } } */