summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/extract_recip_3.c
blob: 15bcc27f8bfae6cc960f7b60a2ddf95afc2692ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* { dg-do compile } */
/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */

float
extract_square (float *a, float *b, float x, float y)
{
  *a = 3 / (y * y);
  *b = 5 / (y * y);

  return x / (y * y);
}

/* Don't expect the 'powmult' (calculation of y * y)
   to be deleted until a later pass, so look for one
   more multiplication than strictly necessary.  */
float
extract_recip (float *a, float *b, float x, float y, float z)
{
  *a = 7 / y;
  *b = x / (y * y);

  return z / y;
}

/* 4 multiplications in 'extract_square', and 4 in 'extract_recip'.  */
/* { dg-final { scan-tree-dump-times "mult_expr" 8 "optimized" } } */

/* 1 division in 'extract_square', 1 division in 'extract_recip'. */
/* { dg-final { scan-tree-dump-times "rdiv_expr" 2 "optimized" } } */