Optimise sqrt reciprocal multiplications
[official-gcc.git] / gcc / testsuite / g++.dg / recip_sqrt_mult_1.C
blob11d9c6f758f1529d8ed4cadf85010f6ce379c195
1 /* { dg-do compile } */
2 /* { dg-options "-Ofast -fnon-call-exceptions -fdump-tree-recip" } */
4 double res, res2, tmp;
5 void
6 foo1 (double a, double b)
8   try {
9     tmp = 1.0 / __builtin_sqrt (a);
10     res = tmp * tmp;
11     res2 = a * tmp;
12   }
13   catch (...)
14     { ; }
17 void
18 foo4 (double a, double b, int c, int d)
20   try {
21     tmp = 1.0 / __builtin_sqrt (a);
22   }
23   catch (...)
24     {
25       if (c)
26         res = tmp * tmp;
28       if (d)
29         res2 = a * tmp;
30     }
33 void
34 foo5 (double a, double b, int c, int d)
36   try {
37     tmp = 1.0 / __builtin_sqrt (a);
38     res = tmp * tmp;
40     if (d)
41       res2 = a * tmp;
42   }
43   catch (...)
44     { ; }
47 /* { dg-final { scan-tree-dump-times "Optimizing reciprocal sqrt multiplications" 2 "recip" } } */
48 /* { dg-final { scan-tree-dump-times "Replacing squaring multiplication" 2 "recip" } } */
49 /* { dg-final { scan-tree-dump-times "Replacing original division" 2 "recip" } } */