1 /* { dg-require-effective-target int32plus } */
3 typedef long unsigned int size_t;
4 extern void *memset (void *__s
, int __c
, size_t __n
) __attribute__ ((__nothrow__
)) __attribute__ ((__nonnull__ (1)));
7 encode (words
, low
, hi
)
12 words
[0] = ((low
) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1));
13 words
[1] = ((unsigned long) (low
) >> sizeof(unsigned long) / 2);
14 words
[2] = ((hi
) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1));
15 words
[3] = ((unsigned long) (hi
) >> sizeof(unsigned long) / 2);
19 decode (words
, low
, hi
)
24 *low
= words
[0] + words
[1] * ((unsigned long) 1 << sizeof(unsigned long) / 2);
25 *hi
= words
[2] + words
[3] * ((unsigned long) 1 << sizeof(unsigned long) / 2);
29 neg_double (l1
, h1
, lv
, hv
)
39 return (*hv
& h1
) < 0;
50 add_double (l1
, h1
, l2
, h2
, lv
, hv
)
60 h
= h1
+ h2
+ (l
< l1
);
64 return ((~((h1
) ^ (h2
)) & ((h1
) ^ (h
))) < 0);
68 mul_double (l1
, h1
, l2
, h2
, lv
, hv
)
79 unsigned long toplow
, neglow
;
80 long tophigh
, neghigh
;
82 encode (arg1
, l1
, h1
);
83 encode (arg2
, l2
, h2
);
85 memset ((char *) prod
, 0, sizeof prod
);
87 for (i
= 0; i
< 4; i
++)
90 for (j
= 0; j
< 4; j
++)
94 carry
+= arg1
[i
] * arg2
[j
];
97 prod
[k
] = ((carry
) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1));
98 carry
= ((unsigned long) (carry
) >> sizeof(unsigned long) / 2);
103 decode (prod
, lv
, hv
);
107 decode (prod
+ 4, &toplow
, &tophigh
);
110 neg_double (l2
, h2
, &neglow
, &neghigh
);
111 add_double (neglow
, neghigh
, toplow
, tophigh
, &toplow
, &tophigh
);
115 neg_double (l1
, h1
, &neglow
, &neghigh
);
116 add_double (neglow
, neghigh
, toplow
, tophigh
, &toplow
, &tophigh
);
118 return (*hv
< 0 ? ~(toplow
& tophigh
) : toplow
| tophigh
) != 0;