1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3
4 /* This maps to essentially the same gimple that is generated for
5 gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of
6 Ada.Numerics.Aux_Float. The value of EPSILON is not relevant to
7 the test, but the test must be there to keep the conversions in
8 different BBs long enough to trigger the problem that prevented the
9 sincos optimization, because the arguments passed to sin and cos
10 didn't get unified into a single SSA_NAME in time for sincos. */
11
12 #include <math.h>
13
14 #define EPSILON 3.4526697709225118160247802734375e-4
15
my_sinf(float x)16 static float my_sinf(float x) {
17 return (float) sin ((double) x);
18 }
19
wrap_sinf(float x)20 static float wrap_sinf(float x) {
21 if (fabs (x) < EPSILON)
22 return 0;
23 return my_sinf (x);
24 }
25
my_cosf(float x)26 static float my_cosf(float x) {
27 return (float) cos ((double) x);
28 }
29
wrap_cosf(float x)30 static float wrap_cosf(float x) {
31 if (fabs (x) < EPSILON)
32 return 1;
33 return my_cosf (x);
34 }
35
my_sin_cos(float x,float * s,float * c)36 float my_sin_cos(float x, float *s, float *c) {
37 *s = wrap_sinf (x);
38 *c = wrap_cosf (x);
39 }
40
41 /* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* *-w64-mingw* *-*-vxworks* } } } */
42