1 /* Test generation of all double-float custom instructions. */
2
3 /* { dg-do compile } */
4 /* { dg-options "-O1 -ffinite-math-only -funsafe-math-optimizations" } */
5
6 /* -O1 in the options is significant. Without it FP operations may not be
7 optimized to custom instructions. */
8
9 #include <stdio.h>
10 #include <math.h>
11
12 #pragma GCC target ("custom-frdxhi=40")
13 #pragma GCC target ("custom-frdxlo=41")
14 #pragma GCC target ("custom-frdy=42")
15 #pragma GCC target ("custom-fwrx=43")
16 #pragma GCC target ("custom-fwry=44")
17
18 #pragma GCC target ("custom-fabsd=100")
19 #pragma GCC target ("custom-faddd=101")
20 #pragma GCC target ("custom-fatand=102")
21 #pragma GCC target ("custom-fcosd=103")
22 #pragma GCC target ("custom-fdivd=104")
23 #pragma GCC target ("custom-fexpd=105")
24 #pragma GCC target ("custom-flogd=106")
25 #pragma GCC target ("custom-fmaxd=107")
26 #pragma GCC target ("custom-fmind=108")
27 #pragma GCC target ("custom-fmuld=109")
28 #pragma GCC target ("custom-fnegd=110")
29 #pragma GCC target ("custom-fsind=111")
30 #pragma GCC target ("custom-fsqrtd=112")
31 #pragma GCC target ("custom-fsubd=113")
32 #pragma GCC target ("custom-ftand=114")
33 #pragma GCC target ("custom-fcmpeqd=200")
34 #pragma GCC target ("custom-fcmpged=201")
35 #pragma GCC target ("custom-fcmpgtd=202")
36 #pragma GCC target ("custom-fcmpled=203")
37 #pragma GCC target ("custom-fcmpltd=204")
38 #pragma GCC target ("custom-fcmpned=205")
39
40 void
custom_fp(double a,double b,double * fp,int * ip)41 custom_fp (double a, double b, double *fp, int *ip)
42 {
43 fp[0] = fabs (a);
44 fp[1] = a + b;
45 fp[2] = atan (a);
46 fp[3] = cos (a);
47 fp[4] = a / b;
48 fp[5] = exp (a);
49 fp[6] = log (a);
50 fp[7] = fmax (a, b);
51 fp[8] = fmin (a, b);
52 fp[9] = a * b;
53 fp[10] = -b;
54 fp[11] = sin (b);
55 fp[12] = sqrt (a);
56 fp[13] = a - b;
57 fp[14] = tan (a);
58 ip[0] = (a == fp[0]);
59 ip[1] = (a >= fp[1]);
60 ip[2] = (a > fp[2]);
61 ip[3] = (a <= fp[3]);
62 ip[4] = (a < fp[4]);
63 ip[5] = (a != fp[5]);
64 }
65
66 /* { dg-final { scan-assembler "custom\\t100, .* # fabsd .*" } } */
67 /* { dg-final { scan-assembler "custom\\t101, .* # faddd .*" } } */
68 /* { dg-final { scan-assembler "custom\\t102, .* # fatand .*" } } */
69 /* { dg-final { scan-assembler "custom\\t103, .* # fcosd .*" } } */
70 /* { dg-final { scan-assembler "custom\\t104, .* # fdivd .*" } } */
71 /* { dg-final { scan-assembler "custom\\t105, .* # fexpd .*" } } */
72 /* { dg-final { scan-assembler "custom\\t106, .* # flogd .*" } } */
73 /* { dg-final { scan-assembler "custom\\t107, .* # fmaxd .*" } } */
74 /* { dg-final { scan-assembler "custom\\t108, .* # fmind .*" } } */
75 /* { dg-final { scan-assembler "custom\\t109, .* # fmuld .*" } } */
76 /* { dg-final { scan-assembler "custom\\t110, .* # fnegd .*" } } */
77 /* { dg-final { scan-assembler "custom\\t111, .* # fsind .*" } } */
78 /* { dg-final { scan-assembler "custom\\t112, .* # fsqrtd .*" } } */
79 /* { dg-final { scan-assembler "custom\\t113, .* # fsubd .*" } } */
80 /* { dg-final { scan-assembler "custom\\t114, .* # ftand .*" } } */
81 /* { dg-final { scan-assembler "custom\\t200, .* # fcmpeqd .*" } } */
82 /* { dg-final { scan-assembler "custom\\t201, .* # fcmpged .*" } } */
83 /* { dg-final { scan-assembler "custom\\t202, .* # fcmpgtd .*" } } */
84 /* { dg-final { scan-assembler "custom\\t203, .* # fcmpled .*" } } */
85 /* { dg-final { scan-assembler "custom\\t204, .* # fcmpltd .*" } } */
86 /* { dg-final { scan-assembler "custom\\t205, .* # fcmpned .*" } } */
87