[builtins] Change si_int to int in some helper declarations

This patch changes types of some integer function arguments or return values from `si_int` to the default `int` type to make it more compatible with `libgcc`.

The compiler-rt/lib/builtins/README.txt has a link to the [libgcc specification](http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc). This specification has an explicit note on `int`, `float` and other such types being just illustrations in some cases while the actual types are expressed with machine modes.

Such usage of always-32-bit-wide integer type may lead to issues on 16-bit platforms such as MSP430. Provided [libgcc2.h](https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=libgcc/libgcc2.h;hb=HEAD) can be used as a reference for all targets supported by the libgcc, this patch fixes some existing differences in helper declarations.

This patch is expected to not change behavior at all for targets with 32-bit `int` type.

Differential Revision: https://reviews.llvm.org/D81285
This commit is contained in:
Anatoly Trosinenko 2020-06-30 11:06:52 +03:00 committed by Anton Korobeynikov
parent 19e75717ef
commit 0ee439b705
33 changed files with 183 additions and 178 deletions

View File

@ -20,13 +20,18 @@ Here is the specification for this library:
http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
Please note that the libgcc specification explicitly mentions actual types of
arguments and returned values being expressed with machine modes.
In some cases particular types such as "int", "unsigned", "long long", etc.
may be specified just as examples there.
Here is a synopsis of the contents of this library:
typedef int si_int;
typedef unsigned su_int;
typedef int32_t si_int;
typedef uint32_t su_int;
typedef long long di_int;
typedef unsigned long long du_int;
typedef int64_t di_int;
typedef uint64_t du_int;
// Integral bit manipulation
@ -38,24 +43,24 @@ ti_int __ashrti3(ti_int a, si_int b); // a >> b arithmetic (sign fill)
di_int __lshrdi3(di_int a, si_int b); // a >> b logical (zero fill)
ti_int __lshrti3(ti_int a, si_int b); // a >> b logical (zero fill)
si_int __clzsi2(si_int a); // count leading zeros
si_int __clzdi2(di_int a); // count leading zeros
si_int __clzti2(ti_int a); // count leading zeros
si_int __ctzsi2(si_int a); // count trailing zeros
si_int __ctzdi2(di_int a); // count trailing zeros
si_int __ctzti2(ti_int a); // count trailing zeros
int __clzsi2(si_int a); // count leading zeros
int __clzdi2(di_int a); // count leading zeros
int __clzti2(ti_int a); // count leading zeros
int __ctzsi2(si_int a); // count trailing zeros
int __ctzdi2(di_int a); // count trailing zeros
int __ctzti2(ti_int a); // count trailing zeros
si_int __ffssi2(si_int a); // find least significant 1 bit
si_int __ffsdi2(di_int a); // find least significant 1 bit
si_int __ffsti2(ti_int a); // find least significant 1 bit
int __ffssi2(si_int a); // find least significant 1 bit
int __ffsdi2(di_int a); // find least significant 1 bit
int __ffsti2(ti_int a); // find least significant 1 bit
si_int __paritysi2(si_int a); // bit parity
si_int __paritydi2(di_int a); // bit parity
si_int __parityti2(ti_int a); // bit parity
int __paritysi2(si_int a); // bit parity
int __paritydi2(di_int a); // bit parity
int __parityti2(ti_int a); // bit parity
si_int __popcountsi2(si_int a); // bit population
si_int __popcountdi2(di_int a); // bit population
si_int __popcountti2(ti_int a); // bit population
int __popcountsi2(si_int a); // bit population
int __popcountdi2(di_int a); // bit population
int __popcountti2(ti_int a); // bit population
uint32_t __bswapsi2(uint32_t a); // a byteswapped
uint64_t __bswapdi2(uint64_t a); // a byteswapped
@ -169,10 +174,10 @@ long double __floatuntixf(tu_int a);
// Floating point raised to integer power
float __powisf2( float a, si_int b); // a ^ b
double __powidf2( double a, si_int b); // a ^ b
long double __powixf2(long double a, si_int b); // a ^ b
long double __powitf2(long double a, si_int b); // ppc only, a ^ b
float __powisf2( float a, int b); // a ^ b
double __powidf2( double a, int b); // a ^ b
long double __powixf2(long double a, int b); // a ^ b
long double __powitf2(long double a, int b); // ppc only, a ^ b
// Complex arithmetic

View File

@ -21,12 +21,12 @@
// ctz instruction, gcc resolves __builtin_clz to __clzdi2 rather than
// __clzsi2, leading to infinite recursion.
#define __builtin_clz(a) __clzsi2(a)
extern si_int __clzsi2(si_int);
extern int __clzsi2(si_int);
#endif
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzdi2(di_int a) {
COMPILER_RT_ABI int __clzdi2(di_int a) {
dwords x;
x.all = a;
const si_int f = -(x.s.high == 0);

View File

@ -16,7 +16,7 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzsi2(si_int a) {
COMPILER_RT_ABI int __clzsi2(si_int a) {
su_int x = (su_int)a;
si_int t = ((x & 0xFFFF0000) == 0) << 4; // if (x is small) t = 16 else 0
x >>= 16 - t; // x = [0 - 0xFFFF]

View File

@ -18,7 +18,7 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzti2(ti_int a) {
COMPILER_RT_ABI int __clzti2(ti_int a) {
twords x;
x.all = a;
const di_int f = -(x.s.high == 0);

View File

@ -21,7 +21,7 @@
// ctz instruction, gcc resolves __builtin_ctz to __ctzdi2 rather than
// __ctzsi2, leading to infinite recursion.
#define __builtin_ctz(a) __ctzsi2(a)
extern si_int __ctzsi2(si_int);
extern int __ctzsi2(si_int);
#endif
// Precondition: a != 0

View File

@ -16,7 +16,7 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __ctzsi2(si_int a) {
COMPILER_RT_ABI int __ctzsi2(si_int a) {
su_int x = (su_int)a;
si_int t = ((x & 0x0000FFFF) == 0)
<< 4; // if (x has no small bits) t = 16 else 0

View File

@ -18,7 +18,7 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __ctzti2(ti_int a) {
COMPILER_RT_ABI int __ctzti2(ti_int a) {
twords x;
x.all = a;
const di_int f = -(x.s.low == 0);

View File

@ -17,7 +17,7 @@
// Returns: the index of the least significant 1-bit in a, or
// the value zero if a is zero. The least significant bit is index one.
COMPILER_RT_ABI si_int __ffsti2(ti_int a) {
COMPILER_RT_ABI int __ffsti2(ti_int a) {
twords x;
x.all = a;
if (x.s.low == 0) {

View File

@ -92,8 +92,8 @@
// Include internal utility function declarations.
#include "int_util.h"
COMPILER_RT_ABI si_int __paritysi2(si_int a);
COMPILER_RT_ABI si_int __paritydi2(di_int a);
COMPILER_RT_ABI int __paritysi2(si_int a);
COMPILER_RT_ABI int __paritydi2(di_int a);
COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
@ -102,7 +102,7 @@ COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);
COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int *rem);
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem);
#ifdef CRT_HAS_128BIT
COMPILER_RT_ABI si_int __clzti2(ti_int a);
COMPILER_RT_ABI int __clzti2(ti_int a);
COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int *rem);
#endif
@ -110,14 +110,14 @@ COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int *rem);
#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
uint32_t __inline __builtin_ctz(uint32_t value) {
int __inline __builtin_ctz(uint32_t value) {
unsigned long trailing_zero = 0;
if (_BitScanForward(&trailing_zero, value))
return trailing_zero;
return 32;
}
uint32_t __inline __builtin_clz(uint32_t value) {
int __inline __builtin_clz(uint32_t value) {
unsigned long leading_zero = 0;
if (_BitScanReverse(&leading_zero, value))
return 31 - leading_zero;
@ -125,14 +125,14 @@ uint32_t __inline __builtin_clz(uint32_t value) {
}
#if defined(_M_ARM) || defined(_M_X64)
uint32_t __inline __builtin_clzll(uint64_t value) {
int __inline __builtin_clzll(uint64_t value) {
unsigned long leading_zero = 0;
if (_BitScanReverse64(&leading_zero, value))
return 63 - leading_zero;
return 64;
}
#else
uint32_t __inline __builtin_clzll(uint64_t value) {
int __inline __builtin_clzll(uint64_t value) {
if (value == 0)
return 64;
uint32_t msh = (uint32_t)(value >> 32);

View File

@ -14,7 +14,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __paritydi2(di_int a) {
COMPILER_RT_ABI int __paritydi2(di_int a) {
dwords x;
x.all = a;
return __paritysi2(x.s.high ^ x.s.low);

View File

@ -14,7 +14,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __paritysi2(si_int a) {
COMPILER_RT_ABI int __paritysi2(si_int a) {
su_int x = (su_int)a;
x ^= x >> 16;
x ^= x >> 8;

View File

@ -16,7 +16,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __parityti2(ti_int a) {
COMPILER_RT_ABI int __parityti2(ti_int a) {
twords x;
x.all = a;
return __paritydi2(x.s.high ^ x.s.low);

View File

@ -14,7 +14,7 @@
// Returns: count of 1 bits
COMPILER_RT_ABI si_int __popcountsi2(si_int a) {
COMPILER_RT_ABI int __popcountsi2(si_int a) {
su_int x = (su_int)a;
x = x - ((x >> 1) & 0x55555555);
// Every 2 bits holds the sum of every pair of bits

View File

@ -17,7 +17,7 @@
// Returns: count of 1 bits
COMPILER_RT_ABI si_int __popcountti2(ti_int a) {
COMPILER_RT_ABI int __popcountti2(ti_int a) {
tu_int x3 = (tu_int)a;
x3 = x3 - ((x3 >> 1) &
(((tu_int)0x5555555555555555uLL << 64) | 0x5555555555555555uLL));

View File

@ -14,7 +14,7 @@
// Returns: a ^ b
COMPILER_RT_ABI double __powidf2(double a, si_int b) {
COMPILER_RT_ABI double __powidf2(double a, int b) {
const int recip = b < 0;
double r = 1;
while (1) {

View File

@ -14,7 +14,7 @@
// Returns: a ^ b
COMPILER_RT_ABI float __powisf2(float a, si_int b) {
COMPILER_RT_ABI float __powisf2(float a, int b) {
const int recip = b < 0;
float r = 1;
while (1) {

View File

@ -17,7 +17,7 @@
// Returns: a ^ b
COMPILER_RT_ABI long double __powitf2(long double a, si_int b) {
COMPILER_RT_ABI long double __powitf2(long double a, int b) {
const int recip = b < 0;
long double r = 1;
while (1) {

View File

@ -16,7 +16,7 @@
// Returns: a ^ b
COMPILER_RT_ABI long double __powixf2(long double a, si_int b) {
COMPILER_RT_ABI long double __powixf2(long double a, int b) {
const int recip = b < 0;
long double r = 1;
while (1) {

View File

@ -8,11 +8,11 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzdi2(di_int a);
COMPILER_RT_ABI int __clzdi2(di_int a);
int test__clzdi2(di_int a, si_int expected)
int test__clzdi2(di_int a, int expected)
{
si_int x = __clzdi2(a);
int x = __clzdi2(a);
if (x != expected)
printf("error in __clzdi2(0x%llX) = %d, expected %d\n", a, x, expected);
return x != expected;

View File

@ -8,11 +8,11 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzsi2(si_int a);
COMPILER_RT_ABI int __clzsi2(si_int a);
int test__clzsi2(si_int a, si_int expected)
int test__clzsi2(si_int a, int expected)
{
si_int x = __clzsi2(a);
int x = __clzsi2(a);
if (x != expected)
printf("error in __clzsi2(0x%X) = %d, expected %d\n", a, x, expected);
return x != expected;

View File

@ -11,11 +11,11 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __clzti2(ti_int a);
COMPILER_RT_ABI int __clzti2(ti_int a);
int test__clzti2(ti_int a, si_int expected)
int test__clzti2(ti_int a, int expected)
{
si_int x = __clzti2(a);
int x = __clzti2(a);
if (x != expected)
{
twords at;

View File

@ -8,11 +8,11 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __ctzsi2(si_int a);
COMPILER_RT_ABI int __ctzsi2(si_int a);
int test__ctzsi2(si_int a, si_int expected)
int test__ctzsi2(si_int a, int expected)
{
si_int x = __ctzsi2(a);
int x = __ctzsi2(a);
if (x != expected)
printf("error in __ctzsi2(0x%X) = %d, expected %d\n", a, x, expected);
return x != expected;

View File

@ -11,11 +11,11 @@
// Precondition: a != 0
COMPILER_RT_ABI si_int __ctzti2(ti_int a);
COMPILER_RT_ABI int __ctzti2(ti_int a);
int test__ctzti2(ti_int a, si_int expected)
int test__ctzti2(ti_int a, int expected)
{
si_int x = __ctzti2(a);
int x = __ctzti2(a);
if (x != expected)
{
twords at;

View File

@ -10,11 +10,11 @@
// Returns: the index of the least significant 1-bit in a, or
// the value zero if a is zero. The least significant bit is index one.
COMPILER_RT_ABI si_int __ffsti2(ti_int a);
COMPILER_RT_ABI int __ffsti2(ti_int a);
int test__ffsti2(ti_int a, si_int expected)
int test__ffsti2(ti_int a, int expected)
{
si_int x = __ffsti2(a);
int x = __ffsti2(a);
if (x != expected)
{
twords at;

View File

@ -7,7 +7,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __paritydi2(di_int a);
COMPILER_RT_ABI int __paritydi2(di_int a);
int naive_parity(di_int a)
{

View File

@ -7,7 +7,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __paritysi2(si_int a);
COMPILER_RT_ABI int __paritysi2(si_int a);
int naive_parity(si_int a)
{

View File

@ -10,7 +10,7 @@
// Returns: 1 if number of bits is odd else returns 0
COMPILER_RT_ABI si_int __parityti2(ti_int a);
COMPILER_RT_ABI int __parityti2(ti_int a);
int naive_parity(ti_int a)
{

View File

@ -7,7 +7,7 @@
// Returns: count of 1 bits
COMPILER_RT_ABI si_int __popcountsi2(si_int a);
COMPILER_RT_ABI int __popcountsi2(si_int a);
int naive_popcount(si_int a)
{

View File

@ -10,7 +10,7 @@
// Returns: count of 1 bits
COMPILER_RT_ABI si_int __popcountti2(ti_int a);
COMPILER_RT_ABI int __popcountti2(ti_int a);
int naive_popcount(ti_int a)
{

View File

@ -7,9 +7,9 @@
// Returns: a ^ b
COMPILER_RT_ABI double __powidf2(double a, si_int b);
COMPILER_RT_ABI double __powidf2(double a, int b);
int test__powidf2(double a, si_int b, double expected)
int test__powidf2(double a, int b, double expected)
{
double x = __powidf2(a, b);
int correct = (x == expected) && (signbit(x) == signbit(expected));
@ -51,9 +51,9 @@ int main()
return 1;
if (test__powidf2(0, 4, 0))
return 1;
if (test__powidf2(0, 0x7FFFFFFE, 0))
if (test__powidf2(0, INT_MAX - 1, 0))
return 1;
if (test__powidf2(0, 0x7FFFFFFF, 0))
if (test__powidf2(0, INT_MAX, 0))
return 1;
if (test__powidf2(-0., 1, -0.))
@ -64,9 +64,9 @@ int main()
return 1;
if (test__powidf2(-0., 4, 0))
return 1;
if (test__powidf2(-0., 0x7FFFFFFE, 0))
if (test__powidf2(-0., INT_MAX - 1, 0))
return 1;
if (test__powidf2(-0., 0x7FFFFFFF, -0.))
if (test__powidf2(-0., INT_MAX, -0.))
return 1;
if (test__powidf2(1, 1, 1))
@ -77,9 +77,9 @@ int main()
return 1;
if (test__powidf2(1, 4, 1))
return 1;
if (test__powidf2(1, 0x7FFFFFFE, 1))
if (test__powidf2(1, INT_MAX - 1, 1))
return 1;
if (test__powidf2(1, 0x7FFFFFFF, 1))
if (test__powidf2(1, INT_MAX, 1))
return 1;
if (test__powidf2(INFINITY, 1, INFINITY))
@ -90,9 +90,9 @@ int main()
return 1;
if (test__powidf2(INFINITY, 4, INFINITY))
return 1;
if (test__powidf2(INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powidf2(INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powidf2(INFINITY, 0x7FFFFFFF, INFINITY))
if (test__powidf2(INFINITY, INT_MAX, INFINITY))
return 1;
if (test__powidf2(-INFINITY, 1, -INFINITY))
@ -103,9 +103,9 @@ int main()
return 1;
if (test__powidf2(-INFINITY, 4, INFINITY))
return 1;
if (test__powidf2(-INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powidf2(-INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powidf2(-INFINITY, 0x7FFFFFFF, -INFINITY))
if (test__powidf2(-INFINITY, INT_MAX, -INFINITY))
return 1;
if (test__powidf2(0, -1, INFINITY))
@ -116,11 +116,11 @@ int main()
return 1;
if (test__powidf2(0, -4, INFINITY))
return 1;
if (test__powidf2(0, 0x80000002, INFINITY))
if (test__powidf2(0, INT_MIN + 2, INFINITY))
return 1;
if (test__powidf2(0, 0x80000001, INFINITY))
if (test__powidf2(0, INT_MIN + 1, INFINITY))
return 1;
if (test__powidf2(0, 0x80000000, INFINITY))
if (test__powidf2(0, INT_MIN, INFINITY))
return 1;
if (test__powidf2(-0., -1, -INFINITY))
@ -131,11 +131,11 @@ int main()
return 1;
if (test__powidf2(-0., -4, INFINITY))
return 1;
if (test__powidf2(-0., 0x80000002, INFINITY))
if (test__powidf2(-0., INT_MIN + 2, INFINITY))
return 1;
if (test__powidf2(-0., 0x80000001, -INFINITY))
if (test__powidf2(-0., INT_MIN + 1, -INFINITY))
return 1;
if (test__powidf2(-0., 0x80000000, INFINITY))
if (test__powidf2(-0., INT_MIN, INFINITY))
return 1;
if (test__powidf2(1, -1, 1))
@ -146,11 +146,11 @@ int main()
return 1;
if (test__powidf2(1, -4, 1))
return 1;
if (test__powidf2(1, 0x80000002, 1))
if (test__powidf2(1, INT_MIN + 2, 1))
return 1;
if (test__powidf2(1, 0x80000001, 1))
if (test__powidf2(1, INT_MIN + 1, 1))
return 1;
if (test__powidf2(1, 0x80000000, 1))
if (test__powidf2(1, INT_MIN, 1))
return 1;
if (test__powidf2(INFINITY, -1, 0))
@ -161,11 +161,11 @@ int main()
return 1;
if (test__powidf2(INFINITY, -4, 0))
return 1;
if (test__powidf2(INFINITY, 0x80000002, 0))
if (test__powidf2(INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powidf2(INFINITY, 0x80000001, 0))
if (test__powidf2(INFINITY, INT_MIN + 1, 0))
return 1;
if (test__powidf2(INFINITY, 0x80000000, 0))
if (test__powidf2(INFINITY, INT_MIN, 0))
return 1;
if (test__powidf2(-INFINITY, -1, -0.))
@ -176,11 +176,11 @@ int main()
return 1;
if (test__powidf2(-INFINITY, -4, 0))
return 1;
if (test__powidf2(-INFINITY, 0x80000002, 0))
if (test__powidf2(-INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powidf2(-INFINITY, 0x80000001, -0.))
if (test__powidf2(-INFINITY, INT_MIN + 1, -0.))
return 1;
if (test__powidf2(-INFINITY, 0x80000000, 0))
if (test__powidf2(-INFINITY, INT_MIN, 0))
return 1;
if (test__powidf2(2, 10, 1024.))

View File

@ -7,9 +7,9 @@
// Returns: a ^ b
COMPILER_RT_ABI float __powisf2(float a, si_int b);
COMPILER_RT_ABI float __powisf2(float a, int b);
int test__powisf2(float a, si_int b, float expected)
int test__powisf2(float a, int b, float expected)
{
float x = __powisf2(a, b);
int correct = (x == expected) && (signbit(x) == signbit(expected));
@ -51,9 +51,9 @@ int main()
return 1;
if (test__powisf2(0, 4, 0))
return 1;
if (test__powisf2(0, 0x7FFFFFFE, 0))
if (test__powisf2(0, INT_MAX -1, 0))
return 1;
if (test__powisf2(0, 0x7FFFFFFF, 0))
if (test__powisf2(0, INT_MAX, 0))
return 1;
if (test__powisf2(-0., 1, -0.))
@ -64,9 +64,9 @@ int main()
return 1;
if (test__powisf2(-0., 4, 0))
return 1;
if (test__powisf2(-0., 0x7FFFFFFE, 0))
if (test__powisf2(-0., INT_MAX - 1, 0))
return 1;
if (test__powisf2(-0., 0x7FFFFFFF, -0.))
if (test__powisf2(-0., INT_MAX, -0.))
return 1;
if (test__powisf2(1, 1, 1))
@ -77,9 +77,9 @@ int main()
return 1;
if (test__powisf2(1, 4, 1))
return 1;
if (test__powisf2(1, 0x7FFFFFFE, 1))
if (test__powisf2(1, INT_MAX - 1, 1))
return 1;
if (test__powisf2(1, 0x7FFFFFFF, 1))
if (test__powisf2(1, INT_MAX, 1))
return 1;
if (test__powisf2(INFINITY, 1, INFINITY))
@ -90,9 +90,9 @@ int main()
return 1;
if (test__powisf2(INFINITY, 4, INFINITY))
return 1;
if (test__powisf2(INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powisf2(INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powisf2(INFINITY, 0x7FFFFFFF, INFINITY))
if (test__powisf2(INFINITY, INT_MAX, INFINITY))
return 1;
if (test__powisf2(-INFINITY, 1, -INFINITY))
@ -103,9 +103,9 @@ int main()
return 1;
if (test__powisf2(-INFINITY, 4, INFINITY))
return 1;
if (test__powisf2(-INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powisf2(-INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powisf2(-INFINITY, 0x7FFFFFFF, -INFINITY))
if (test__powisf2(-INFINITY, INT_MAX, -INFINITY))
return 1;
if (test__powisf2(0, -1, INFINITY))
@ -116,11 +116,11 @@ int main()
return 1;
if (test__powisf2(0, -4, INFINITY))
return 1;
if (test__powisf2(0, 0x80000002, INFINITY))
if (test__powisf2(0, INT_MIN + 2, INFINITY))
return 1;
if (test__powisf2(0, 0x80000001, INFINITY))
if (test__powisf2(0, INT_MIN + 1, INFINITY))
return 1;
if (test__powisf2(0, 0x80000000, INFINITY))
if (test__powisf2(0, INT_MIN, INFINITY))
return 1;
if (test__powisf2(-0., -1, -INFINITY))
@ -131,11 +131,11 @@ int main()
return 1;
if (test__powisf2(-0., -4, INFINITY))
return 1;
if (test__powisf2(-0., 0x80000002, INFINITY))
if (test__powisf2(-0., INT_MIN + 2, INFINITY))
return 1;
if (test__powisf2(-0., 0x80000001, -INFINITY))
if (test__powisf2(-0., INT_MIN + 1, -INFINITY))
return 1;
if (test__powisf2(-0., 0x80000000, INFINITY))
if (test__powisf2(-0., INT_MIN, INFINITY))
return 1;
if (test__powisf2(1, -1, 1))
@ -146,11 +146,11 @@ int main()
return 1;
if (test__powisf2(1, -4, 1))
return 1;
if (test__powisf2(1, 0x80000002, 1))
if (test__powisf2(1, INT_MIN + 2, 1))
return 1;
if (test__powisf2(1, 0x80000001, 1))
if (test__powisf2(1, INT_MIN + 1, 1))
return 1;
if (test__powisf2(1, 0x80000000, 1))
if (test__powisf2(1, INT_MIN, 1))
return 1;
if (test__powisf2(INFINITY, -1, 0))
@ -161,11 +161,11 @@ int main()
return 1;
if (test__powisf2(INFINITY, -4, 0))
return 1;
if (test__powisf2(INFINITY, 0x80000002, 0))
if (test__powisf2(INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powisf2(INFINITY, 0x80000001, 0))
if (test__powisf2(INFINITY, INT_MIN + 1, 0))
return 1;
if (test__powisf2(INFINITY, 0x80000000, 0))
if (test__powisf2(INFINITY, INT_MIN, 0))
return 1;
if (test__powisf2(-INFINITY, -1, -0.))
@ -176,11 +176,11 @@ int main()
return 1;
if (test__powisf2(-INFINITY, -4, 0))
return 1;
if (test__powisf2(-INFINITY, 0x80000002, 0))
if (test__powisf2(-INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powisf2(-INFINITY, 0x80000001, -0.))
if (test__powisf2(-INFINITY, INT_MIN + 1, -0.))
return 1;
if (test__powisf2(-INFINITY, 0x80000000, 0))
if (test__powisf2(-INFINITY, INT_MIN, 0))
return 1;
if (test__powisf2(2, 10, 1024.))

View File

@ -10,9 +10,9 @@
// Returns: a ^ b
COMPILER_RT_ABI long double __powitf2(long double a, si_int b);
COMPILER_RT_ABI long double __powitf2(long double a, int b);
int test__powitf2(long double a, si_int b, long double expected)
int test__powitf2(long double a, int b, long double expected)
{
long double x = __powitf2(a, b);
int correct = (x == expected) && (signbit(x) == signbit(expected));
@ -57,9 +57,9 @@ int main()
return 1;
if (test__powitf2(0, 4, 0))
return 1;
if (test__powitf2(0, 0x7FFFFFFE, 0))
if (test__powitf2(0, INT_MAX - 1, 0))
return 1;
if (test__powitf2(0, 0x7FFFFFFF, 0))
if (test__powitf2(0, INT_MAX, 0))
return 1;
if (test__powitf2(-0., 1, -0.))
@ -70,9 +70,9 @@ int main()
return 1;
if (test__powitf2(-0., 4, 0))
return 1;
if (test__powitf2(-0., 0x7FFFFFFE, 0))
if (test__powitf2(-0., INT_MAX - 1, 0))
return 1;
if (test__powitf2(-0., 0x7FFFFFFF, -0.))
if (test__powitf2(-0., INT_MAX, -0.))
return 1;
if (test__powitf2(1, 1, 1))
@ -83,9 +83,9 @@ int main()
return 1;
if (test__powitf2(1, 4, 1))
return 1;
if (test__powitf2(1, 0x7FFFFFFE, 1))
if (test__powitf2(1, INT_MAX - 1, 1))
return 1;
if (test__powitf2(1, 0x7FFFFFFF, 1))
if (test__powitf2(1, INT_MAX, 1))
return 1;
if (test__powitf2(INFINITY, 1, INFINITY))
@ -96,9 +96,9 @@ int main()
return 1;
if (test__powitf2(INFINITY, 4, INFINITY))
return 1;
if (test__powitf2(INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powitf2(INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powitf2(INFINITY, 0x7FFFFFFF, INFINITY))
if (test__powitf2(INFINITY, INT_MAX, INFINITY))
return 1;
if (test__powitf2(-INFINITY, 1, -INFINITY))
@ -109,9 +109,9 @@ int main()
return 1;
if (test__powitf2(-INFINITY, 4, INFINITY))
return 1;
if (test__powitf2(-INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powitf2(-INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powitf2(-INFINITY, 0x7FFFFFFF, -INFINITY))
if (test__powitf2(-INFINITY, INT_MAX, -INFINITY))
return 1;
if (test__powitf2(0, -1, INFINITY))
@ -122,11 +122,11 @@ int main()
return 1;
if (test__powitf2(0, -4, INFINITY))
return 1;
if (test__powitf2(0, 0x80000002, INFINITY))
if (test__powitf2(0, INT_MIN + 2, INFINITY))
return 1;
if (test__powitf2(0, 0x80000001, INFINITY))
if (test__powitf2(0, INT_MIN + 1, INFINITY))
return 1;
if (test__powitf2(0, 0x80000000, INFINITY))
if (test__powitf2(0, INT_MIN, INFINITY))
return 1;
if (test__powitf2(-0., -1, -INFINITY))
@ -137,11 +137,11 @@ int main()
return 1;
if (test__powitf2(-0., -4, INFINITY))
return 1;
if (test__powitf2(-0., 0x80000002, INFINITY))
if (test__powitf2(-0., INT_MIN + 2, INFINITY))
return 1;
if (test__powitf2(-0., 0x80000001, -INFINITY))
if (test__powitf2(-0., INT_MIN + 1, -INFINITY))
return 1;
if (test__powitf2(-0., 0x80000000, INFINITY))
if (test__powitf2(-0., INT_MIN, INFINITY))
return 1;
if (test__powitf2(1, -1, 1))
@ -152,11 +152,11 @@ int main()
return 1;
if (test__powitf2(1, -4, 1))
return 1;
if (test__powitf2(1, 0x80000002, 1))
if (test__powitf2(1, INT_MIN + 2, 1))
return 1;
if (test__powitf2(1, 0x80000001, 1))
if (test__powitf2(1, INT_MIN + 1, 1))
return 1;
if (test__powitf2(1, 0x80000000, 1))
if (test__powitf2(1, INT_MIN, 1))
return 1;
if (test__powitf2(INFINITY, -1, 0))
@ -167,11 +167,11 @@ int main()
return 1;
if (test__powitf2(INFINITY, -4, 0))
return 1;
if (test__powitf2(INFINITY, 0x80000002, 0))
if (test__powitf2(INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powitf2(INFINITY, 0x80000001, 0))
if (test__powitf2(INFINITY, INT_MIN + 1, 0))
return 1;
if (test__powitf2(INFINITY, 0x80000000, 0))
if (test__powitf2(INFINITY, INT_MIN, 0))
return 1;
if (test__powitf2(-INFINITY, -1, -0.))
@ -182,11 +182,11 @@ int main()
return 1;
if (test__powitf2(-INFINITY, -4, 0))
return 1;
if (test__powitf2(-INFINITY, 0x80000002, 0))
if (test__powitf2(-INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powitf2(-INFINITY, 0x80000001, -0.))
if (test__powitf2(-INFINITY, INT_MIN + 1, -0.))
return 1;
if (test__powitf2(-INFINITY, 0x80000000, 0))
if (test__powitf2(-INFINITY, INT_MIN, 0))
return 1;
if (test__powitf2(2, 10, 1024.))

View File

@ -11,9 +11,9 @@
// Returns: a ^ b
COMPILER_RT_ABI long double __powixf2(long double a, si_int b);
COMPILER_RT_ABI long double __powixf2(long double a, int b);
int test__powixf2(long double a, si_int b, long double expected)
int test__powixf2(long double a, int b, long double expected)
{
long double x = __powixf2(a, b);
int correct = (x == expected) && (signbit(x) == signbit(expected));
@ -58,9 +58,9 @@ int main()
return 1;
if (test__powixf2(0, 4, 0))
return 1;
if (test__powixf2(0, 0x7FFFFFFE, 0))
if (test__powixf2(0, INT_MAX - 1, 0))
return 1;
if (test__powixf2(0, 0x7FFFFFFF, 0))
if (test__powixf2(0, INT_MAX, 0))
return 1;
if (test__powixf2(-0., 1, -0.))
@ -71,9 +71,9 @@ int main()
return 1;
if (test__powixf2(-0., 4, 0))
return 1;
if (test__powixf2(-0., 0x7FFFFFFE, 0))
if (test__powixf2(-0., INT_MAX - 1, 0))
return 1;
if (test__powixf2(-0., 0x7FFFFFFF, -0.))
if (test__powixf2(-0., INT_MAX, -0.))
return 1;
if (test__powixf2(1, 1, 1))
@ -84,9 +84,9 @@ int main()
return 1;
if (test__powixf2(1, 4, 1))
return 1;
if (test__powixf2(1, 0x7FFFFFFE, 1))
if (test__powixf2(1, INT_MAX - 1, 1))
return 1;
if (test__powixf2(1, 0x7FFFFFFF, 1))
if (test__powixf2(1, INT_MAX, 1))
return 1;
if (test__powixf2(INFINITY, 1, INFINITY))
@ -97,9 +97,9 @@ int main()
return 1;
if (test__powixf2(INFINITY, 4, INFINITY))
return 1;
if (test__powixf2(INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powixf2(INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powixf2(INFINITY, 0x7FFFFFFF, INFINITY))
if (test__powixf2(INFINITY, INT_MAX, INFINITY))
return 1;
if (test__powixf2(-INFINITY, 1, -INFINITY))
@ -110,9 +110,9 @@ int main()
return 1;
if (test__powixf2(-INFINITY, 4, INFINITY))
return 1;
if (test__powixf2(-INFINITY, 0x7FFFFFFE, INFINITY))
if (test__powixf2(-INFINITY, INT_MAX - 1, INFINITY))
return 1;
if (test__powixf2(-INFINITY, 0x7FFFFFFF, -INFINITY))
if (test__powixf2(-INFINITY, INT_MAX, -INFINITY))
return 1;
if (test__powixf2(0, -1, INFINITY))
@ -123,11 +123,11 @@ int main()
return 1;
if (test__powixf2(0, -4, INFINITY))
return 1;
if (test__powixf2(0, 0x80000002, INFINITY))
if (test__powixf2(0, INT_MIN + 2, INFINITY))
return 1;
if (test__powixf2(0, 0x80000001, INFINITY))
if (test__powixf2(0, INT_MIN + 1, INFINITY))
return 1;
if (test__powixf2(0, 0x80000000, INFINITY))
if (test__powixf2(0, INT_MIN, INFINITY))
return 1;
if (test__powixf2(-0., -1, -INFINITY))
@ -138,11 +138,11 @@ int main()
return 1;
if (test__powixf2(-0., -4, INFINITY))
return 1;
if (test__powixf2(-0., 0x80000002, INFINITY))
if (test__powixf2(-0., INT_MIN + 2, INFINITY))
return 1;
if (test__powixf2(-0., 0x80000001, -INFINITY))
if (test__powixf2(-0., INT_MIN + 1, -INFINITY))
return 1;
if (test__powixf2(-0., 0x80000000, INFINITY))
if (test__powixf2(-0., INT_MIN, INFINITY))
return 1;
if (test__powixf2(1, -1, 1))
@ -153,11 +153,11 @@ int main()
return 1;
if (test__powixf2(1, -4, 1))
return 1;
if (test__powixf2(1, 0x80000002, 1))
if (test__powixf2(1, INT_MIN + 2, 1))
return 1;
if (test__powixf2(1, 0x80000001, 1))
if (test__powixf2(1, INT_MIN + 1, 1))
return 1;
if (test__powixf2(1, 0x80000000, 1))
if (test__powixf2(1, INT_MIN, 1))
return 1;
if (test__powixf2(INFINITY, -1, 0))
@ -168,11 +168,11 @@ int main()
return 1;
if (test__powixf2(INFINITY, -4, 0))
return 1;
if (test__powixf2(INFINITY, 0x80000002, 0))
if (test__powixf2(INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powixf2(INFINITY, 0x80000001, 0))
if (test__powixf2(INFINITY, INT_MIN + 1, 0))
return 1;
if (test__powixf2(INFINITY, 0x80000000, 0))
if (test__powixf2(INFINITY, INT_MIN, 0))
return 1;
if (test__powixf2(-INFINITY, -1, -0.))
@ -183,11 +183,11 @@ int main()
return 1;
if (test__powixf2(-INFINITY, -4, 0))
return 1;
if (test__powixf2(-INFINITY, 0x80000002, 0))
if (test__powixf2(-INFINITY, INT_MIN + 2, 0))
return 1;
if (test__powixf2(-INFINITY, 0x80000001, -0.))
if (test__powixf2(-INFINITY, INT_MIN + 1, -0.))
return 1;
if (test__powixf2(-INFINITY, 0x80000000, 0))
if (test__powixf2(-INFINITY, INT_MIN, 0))
return 1;
if (test__powixf2(2, 10, 1024.))