1 /* Make sure a -0 stays -0 when we perform a conditional reduction. */
2 /* { dg-require-effective-target vect_double } */
3 /* { dg-add-options ieee } */
4 /* { dg-additional-options "-std=gnu99 -fno-fast-math" } */
10 #define N (VECTOR_BITS * 17)
12 double __attribute__ ((noinline
, noclone
))
13 reduc_plus_double (double *restrict a
, double init
, int *cond
, int n
)
16 for (int i
= 0; i
< n
; i
++)
22 double __attribute__ ((noinline
, noclone
, optimize ("0")))
23 reduc_plus_double_ref (double *restrict a
, double init
, int *cond
, int n
)
26 for (int i
= 0; i
< n
; i
++)
32 double __attribute__ ((noinline
, noclone
))
33 reduc_minus_double (double *restrict a
, double init
, int *cond
, int n
)
36 for (int i
= 0; i
< n
; i
++)
42 double __attribute__ ((noinline
, noclone
, optimize ("0")))
43 reduc_minus_double_ref (double *restrict a
, double init
, int *cond
, int n
)
46 for (int i
= 0; i
< n
; i
++)
52 int __attribute__ ((optimize (1)))
57 int cond1
[N
], cond2
[N
];
59 for (int i
= 0; i
< N
; i
++)
61 a
[i
] = (i
* 0.1) * (i
& 1 ? 1 : -1);
63 cond2
[i
] = i
& 4 ? 1 : 0;
64 asm volatile ("" ::: "memory");
67 double res1
= reduc_plus_double (a
, -0.0, cond1
, n
);
68 double ref1
= reduc_plus_double_ref (a
, -0.0, cond1
, n
);
69 double res2
= reduc_minus_double (a
, -0.0, cond1
, n
);
70 double ref2
= reduc_minus_double_ref (a
, -0.0, cond1
, n
);
71 double res3
= reduc_plus_double (a
, -0.0, cond1
, n
);
72 double ref3
= reduc_plus_double_ref (a
, -0.0, cond1
, n
);
73 double res4
= reduc_minus_double (a
, -0.0, cond1
, n
);
74 double ref4
= reduc_minus_double_ref (a
, -0.0, cond1
, n
);
76 if (res1
!= ref1
|| signbit (res1
) != signbit (ref1
))
78 if (res2
!= ref2
|| signbit (res2
) != signbit (ref2
))
80 if (res3
!= ref3
|| signbit (res3
) != signbit (ref3
))
82 if (res4
!= ref4
|| signbit (res4
) != signbit (ref4
))
85 res1
= reduc_plus_double (a
, 0.0, cond1
, n
);
86 ref1
= reduc_plus_double_ref (a
, 0.0, cond1
, n
);
87 res2
= reduc_minus_double (a
, 0.0, cond1
, n
);
88 ref2
= reduc_minus_double_ref (a
, 0.0, cond1
, n
);
89 res3
= reduc_plus_double (a
, 0.0, cond1
, n
);
90 ref3
= reduc_plus_double_ref (a
, 0.0, cond1
, n
);
91 res4
= reduc_minus_double (a
, 0.0, cond1
, n
);
92 ref4
= reduc_minus_double_ref (a
, 0.0, cond1
, n
);
94 if (res1
!= ref1
|| signbit (res1
) != signbit (ref1
))
96 if (res2
!= ref2
|| signbit (res2
) != signbit (ref2
))
98 if (res3
!= ref3
|| signbit (res3
) != signbit (ref3
))
100 if (res4
!= ref4
|| signbit (res4
) != signbit (ref4
))
103 res1
= reduc_plus_double (a
, -0.0, cond2
, n
);
104 ref1
= reduc_plus_double_ref (a
, -0.0, cond2
, n
);
105 res2
= reduc_minus_double (a
, -0.0, cond2
, n
);
106 ref2
= reduc_minus_double_ref (a
, -0.0, cond2
, n
);
107 res3
= reduc_plus_double (a
, -0.0, cond2
, n
);
108 ref3
= reduc_plus_double_ref (a
, -0.0, cond2
, n
);
109 res4
= reduc_minus_double (a
, -0.0, cond2
, n
);
110 ref4
= reduc_minus_double_ref (a
, -0.0, cond2
, n
);
112 if (res1
!= ref1
|| signbit (res1
) != signbit (ref1
))
114 if (res2
!= ref2
|| signbit (res2
) != signbit (ref2
))
116 if (res3
!= ref3
|| signbit (res3
) != signbit (ref3
))
118 if (res4
!= ref4
|| signbit (res4
) != signbit (ref4
))
121 res1
= reduc_plus_double (a
, 0.0, cond2
, n
);
122 ref1
= reduc_plus_double_ref (a
, 0.0, cond2
, n
);
123 res2
= reduc_minus_double (a
, 0.0, cond2
, n
);
124 ref2
= reduc_minus_double_ref (a
, 0.0, cond2
, n
);
125 res3
= reduc_plus_double (a
, 0.0, cond2
, n
);
126 ref3
= reduc_plus_double_ref (a
, 0.0, cond2
, n
);
127 res4
= reduc_minus_double (a
, 0.0, cond2
, n
);
128 ref4
= reduc_minus_double_ref (a
, 0.0, cond2
, n
);
130 if (res1
!= ref1
|| signbit (res1
) != signbit (ref1
))
132 if (res2
!= ref2
|| signbit (res2
) != signbit (ref2
))
134 if (res3
!= ref3
|| signbit (res3
) != signbit (ref3
))
136 if (res4
!= ref4
|| signbit (res4
) != signbit (ref4
))