1 /* { dg-do run } */
2 /* { dg-options "-std=gnu99 -O0" } */
3 
4 extern void abort (void);
5 
6 /* Make sure GCC knows there is no associativity for saturating types.  */
7 
8 /* Don't transform to (temp + (0.5r + 0.8r))  */
add_test(_Sat _Fract temp)9 _Sat _Fract add_test (_Sat _Fract temp)
10 {
11   return temp + 0.5r + 0.8r;
12 }
13 
14 /* Don't transform to (temp * ((-0.5r - 0.5r) * (-0.5r - 0.5r)))  */
mul_test(_Sat _Fract temp)15 _Sat _Fract mul_test (_Sat _Fract temp)
16 {
17   return temp * (-0.5r - 0.5r) * (-0.5r - 0.5r);
18 }
19 
20 /* Don't transform to ((temp1 + temp2) * 0.5r)  */
mul_add_test(_Sat _Fract temp1,_Sat _Fract temp2)21 _Sat _Fract mul_add_test (_Sat _Fract temp1, _Sat _Fract temp2)
22 {
23   return temp1 * 0.5r + temp2 * 0.5r;
24 }
25 
26 /* Don't transform to ((temp1 - temp2) * 0.5r)  */
mul_sub_test(_Sat _Fract temp1,_Sat _Fract temp2)27 _Sat _Fract mul_sub_test (_Sat _Fract temp1, _Sat _Fract temp2)
28 {
29   return temp1 * 0.5r - temp2 * 0.5r;
30 }
31 
main()32 int main ()
33 {
34   _Sat _Fract a;
35 
36   a = add_test (-0.5r);
37   if (a != 0.8r)
38     abort ();
39 
40   a = mul_test (0.1r);
41   if (a != 0.1r)
42     abort ();
43 
44   a = mul_add_test (0.75r, 0.5r);
45   if (a != 0.625r)
46     abort ();
47 
48   a = mul_sub_test (0.75r, -0.5r);
49   if (a != 0.625r)
50     abort ();
51 
52   return 0;
53 }
54