2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr54680.c
blob7b02de35464787ccdc4eb5b28be01a71e8ca668f
1 /* Verify that the fsca input value is not converted to float and then back
2 to int. Notice that we can't count just "lds" insns because mode switches
3 use "lds.l". */
4 /* { dg-do compile { target { has_fsca } } } */
5 /* { dg-options "-O2 -mfsca -funsafe-math-optimizations -fno-ipa-icf" } */
6 /* { dg-final { scan-assembler-times "fsca" 7 } } */
7 /* { dg-final { scan-assembler-times "shad" 1 } } */
8 /* { dg-final { scan-assembler-times "lds\tr\[0-9\],fpul" 6 } } */
9 /* { dg-final { scan-assembler-times "fmul" 2 } } */
10 /* { dg-final { scan-assembler-times "ftrc" 1 } } */
12 #include <math.h>
14 static const float pi = 3.14159265359f;
16 float
17 test00 (int x)
19 /* 1x shad, 1x lds, 1x fsca */
20 return sinf ( (x >> 8) * (2*pi) / (1 << 16));
23 float
24 test01 (int x)
26 /* 1x lds, 1x fsca */
27 return sinf (x * (2*pi) / 65536);
30 float
31 test02 (int x)
33 /* 1x lds, 1x fsca */
34 return sinf (x * (2*pi / 65536));
37 float
38 test03 (int x)
40 /* 1x lds, 1x fsca */
41 float scale = 2*pi / 65536;
42 return sinf (x * scale);
45 float
46 test04 (int x)
48 /* 1x lds, 1x fsca */
49 return cosf (x / 65536.0f * 2*pi);
52 float
53 test05 (int x)
55 /* 1x lds, 1x fsca, 1x fmul */
56 float scale = 2*pi / 65536;
57 return sinf (x * scale) * cosf (x * scale);
60 float
61 test_06 (float x)
63 /* 1x fmul, 1x ftrc, 1x fsca */
64 return sinf (x);