aboutsummaryrefslogtreecommitdiff
path: root/test/builtins
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
commitca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch)
tree9b19e801150082c33e9152275829a6ce90614b55 /test/builtins
parent8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff)
downloadsrc-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.tar.gz
src-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.zip
Import compiler-rt trunk r224034.vendor/compiler-rt/compiler-rt-r224034
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=276789 svn path=/vendor/compiler-rt/compiler-rt-r224034/; revision=276790; tag=vendor/compiler-rt/compiler-rt-r224034
Diffstat (limited to 'test/builtins')
-rw-r--r--test/builtins/Unit/absvdi2_test.c65
-rw-r--r--test/builtins/Unit/absvsi2_test.c65
-rw-r--r--test/builtins/Unit/absvti2_test.c84
-rw-r--r--test/builtins/Unit/adddf3vfp_test.c48
-rw-r--r--test/builtins/Unit/addsf3vfp_test.c48
-rw-r--r--test/builtins/Unit/addtf3_test.c81
-rw-r--r--test/builtins/Unit/addvdi3_test.c58
-rw-r--r--test/builtins/Unit/addvsi3_test.c58
-rw-r--r--test/builtins/Unit/addvti3_test.c94
-rw-r--r--test/builtins/Unit/ashldi3_test.c77
-rw-r--r--test/builtins/Unit/ashlti3_test.c175
-rw-r--r--test/builtins/Unit/ashrdi3_test.c118
-rw-r--r--test/builtins/Unit/ashrti3_test.c173
-rw-r--r--test/builtins/Unit/bswapdi2_test.c44
-rw-r--r--test/builtins/Unit/bswapsi2_test.c44
-rw-r--r--test/builtins/Unit/clear_cache_test.c76
-rw-r--r--test/builtins/Unit/clzdi2_test.c68
-rw-r--r--test/builtins/Unit/clzsi2_test.c599
-rw-r--r--test/builtins/Unit/clzti2_test.c90
-rw-r--r--test/builtins/Unit/cmpdi2_test.c77
-rw-r--r--test/builtins/Unit/cmpti2_test.c112
-rw-r--r--test/builtins/Unit/comparedf2_test.c479
-rw-r--r--test/builtins/Unit/comparesf2_test.c479
-rw-r--r--test/builtins/Unit/ctzdi2_test.c67
-rw-r--r--test/builtins/Unit/ctzsi2_test.c569
-rw-r--r--test/builtins/Unit/ctzti2_test.c84
-rw-r--r--test/builtins/Unit/divdc3_test.c370
-rw-r--r--test/builtins/Unit/divdf3vfp_test.c48
-rw-r--r--test/builtins/Unit/divdi3_test.c58
-rw-r--r--test/builtins/Unit/divmodsi4_test.c73
-rw-r--r--test/builtins/Unit/divsc3_test.c370
-rw-r--r--test/builtins/Unit/divsf3vfp_test.c48
-rw-r--r--test/builtins/Unit/divsi3_test.c56
-rw-r--r--test/builtins/Unit/divtc3_test.c382
-rw-r--r--test/builtins/Unit/divtf3_test.c94
-rw-r--r--test/builtins/Unit/divti3_test.c78
-rw-r--r--test/builtins/Unit/divxc3_test.c379
-rw-r--r--test/builtins/Unit/enable_execute_stack_test.c72
-rw-r--r--test/builtins/Unit/endianness.h109
-rw-r--r--test/builtins/Unit/eqdf2vfp_test.c55
-rw-r--r--test/builtins/Unit/eqsf2vfp_test.c51
-rw-r--r--test/builtins/Unit/eqtf2_test.c89
-rw-r--r--test/builtins/Unit/extebdsfdf2vfp_test.c48
-rw-r--r--test/builtins/Unit/extenddftf2_test.c82
-rw-r--r--test/builtins/Unit/extendsftf2_test.c83
-rw-r--r--test/builtins/Unit/ffsdi2_test.c66
-rw-r--r--test/builtins/Unit/ffsti2_test.c83
-rw-r--r--test/builtins/Unit/fixdfdi_test.c94
-rw-r--r--test/builtins/Unit/fixdfsivfp_test.c50
-rw-r--r--test/builtins/Unit/fixdfti_test.c123
-rw-r--r--test/builtins/Unit/fixsfdi_test.c84
-rw-r--r--test/builtins/Unit/fixsfsivfp_test.c52
-rw-r--r--test/builtins/Unit/fixsfti_test.c111
-rw-r--r--test/builtins/Unit/fixunsdfdi_test.c106
-rw-r--r--test/builtins/Unit/fixunsdfsi_test.c100
-rw-r--r--test/builtins/Unit/fixunsdfsivfp_test.c50
-rw-r--r--test/builtins/Unit/fixunsdfti_test.c128
-rw-r--r--test/builtins/Unit/fixunssfdi_test.c95
-rw-r--r--test/builtins/Unit/fixunssfsi_test.c93
-rw-r--r--test/builtins/Unit/fixunssfsivfp_test.c50
-rw-r--r--test/builtins/Unit/fixunssfti_test.c120
-rw-r--r--test/builtins/Unit/fixunstfdi_test.c121
-rw-r--r--test/builtins/Unit/fixunsxfdi_test.c124
-rw-r--r--test/builtins/Unit/fixunsxfsi_test.c105
-rw-r--r--test/builtins/Unit/fixunsxfti_test.c141
-rw-r--r--test/builtins/Unit/fixxfdi_test.c115
-rw-r--r--test/builtins/Unit/fixxfti_test.c146
-rw-r--r--test/builtins/Unit/floatdidf_test.c137
-rw-r--r--test/builtins/Unit/floatdisf_test.c95
-rw-r--r--test/builtins/Unit/floatdixf_test.c144
-rw-r--r--test/builtins/Unit/floatsidfvfp_test.c50
-rw-r--r--test/builtins/Unit/floatsisfvfp_test.c50
-rw-r--r--test/builtins/Unit/floatsitf_test.c58
-rw-r--r--test/builtins/Unit/floattidf_test.c180
-rw-r--r--test/builtins/Unit/floattisf_test.c136
-rw-r--r--test/builtins/Unit/floattixf_test.c212
-rw-r--r--test/builtins/Unit/floatundidf_test.c132
-rw-r--r--test/builtins/Unit/floatundisf_test.c96
-rw-r--r--test/builtins/Unit/floatundixf_test.c145
-rw-r--r--test/builtins/Unit/floatunsitf_test.c55
-rw-r--r--test/builtins/Unit/floatunssidfvfp_test.c50
-rw-r--r--test/builtins/Unit/floatunssisfvfp_test.c50
-rw-r--r--test/builtins/Unit/floatuntidf_test.c174
-rw-r--r--test/builtins/Unit/floatuntisf_test.c165
-rw-r--r--test/builtins/Unit/floatuntixf_test.c219
-rw-r--r--test/builtins/Unit/fp_test.h223
-rw-r--r--test/builtins/Unit/gcc_personality_test.c42
-rw-r--r--test/builtins/Unit/gcc_personality_test_helper.cxx85
-rw-r--r--test/builtins/Unit/gedf2vfp_test.c53
-rw-r--r--test/builtins/Unit/gesf2vfp_test.c53
-rw-r--r--test/builtins/Unit/getf2_test.c89
-rw-r--r--test/builtins/Unit/gtdf2vfp_test.c53
-rw-r--r--test/builtins/Unit/gtsf2vfp_test.c53
-rw-r--r--test/builtins/Unit/gttf2_test.c89
-rw-r--r--test/builtins/Unit/ledf2vfp_test.c53
-rw-r--r--test/builtins/Unit/lesf2vfp_test.c53
-rw-r--r--test/builtins/Unit/letf2_test.c89
-rw-r--r--test/builtins/Unit/lshrdi3_test.c118
-rw-r--r--test/builtins/Unit/lshrti3_test.c173
-rw-r--r--test/builtins/Unit/ltdf2vfp_test.c51
-rw-r--r--test/builtins/Unit/ltsf2vfp_test.c53
-rw-r--r--test/builtins/Unit/lttf2_test.c89
-rw-r--r--test/builtins/Unit/moddi3_test.c62
-rw-r--r--test/builtins/Unit/modsi3_test.c57
-rw-r--r--test/builtins/Unit/modti3_test.c95
-rw-r--r--test/builtins/Unit/muldc3_test.c366
-rw-r--r--test/builtins/Unit/muldf3vfp_test.c50
-rw-r--r--test/builtins/Unit/muldi3_test.c110
-rw-r--r--test/builtins/Unit/mulodi4_test.c178
-rw-r--r--test/builtins/Unit/mulosi4_test.c156
-rw-r--r--test/builtins/Unit/muloti4_test.c280
-rw-r--r--test/builtins/Unit/mulsc3_test.c370
-rw-r--r--test/builtins/Unit/mulsf3vfp_test.c50
-rw-r--r--test/builtins/Unit/multc3_test.c374
-rw-r--r--test/builtins/Unit/multf3_test.c95
-rw-r--r--test/builtins/Unit/multi3_test.c134
-rw-r--r--test/builtins/Unit/mulvdi3_test.c175
-rw-r--r--test/builtins/Unit/mulvsi3_test.c148
-rw-r--r--test/builtins/Unit/mulvti3_test.c260
-rw-r--r--test/builtins/Unit/mulxc3_test.c375
-rw-r--r--test/builtins/Unit/nedf2vfp_test.c51
-rw-r--r--test/builtins/Unit/negdf2vfp_test.c48
-rw-r--r--test/builtins/Unit/negdi2_test.c84
-rw-r--r--test/builtins/Unit/negsf2vfp_test.c48
-rw-r--r--test/builtins/Unit/negti2_test.c127
-rw-r--r--test/builtins/Unit/negvdi2_test.c57
-rw-r--r--test/builtins/Unit/negvsi2_test.c56
-rw-r--r--test/builtins/Unit/negvti2_test.c109
-rw-r--r--test/builtins/Unit/nesf2vfp_test.c51
-rw-r--r--test/builtins/Unit/netf2_test.c89
-rw-r--r--test/builtins/Unit/paritydi2_test.c51
-rw-r--r--test/builtins/Unit/paritysi2_test.c50
-rw-r--r--test/builtins/Unit/parityti2_test.c64
-rw-r--r--test/builtins/Unit/popcountdi2_test.c63
-rw-r--r--test/builtins/Unit/popcountsi2_test.c62
-rw-r--r--test/builtins/Unit/popcountti2_test.c82
-rw-r--r--test/builtins/Unit/powidf2_test.c224
-rw-r--r--test/builtins/Unit/powisf2_test.c224
-rw-r--r--test/builtins/Unit/powitf2_test.c232
-rw-r--r--test/builtins/Unit/powixf2_test.c232
-rw-r--r--test/builtins/Unit/ppc/DD.h14
-rw-r--r--test/builtins/Unit/ppc/fixtfdi_test.c477
-rw-r--r--test/builtins/Unit/ppc/floatditf_test.c30
-rw-r--r--test/builtins/Unit/ppc/floatditf_test.h38018
-rw-r--r--test/builtins/Unit/ppc/floatunditf_test.c30
-rw-r--r--test/builtins/Unit/ppc/floatunditf_test.h19014
-rw-r--r--test/builtins/Unit/ppc/qadd_test.c1872
-rw-r--r--test/builtins/Unit/ppc/qdiv_test.c795
-rw-r--r--test/builtins/Unit/ppc/qmul_test.c793
-rw-r--r--test/builtins/Unit/ppc/qsub_test.c1874
-rwxr-xr-xtest/builtins/Unit/ppc/test18
-rw-r--r--test/builtins/Unit/subdf3vfp_test.c48
-rw-r--r--test/builtins/Unit/subsf3vfp_test.c48
-rw-r--r--test/builtins/Unit/subtf3_test.c74
-rw-r--r--test/builtins/Unit/subvdi3_test.c60
-rw-r--r--test/builtins/Unit/subvsi3_test.c60
-rw-r--r--test/builtins/Unit/subvti3_test.c80
-rwxr-xr-xtest/builtins/Unit/test68
-rw-r--r--test/builtins/Unit/trampoline_setup_test.c64
-rw-r--r--test/builtins/Unit/truncdfsf2vfp_test.c50
-rw-r--r--test/builtins/Unit/trunctfdf2_test.c76
-rw-r--r--test/builtins/Unit/trunctfsf2_test.c75
-rw-r--r--test/builtins/Unit/ucmpdi2_test.c75
-rw-r--r--test/builtins/Unit/ucmpti2_test.c116
-rw-r--r--test/builtins/Unit/udivdi3_test.c44
-rw-r--r--test/builtins/Unit/udivmoddi4_test.c20639
-rw-r--r--test/builtins/Unit/udivmodsi4_test.c59
-rw-r--r--test/builtins/Unit/udivmodti4_test.c65353
-rw-r--r--test/builtins/Unit/udivsi3_test.c175
-rw-r--r--test/builtins/Unit/udivti3_test.c67
-rw-r--r--test/builtins/Unit/umoddi3_test.c44
-rw-r--r--test/builtins/Unit/umodsi3_test.c175
-rw-r--r--test/builtins/Unit/umodti3_test.c65
-rw-r--r--test/builtins/Unit/unorddf2vfp_test.c49
-rw-r--r--test/builtins/Unit/unordsf2vfp_test.c49
-rw-r--r--test/builtins/Unit/unordtf2_test.c65
-rw-r--r--test/builtins/timing/ashldi3.c49
-rw-r--r--test/builtins/timing/ashrdi3.c49
-rw-r--r--test/builtins/timing/divdi3.c52
-rw-r--r--test/builtins/timing/floatdidf.c47
-rw-r--r--test/builtins/timing/floatdisf.c47
-rw-r--r--test/builtins/timing/floatdixf.c47
-rw-r--r--test/builtins/timing/floatundidf.c44
-rw-r--r--test/builtins/timing/floatundisf.c47
-rw-r--r--test/builtins/timing/floatundixf.c47
-rw-r--r--test/builtins/timing/lshrdi3.c49
-rw-r--r--test/builtins/timing/moddi3.c52
-rw-r--r--test/builtins/timing/modsi3.c52
-rw-r--r--test/builtins/timing/muldi3.c52
-rw-r--r--test/builtins/timing/negdi2.c50
-rwxr-xr-xtest/builtins/timing/time39
-rw-r--r--test/builtins/timing/timing.h28
-rw-r--r--test/builtins/timing/udivdi3.c52
-rw-r--r--test/builtins/timing/umoddi3.c52
194 files changed, 169008 insertions, 0 deletions
diff --git a/test/builtins/Unit/absvdi2_test.c b/test/builtins/Unit/absvdi2_test.c
new file mode 100644
index 000000000000..f0bf560681e7
--- /dev/null
+++ b/test/builtins/Unit/absvdi2_test.c
@@ -0,0 +1,65 @@
+//===-- absvdi2_test.c - Test __absvdi2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __absvdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: absolute value
+
+// Effects: aborts if abs(x) < 0
+
+di_int __absvdi2(di_int a);
+
+int test__absvdi2(di_int a)
+{
+ di_int x = __absvdi2(a);
+ di_int expected = a;
+ if (expected < 0)
+ expected = -expected;
+ if (x != expected || expected < 0)
+ printf("error in __absvdi2(0x%llX) = %lld, expected positive %lld\n",
+ a, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// if (test__absvdi2(0x8000000000000000LL)) // should abort
+// return 1;
+ if (test__absvdi2(0x0000000000000000LL))
+ return 1;
+ if (test__absvdi2(0x0000000000000001LL))
+ return 1;
+ if (test__absvdi2(0x0000000000000002LL))
+ return 1;
+ if (test__absvdi2(0x7FFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__absvdi2(0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__absvdi2(0x8000000000000001LL))
+ return 1;
+ if (test__absvdi2(0x8000000000000002LL))
+ return 1;
+ if (test__absvdi2(0xFFFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__absvdi2(0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__absvdi2(((di_int)rand() << 32) | rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/absvsi2_test.c b/test/builtins/Unit/absvsi2_test.c
new file mode 100644
index 000000000000..3b88078dfb4a
--- /dev/null
+++ b/test/builtins/Unit/absvsi2_test.c
@@ -0,0 +1,65 @@
+//===-- absvsi2_test.c - Test __absvsi2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __absvsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: absolute value
+
+// Effects: aborts if abs(x) < 0
+
+si_int __absvsi2(si_int a);
+
+int test__absvsi2(si_int a)
+{
+ si_int x = __absvsi2(a);
+ si_int expected = a;
+ if (expected < 0)
+ expected = -expected;
+ if (x != expected || expected < 0)
+ printf("error in __absvsi2(0x%X) = %d, expected positive %d\n",
+ a, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// if (test__absvsi2(0x80000000)) // should abort
+// return 1;
+ if (test__absvsi2(0x00000000))
+ return 1;
+ if (test__absvsi2(0x00000001))
+ return 1;
+ if (test__absvsi2(0x00000002))
+ return 1;
+ if (test__absvsi2(0x7FFFFFFE))
+ return 1;
+ if (test__absvsi2(0x7FFFFFFF))
+ return 1;
+ if (test__absvsi2(0x80000001))
+ return 1;
+ if (test__absvsi2(0x80000002))
+ return 1;
+ if (test__absvsi2(0xFFFFFFFE))
+ return 1;
+ if (test__absvsi2(0xFFFFFFFF))
+ return 1;
+
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__absvsi2(rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/absvti2_test.c b/test/builtins/Unit/absvti2_test.c
new file mode 100644
index 000000000000..9b71f200ac7b
--- /dev/null
+++ b/test/builtins/Unit/absvti2_test.c
@@ -0,0 +1,84 @@
+//===-- absvti2_test.c - Test __absvti2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __absvti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: absolute value
+
+// Effects: aborts if abs(x) < 0
+
+ti_int __absvti2(ti_int a);
+
+int test__absvti2(ti_int a)
+{
+ ti_int x = __absvti2(a);
+ ti_int expected = a;
+ if (expected < 0)
+ expected = -expected;
+ if (x != expected || expected < 0)
+ {
+ twords at;
+ at.all = a;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __absvti2(0x%llX%.16llX) = "
+ "0x%llX%.16llX, expected positive 0x%llX%.16llX\n",
+ at.s.high, at.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+
+// if (test__absvti2(make_ti(0x8000000000000000LL, 0))) // should abort
+// return 1;
+ if (test__absvti2(0x0000000000000000LL))
+ return 1;
+ if (test__absvti2(0x0000000000000001LL))
+ return 1;
+ if (test__absvti2(0x0000000000000002LL))
+ return 1;
+ if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFELL)))
+ return 1;
+ if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__absvti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__absvti2(make_ti(0x8000000000000000LL, 0x0000000000000002LL)))
+ return 1;
+ if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFELL)))
+ return 1;
+ if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__absvti2(make_ti(((ti_int)rand() << 32) | rand(),
+ ((ti_int)rand() << 32) | rand())))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/adddf3vfp_test.c b/test/builtins/Unit/adddf3vfp_test.c
new file mode 100644
index 000000000000..5ad42f7b3a6e
--- /dev/null
+++ b/test/builtins/Unit/adddf3vfp_test.c
@@ -0,0 +1,48 @@
+//===-- adddf3vfp_test.c - Test __adddf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __adddf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#if __arm__
+extern double __adddf3vfp(double a, double b);
+
+int test__adddf3vfp(double a, double b)
+{
+ double actual = __adddf3vfp(a, b);
+ double expected = a + b;
+ if (actual != expected)
+ printf("error in test__adddf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__adddf3vfp(1.0, 1.0))
+ return 1;
+ if (test__adddf3vfp(HUGE_VAL, HUGE_VAL))
+ return 1;
+ if (test__adddf3vfp(0.0, HUGE_VAL))
+ return 1;
+ if (test__adddf3vfp(0.0, -0.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/addsf3vfp_test.c b/test/builtins/Unit/addsf3vfp_test.c
new file mode 100644
index 000000000000..95e057c36305
--- /dev/null
+++ b/test/builtins/Unit/addsf3vfp_test.c
@@ -0,0 +1,48 @@
+//===-- addsf3vfp_test.c - Test __addsf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __addsf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __addsf3vfp(float a, float b);
+
+#if __arm__
+int test__addsf3vfp(float a, float b)
+{
+ float actual = __addsf3vfp(a, b);
+ float expected = a + b;
+ if (actual != expected)
+ printf("error in test__addsf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__addsf3vfp(1.0, 1.0))
+ return 1;
+ if (test__addsf3vfp(HUGE_VALF, HUGE_VALF))
+ return 1;
+ if (test__addsf3vfp(0.0, HUGE_VALF))
+ return 1;
+ if (test__addsf3vfp(0.0, -0.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/addtf3_test.c b/test/builtins/Unit/addtf3_test.c
new file mode 100644
index 000000000000..4a3aacd96e6d
--- /dev/null
+++ b/test/builtins/Unit/addtf3_test.c
@@ -0,0 +1,81 @@
+//===--------------- addtf3_test.c - Test __addtf3 ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __addtf3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+// Returns: a + b
+long double __addtf3(long double a, long double b);
+
+int test__addtf3(long double a, long double b,
+ uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __addtf3(a, b);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret){
+ printf("error in test__addtf3(%.20Lf, %.20Lf) = %.20Lf, "
+ "expected %.20Lf\n", a, b, x,
+ fromRep128(expectedHi, expectedLo));
+ }
+
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ // qNaN + any = qNaN
+ if (test__addtf3(makeQNaN128(),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // NaN + any = NaN
+ if (test__addtf3(makeNaN128(UINT64_C(0x800030000000)),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf + inf = inf
+ if (test__addtf3(makeInf128(),
+ makeInf128(),
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf + any = inf
+ if (test__addtf3(makeInf128(),
+ 0x1.2335653452436234723489432abcdefp+5L,
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // any + any
+ if (test__addtf3(0x1.23456734245345543849abcdefp+5L,
+ 0x1.edcba52449872455634654321fp-1L,
+ UINT64_C(0x40042afc95c8b579),
+ UINT64_C(0x61e58dd6c51eb77c)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/addvdi3_test.c b/test/builtins/Unit/addvdi3_test.c
new file mode 100644
index 000000000000..0d7271d5a4ae
--- /dev/null
+++ b/test/builtins/Unit/addvdi3_test.c
@@ -0,0 +1,58 @@
+//===-- addvdi3_test.c - Test __addvdi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __addvdi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a + b
+
+// Effects: aborts if a + b overflows
+
+di_int __addvdi3(di_int a, di_int b);
+
+int test__addvdi3(di_int a, di_int b)
+{
+ di_int x = __addvdi3(a, b);
+ di_int expected = a + b;
+ if (x != expected)
+ printf("error in test__addvdi3(0x%llX, 0x%llX) = %lld, expected %lld\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// test__addvdi3(0x8000000000000000LL, -1); // should abort
+// test__addvdi3(-1, 0x8000000000000000LL); // should abort
+// test__addvdi3(1, 0x7FFFFFFFFFFFFFFFLL); // should abort
+// test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 1); // should abort
+
+ if (test__addvdi3(0x8000000000000000LL, 1))
+ return 1;
+ if (test__addvdi3(1, 0x8000000000000000LL))
+ return 1;
+ if (test__addvdi3(0x8000000000000000LL, 0))
+ return 1;
+ if (test__addvdi3(0, 0x8000000000000000LL))
+ return 1;
+ if (test__addvdi3(0x7FFFFFFFFFFFFFFLL, -1))
+ return 1;
+ if (test__addvdi3(-1, 0x7FFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__addvdi3(0, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/addvsi3_test.c b/test/builtins/Unit/addvsi3_test.c
new file mode 100644
index 000000000000..59fd9d2ae15f
--- /dev/null
+++ b/test/builtins/Unit/addvsi3_test.c
@@ -0,0 +1,58 @@
+//===-- addvsi3_test.c - Test __addvsi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __addvsi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a + b
+
+// Effects: aborts if a + b overflows
+
+si_int __addvsi3(si_int a, si_int b);
+
+int test__addvsi3(si_int a, si_int b)
+{
+ si_int x = __addvsi3(a, b);
+ si_int expected = a + b;
+ if (x != expected)
+ printf("error in test__addvsi3(0x%X, 0x%X) = %d, expected %d\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// test__addvsi3(0x80000000, -1); // should abort
+// test__addvsi3(-1, 0x80000000); // should abort
+// test__addvsi3(1, 0x7FFFFFFF); // should abort
+// test__addvsi3(0x7FFFFFFF, 1); // should abort
+
+ if (test__addvsi3(0x80000000, 1))
+ return 1;
+ if (test__addvsi3(1, 0x80000000))
+ return 1;
+ if (test__addvsi3(0x80000000, 0))
+ return 1;
+ if (test__addvsi3(0, 0x80000000))
+ return 1;
+ if (test__addvsi3(0x7FFFFFFF, -1))
+ return 1;
+ if (test__addvsi3(-1, 0x7FFFFFFF))
+ return 1;
+ if (test__addvsi3(0x7FFFFFFF, 0))
+ return 1;
+ if (test__addvsi3(0, 0x7FFFFFFF))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/addvti3_test.c b/test/builtins/Unit/addvti3_test.c
new file mode 100644
index 000000000000..fe093e3b26a2
--- /dev/null
+++ b/test/builtins/Unit/addvti3_test.c
@@ -0,0 +1,94 @@
+//===-- addvti3_test.c - Test __addvti3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __addvti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a + b
+
+// Effects: aborts if a + b overflows
+
+ti_int __addvti3(ti_int a, ti_int b);
+
+int test__addvti3(ti_int a, ti_int b)
+{
+ ti_int x = __addvti3(a, b);
+ ti_int expected = a + b;
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in test__addvti3(0x%llX%.16llX, 0x%llX%.16llX) = "
+ "0x%llX%.16llX, expected 0x%llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+// should abort
+// test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
+// should abort
+// test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL));
+// should abort
+// test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL),
+// make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
+// should abort
+// test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// make_ti(0x0000000000000000LL, 0x0000000000000001LL));
+
+ if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x0000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ashldi3_test.c b/test/builtins/Unit/ashldi3_test.c
new file mode 100644
index 000000000000..fb80c6f77e40
--- /dev/null
+++ b/test/builtins/Unit/ashldi3_test.c
@@ -0,0 +1,77 @@
+//===-- ashldi3_test.c - Test __ashldi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ashldi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a << b
+
+// Precondition: 0 <= b < bits_in_dword
+
+di_int __ashldi3(di_int a, si_int b);
+
+int test__ashldi3(di_int a, si_int b, di_int expected)
+{
+ di_int x = __ashldi3(a, b);
+ if (x != expected)
+ printf("error in __ashldi3: %llX << %d = %llX, expected %llX\n",
+ a, b, __ashldi3(a, b), expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__ashldi3(0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 1, 0x2468ACF13579BDELL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BCLL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 3, 0x91A2B3C4D5E6F78LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 4, 0x123456789ABCDEF0LL))
+ return 1;
+
+ if (test__ashldi3(0x0123456789ABCDEFLL, 28, 0x789ABCDEF0000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 29, 0xF13579BDE0000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 30, 0xE26AF37BC0000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 31, 0xC4D5E6F780000000LL))
+ return 1;
+
+ if (test__ashldi3(0x0123456789ABCDEFLL, 32, 0x89ABCDEF00000000LL))
+ return 1;
+
+ if (test__ashldi3(0x0123456789ABCDEFLL, 33, 0x13579BDE00000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 34, 0x26AF37BC00000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 35, 0x4D5E6F7800000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 36, 0x9ABCDEF000000000LL))
+ return 1;
+
+ if (test__ashldi3(0x0123456789ABCDEFLL, 60, 0xF000000000000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 61, 0xE000000000000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 62, 0xC000000000000000LL))
+ return 1;
+ if (test__ashldi3(0x0123456789ABCDEFLL, 63, 0x8000000000000000LL))
+ return 1;
+ return 0;
+}
diff --git a/test/builtins/Unit/ashlti3_test.c b/test/builtins/Unit/ashlti3_test.c
new file mode 100644
index 000000000000..2361d16b3699
--- /dev/null
+++ b/test/builtins/Unit/ashlti3_test.c
@@ -0,0 +1,175 @@
+//===-- ashlti3_test.c - Test __ashlti3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ashlti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a << b
+
+// Precondition: 0 <= b < bits_in_tword
+
+ti_int __ashlti3(ti_int a, si_int b);
+
+int test__ashlti3(ti_int a, si_int b, ti_int expected)
+{
+ ti_int x = __ashlti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __ashlti3: 0x%llX%.16llX << %d = 0x%llX%.16llX,"
+ " expected 0x%llX%.16llX\n",
+ at.s.high, at.s.low, b, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0,
+ make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1,
+ make_ti(0xFDB97530ECA8642BLL, 0xFDB97530ECA8642ALL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2,
+ make_ti(0xFB72EA61D950C857LL, 0XFB72EA61D950C854LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3,
+ make_ti(0xF6E5D4C3B2A190AFLL, 0xF6E5D4C3B2A190A8LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4,
+ make_ti(0xEDCBA9876543215FLL, 0xEDCBA98765432150LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28,
+ make_ti(0x876543215FEDCBA9LL, 0x8765432150000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29,
+ make_ti(0x0ECA8642BFDB9753LL, 0x0ECA8642A0000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30,
+ make_ti(0x1D950C857FB72EA6LL, 0x1D950C8540000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31,
+ make_ti(0x3B2A190AFF6E5D4CLL, 0x3B2A190A80000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32,
+ make_ti(0x76543215FEDCBA98LL, 0x7654321500000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33,
+ make_ti(0xECA8642BFDB97530LL, 0xECA8642A00000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34,
+ make_ti(0xD950C857FB72EA61LL, 0xD950C85400000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35,
+ make_ti(0xB2A190AFF6E5D4C3LL, 0xB2A190A800000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36,
+ make_ti(0x6543215FEDCBA987LL, 0x6543215000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60,
+ make_ti(0x5FEDCBA987654321LL, 0x5000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61,
+ make_ti(0xBFDB97530ECA8642LL, 0xA000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62,
+ make_ti(0x7FB72EA61D950C85LL, 0x4000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63,
+ make_ti(0xFF6E5D4C3B2A190ALL, 0x8000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64,
+ make_ti(0xFEDCBA9876543215LL, 0x0000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65,
+ make_ti(0xFDB97530ECA8642ALL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66,
+ make_ti(0xFB72EA61D950C854LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67,
+ make_ti(0xF6E5D4C3B2A190A8LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68,
+ make_ti(0xEDCBA98765432150LL, 0x0000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92,
+ make_ti(0x8765432150000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93,
+ make_ti(0x0ECA8642A0000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94,
+ make_ti(0x1D950C8540000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95,
+ make_ti(0x3B2A190A80000000LL, 0x0000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96,
+ make_ti(0x7654321500000000LL, 0x0000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97,
+ make_ti(0xECA8642A00000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98,
+ make_ti(0xD950C85400000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99,
+ make_ti(0xB2A190A800000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100,
+ make_ti(0x6543215000000000LL, 0x0000000000000000LL)))
+ return 1;
+
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124,
+ make_ti(0x5000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125,
+ make_ti(0xA000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126,
+ make_ti(0x4000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ashrdi3_test.c b/test/builtins/Unit/ashrdi3_test.c
new file mode 100644
index 000000000000..ac517e191880
--- /dev/null
+++ b/test/builtins/Unit/ashrdi3_test.c
@@ -0,0 +1,118 @@
+//===-- ashrdi3_test.c - Test __ashrdi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ashrdi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: arithmetic a >> b
+
+// Precondition: 0 <= b < bits_in_dword
+
+di_int __ashrdi3(di_int a, si_int b);
+
+int test__ashrdi3(di_int a, si_int b, di_int expected)
+{
+ di_int x = __ashrdi3(a, b);
+ if (x != expected)
+ printf("error in __ashrdi3: %llX >> %d = %llX, expected %llX\n",
+ a, b, __ashrdi3(a, b), expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 1, 0x91A2B3C4D5E6F7LL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BLL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 3, 0x2468ACF13579BDLL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 4, 0x123456789ABCDELL))
+ return 1;
+
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 28, 0x12345678LL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 29, 0x91A2B3CLL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 30, 0x48D159ELL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 31, 0x2468ACFLL))
+ return 1;
+
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 32, 0x1234567LL))
+ return 1;
+
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 33, 0x91A2B3LL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 34, 0x48D159LL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 35, 0x2468ACLL))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 36, 0x123456LL))
+ return 1;
+
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 60, 0))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 61, 0))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 62, 0))
+ return 1;
+ if (test__ashrdi3(0x0123456789ABCDEFLL, 63, 0))
+ return 1;
+
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 0, 0xFEDCBA9876543210LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 1, 0xFF6E5D4C3B2A1908LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 2, 0xFFB72EA61D950C84LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 3, 0xFFDB97530ECA8642LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 4, 0xFFEDCBA987654321LL))
+ return 1;
+
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 28, 0xFFFFFFFFEDCBA987LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 29, 0xFFFFFFFFF6E5D4C3LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 30, 0xFFFFFFFFFB72EA61LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 31, 0xFFFFFFFFFDB97530LL))
+ return 1;
+
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 32, 0xFFFFFFFFFEDCBA98LL))
+ return 1;
+
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 33, 0xFFFFFFFFFF6E5D4CLL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 34, 0xFFFFFFFFFFB72EA6LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 35, 0xFFFFFFFFFFDB9753LL))
+ return 1;
+ if (test__ashrdi3(0xFEDCBA9876543210LL, 36, 0xFFFFFFFFFFEDCBA9LL))
+ return 1;
+
+ if (test__ashrdi3(0xAEDCBA9876543210LL, 60, 0xFFFFFFFFFFFFFFFALL))
+ return 1;
+ if (test__ashrdi3(0xAEDCBA9876543210LL, 61, 0xFFFFFFFFFFFFFFFDLL))
+ return 1;
+ if (test__ashrdi3(0xAEDCBA9876543210LL, 62, 0xFFFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__ashrdi3(0xAEDCBA9876543210LL, 63, 0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ return 0;
+}
diff --git a/test/builtins/Unit/ashrti3_test.c b/test/builtins/Unit/ashrti3_test.c
new file mode 100644
index 000000000000..62ba1017ecd9
--- /dev/null
+++ b/test/builtins/Unit/ashrti3_test.c
@@ -0,0 +1,173 @@
+//===-- ashrti3_test.c - Test __ashrti3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ashrti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: arithmetic a >> b
+
+// Precondition: 0 <= b < bits_in_tword
+
+ti_int __ashrti3(ti_int a, si_int b);
+
+int test__ashrti3(ti_int a, si_int b, ti_int expected)
+{
+ ti_int x = __ashrti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __ashrti3: 0x%llX%.16llX >> %d = 0x%llX%.16llX,"
+ " expected 0x%llX%.16llX\n",
+ at.s.high, at.s.low, b, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0,
+ make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1,
+ make_ti(0xFF6E5D4C3B2A190ALL, 0xFF6E5D4C3B2A190ALL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2,
+ make_ti(0xFFB72EA61D950C85LL, 0x7FB72EA61D950C85LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3,
+ make_ti(0xFFDB97530ECA8642LL, 0xBFDB97530ECA8642LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4,
+ make_ti(0xFFEDCBA987654321LL, 0x5FEDCBA987654321LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28,
+ make_ti(0xFFFFFFFFEDCBA987LL, 0x6543215FEDCBA987LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29,
+ make_ti(0xFFFFFFFFF6E5D4C3LL, 0xB2A190AFF6E5D4C3LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30,
+ make_ti(0xFFFFFFFFFB72EA61LL, 0xD950C857FB72EA61LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31,
+ make_ti(0xFFFFFFFFFDB97530LL, 0xECA8642BFDB97530LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32,
+ make_ti(0xFFFFFFFFFEDCBA98LL, 0x76543215FEDCBA98LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33,
+ make_ti(0xFFFFFFFFFF6E5D4CLL, 0x3B2A190AFF6E5D4CLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34,
+ make_ti(0xFFFFFFFFFFB72EA6LL, 0x1D950C857FB72EA6LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35,
+ make_ti(0xFFFFFFFFFFDB9753LL, 0x0ECA8642BFDB9753LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36,
+ make_ti(0xFFFFFFFFFFEDCBA9LL, 0x876543215FEDCBA9LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xEDCBA9876543215FLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xF6E5D4C3B2A190AFLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFB72EA61D950C857LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFDB97530ECA8642BLL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFEDCBA9876543215LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFF6E5D4C3B2A190ALL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFB72EA61D950C85LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFDB97530ECA8642LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFEDCBA987654321LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFEDCBA987LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFF6E5D4C3LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFB72EA61LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFDB97530LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFEDCBA98LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFF6E5D4CLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFB72EA6LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFDB9753LL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFEDCBA9LL)))
+ return 1;
+
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127,
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/bswapdi2_test.c b/test/builtins/Unit/bswapdi2_test.c
new file mode 100644
index 000000000000..2d830cf5e41e
--- /dev/null
+++ b/test/builtins/Unit/bswapdi2_test.c
@@ -0,0 +1,44 @@
+//===-- bswapdi2_test.c - Test __bswapdi2 ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __bswapdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern uint64_t __bswapdi2(uint64_t);
+
+#if __arm__
+int test__bswapdi2(uint64_t a, uint64_t expected)
+{
+ uint64_t actual = __bswapdi2(a);
+ if (actual != expected)
+ printf("error in test__bswapsi2(0x%0llX) = 0x%0llX, expected 0x%0llX\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__bswapdi2(0x123456789ABCDEF0LL, 0xF0DEBC9A78563412LL))
+ return 1;
+ if (test__bswapdi2(0x0000000100000002LL, 0x0200000001000000LL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/bswapsi2_test.c b/test/builtins/Unit/bswapsi2_test.c
new file mode 100644
index 000000000000..4488a888e1eb
--- /dev/null
+++ b/test/builtins/Unit/bswapsi2_test.c
@@ -0,0 +1,44 @@
+//===-- bswapsi2_test.c - Test __bswapsi2 ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __bswapsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern uint32_t __bswapsi2(uint32_t);
+
+#if __arm__
+int test__bswapsi2(uint32_t a, uint32_t expected)
+{
+ uint32_t actual = __bswapsi2(a);
+ if (actual != expected)
+ printf("error in test__bswapsi2(0x%0X) = 0x%0X, expected 0x%0X\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__bswapsi2(0x12345678, 0x78563412))
+ return 1;
+ if (test__bswapsi2(0x00000001, 0x01000000))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/clear_cache_test.c b/test/builtins/Unit/clear_cache_test.c
new file mode 100644
index 000000000000..3507fd80b288
--- /dev/null
+++ b/test/builtins/Unit/clear_cache_test.c
@@ -0,0 +1,76 @@
+//===-- clear_cache_test.c - Test clear_cache -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#if defined(_WIN32)
+#include <windows.h>
+void __clear_cache(void* start, void* end)
+{
+ if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
+ exit(1);
+}
+#else
+#include <sys/mman.h>
+extern void __clear_cache(void* start, void* end);
+#endif
+
+
+
+
+typedef int (*pfunc)(void);
+
+int func1()
+{
+ return 1;
+}
+
+int func2()
+{
+ return 2;
+}
+
+
+
+unsigned char execution_buffer[128];
+
+int main()
+{
+ // make executable the page containing execution_buffer
+ char* start = (char*)((uintptr_t)execution_buffer & (-4095));
+ char* end = (char*)((uintptr_t)(&execution_buffer[128+4096]) & (-4095));
+#if defined(_WIN32)
+ DWORD dummy_oldProt;
+ MEMORY_BASIC_INFORMATION b;
+ if (!VirtualQuery(start, &b, sizeof(b)))
+ return 1;
+ if (!VirtualProtect(b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, &b.Protect))
+#else
+ if (mprotect(start, end-start, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
+#endif
+ return 1;
+
+ // verify you can copy and execute a function
+ memcpy(execution_buffer, (void *)(uintptr_t)&func1, 128);
+ __clear_cache(execution_buffer, &execution_buffer[128]);
+ pfunc f1 = (pfunc)(uintptr_t)execution_buffer;
+ if ((*f1)() != 1)
+ return 1;
+
+ // verify you can overwrite a function with another
+ memcpy(execution_buffer, (void *)(uintptr_t)&func2, 128);
+ __clear_cache(execution_buffer, &execution_buffer[128]);
+ pfunc f2 = (pfunc)(uintptr_t)execution_buffer;
+ if ((*f2)() != 2)
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/clzdi2_test.c b/test/builtins/Unit/clzdi2_test.c
new file mode 100644
index 000000000000..58403f091f48
--- /dev/null
+++ b/test/builtins/Unit/clzdi2_test.c
@@ -0,0 +1,68 @@
+//===-- clzdi2_test.c - Test __clzdi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __clzdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: the number of leading 0-bits
+
+// Precondition: a != 0
+
+si_int __clzdi2(di_int a);
+
+int test__clzdi2(di_int a, si_int expected)
+{
+ si_int x = __clzdi2(a);
+ if (x != expected)
+ printf("error in __clzdi2(0x%llX) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ const int N = (int)(sizeof(di_int) * CHAR_BIT);
+// if (test__clzdi2(0x00000000, N)) // undefined
+// return 1;
+ if (test__clzdi2(0x00000001, N-1))
+ return 1;
+ if (test__clzdi2(0x00000002, N-2))
+ return 1;
+ if (test__clzdi2(0x00000003, N-2))
+ return 1;
+ if (test__clzdi2(0x00000004, N-3))
+ return 1;
+ if (test__clzdi2(0x00000005, N-3))
+ return 1;
+ if (test__clzdi2(0x0000000A, N-4))
+ return 1;
+ if (test__clzdi2(0x1000000A, N/2+3))
+ return 1;
+ if (test__clzdi2(0x2000000A, N/2+2))
+ return 1;
+ if (test__clzdi2(0x6000000A, N/2+1))
+ return 1;
+ if (test__clzdi2(0x8000000AuLL, N/2))
+ return 1;
+ if (test__clzdi2(0x000005008000000AuLL, 21))
+ return 1;
+ if (test__clzdi2(0x020005008000000AuLL, 6))
+ return 1;
+ if (test__clzdi2(0x720005008000000AuLL, 1))
+ return 1;
+ if (test__clzdi2(0x820005008000000AuLL, 0))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/clzsi2_test.c b/test/builtins/Unit/clzsi2_test.c
new file mode 100644
index 000000000000..cc1da64b03ef
--- /dev/null
+++ b/test/builtins/Unit/clzsi2_test.c
@@ -0,0 +1,599 @@
+//===-- clzsi2_test.c - Test __clzsi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __clzsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: the number of leading 0-bits
+
+// Precondition: a != 0
+
+si_int __clzsi2(si_int a);
+
+int test__clzsi2(si_int a, si_int expected)
+{
+ si_int x = __clzsi2(a);
+ if (x != expected)
+ printf("error in __clzsi2(0x%X) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+// if (test__clzsi2(0x00000000, 32)) // undefined
+// return 1;
+ if (test__clzsi2(0x00800000, 8))
+ return 1;
+ if (test__clzsi2(0x01000000, 7))
+ return 1;
+ if (test__clzsi2(0x02000000, 6))
+ return 1;
+ if (test__clzsi2(0x03000000, 6))
+ return 1;
+ if (test__clzsi2(0x04000000, 5))
+ return 1;
+ if (test__clzsi2(0x05000000, 5))
+ return 1;
+ if (test__clzsi2(0x06000000, 5))
+ return 1;
+ if (test__clzsi2(0x07000000, 5))
+ return 1;
+ if (test__clzsi2(0x08000000, 4))
+ return 1;
+ if (test__clzsi2(0x09000000, 4))
+ return 1;
+ if (test__clzsi2(0x0A000000, 4))
+ return 1;
+ if (test__clzsi2(0x0B000000, 4))
+ return 1;
+ if (test__clzsi2(0x0C000000, 4))
+ return 1;
+ if (test__clzsi2(0x0D000000, 4))
+ return 1;
+ if (test__clzsi2(0x0E000000, 4))
+ return 1;
+ if (test__clzsi2(0x0F000000, 4))
+ return 1;
+ if (test__clzsi2(0x10000000, 3))
+ return 1;
+ if (test__clzsi2(0x11000000, 3))
+ return 1;
+ if (test__clzsi2(0x12000000, 3))
+ return 1;
+ if (test__clzsi2(0x13000000, 3))
+ return 1;
+ if (test__clzsi2(0x14000000, 3))
+ return 1;
+ if (test__clzsi2(0x15000000, 3))
+ return 1;
+ if (test__clzsi2(0x16000000, 3))
+ return 1;
+ if (test__clzsi2(0x17000000, 3))
+ return 1;
+ if (test__clzsi2(0x18000000, 3))
+ return 1;
+ if (test__clzsi2(0x19000000, 3))
+ return 1;
+ if (test__clzsi2(0x1A000000, 3))
+ return 1;
+ if (test__clzsi2(0x1B000000, 3))
+ return 1;
+ if (test__clzsi2(0x1C000000, 3))
+ return 1;
+ if (test__clzsi2(0x1D000000, 3))
+ return 1;
+ if (test__clzsi2(0x1E000000, 3))
+ return 1;
+ if (test__clzsi2(0x1F000000, 3))
+ return 1;
+ if (test__clzsi2(0x20000000, 2))
+ return 1;
+ if (test__clzsi2(0x21000000, 2))
+ return 1;
+ if (test__clzsi2(0x22000000, 2))
+ return 1;
+ if (test__clzsi2(0x23000000, 2))
+ return 1;
+ if (test__clzsi2(0x24000000, 2))
+ return 1;
+ if (test__clzsi2(0x25000000, 2))
+ return 1;
+ if (test__clzsi2(0x26000000, 2))
+ return 1;
+ if (test__clzsi2(0x27000000, 2))
+ return 1;
+ if (test__clzsi2(0x28000000, 2))
+ return 1;
+ if (test__clzsi2(0x29000000, 2))
+ return 1;
+ if (test__clzsi2(0x2A000000, 2))
+ return 1;
+ if (test__clzsi2(0x2B000000, 2))
+ return 1;
+ if (test__clzsi2(0x2C000000, 2))
+ return 1;
+ if (test__clzsi2(0x2D000000, 2))
+ return 1;
+ if (test__clzsi2(0x2E000000, 2))
+ return 1;
+ if (test__clzsi2(0x2F000000, 2))
+ return 1;
+ if (test__clzsi2(0x30000000, 2))
+ return 1;
+ if (test__clzsi2(0x31000000, 2))
+ return 1;
+ if (test__clzsi2(0x32000000, 2))
+ return 1;
+ if (test__clzsi2(0x33000000, 2))
+ return 1;
+ if (test__clzsi2(0x34000000, 2))
+ return 1;
+ if (test__clzsi2(0x35000000, 2))
+ return 1;
+ if (test__clzsi2(0x36000000, 2))
+ return 1;
+ if (test__clzsi2(0x37000000, 2))
+ return 1;
+ if (test__clzsi2(0x38000000, 2))
+ return 1;
+ if (test__clzsi2(0x39000000, 2))
+ return 1;
+ if (test__clzsi2(0x3A000000, 2))
+ return 1;
+ if (test__clzsi2(0x3B000000, 2))
+ return 1;
+ if (test__clzsi2(0x3C000000, 2))
+ return 1;
+ if (test__clzsi2(0x3D000000, 2))
+ return 1;
+ if (test__clzsi2(0x3E000000, 2))
+ return 1;
+ if (test__clzsi2(0x3F000000, 2))
+ return 1;
+ if (test__clzsi2(0x40000000, 1))
+ return 1;
+ if (test__clzsi2(0x41000000, 1))
+ return 1;
+ if (test__clzsi2(0x42000000, 1))
+ return 1;
+ if (test__clzsi2(0x43000000, 1))
+ return 1;
+ if (test__clzsi2(0x44000000, 1))
+ return 1;
+ if (test__clzsi2(0x45000000, 1))
+ return 1;
+ if (test__clzsi2(0x46000000, 1))
+ return 1;
+ if (test__clzsi2(0x47000000, 1))
+ return 1;
+ if (test__clzsi2(0x48000000, 1))
+ return 1;
+ if (test__clzsi2(0x49000000, 1))
+ return 1;
+ if (test__clzsi2(0x4A000000, 1))
+ return 1;
+ if (test__clzsi2(0x4B000000, 1))
+ return 1;
+ if (test__clzsi2(0x4C000000, 1))
+ return 1;
+ if (test__clzsi2(0x4D000000, 1))
+ return 1;
+ if (test__clzsi2(0x4E000000, 1))
+ return 1;
+ if (test__clzsi2(0x4F000000, 1))
+ return 1;
+ if (test__clzsi2(0x50000000, 1))
+ return 1;
+ if (test__clzsi2(0x51000000, 1))
+ return 1;
+ if (test__clzsi2(0x52000000, 1))
+ return 1;
+ if (test__clzsi2(0x53000000, 1))
+ return 1;
+ if (test__clzsi2(0x54000000, 1))
+ return 1;
+ if (test__clzsi2(0x55000000, 1))
+ return 1;
+ if (test__clzsi2(0x56000000, 1))
+ return 1;
+ if (test__clzsi2(0x57000000, 1))
+ return 1;
+ if (test__clzsi2(0x58000000, 1))
+ return 1;
+ if (test__clzsi2(0x59000000, 1))
+ return 1;
+ if (test__clzsi2(0x5A000000, 1))
+ return 1;
+ if (test__clzsi2(0x5B000000, 1))
+ return 1;
+ if (test__clzsi2(0x5C000000, 1))
+ return 1;
+ if (test__clzsi2(0x5D000000, 1))
+ return 1;
+ if (test__clzsi2(0x5E000000, 1))
+ return 1;
+ if (test__clzsi2(0x5F000000, 1))
+ return 1;
+ if (test__clzsi2(0x60000000, 1))
+ return 1;
+ if (test__clzsi2(0x61000000, 1))
+ return 1;
+ if (test__clzsi2(0x62000000, 1))
+ return 1;
+ if (test__clzsi2(0x63000000, 1))
+ return 1;
+ if (test__clzsi2(0x64000000, 1))
+ return 1;
+ if (test__clzsi2(0x65000000, 1))
+ return 1;
+ if (test__clzsi2(0x66000000, 1))
+ return 1;
+ if (test__clzsi2(0x67000000, 1))
+ return 1;
+ if (test__clzsi2(0x68000000, 1))
+ return 1;
+ if (test__clzsi2(0x69000000, 1))
+ return 1;
+ if (test__clzsi2(0x6A000000, 1))
+ return 1;
+ if (test__clzsi2(0x6B000000, 1))
+ return 1;
+ if (test__clzsi2(0x6C000000, 1))
+ return 1;
+ if (test__clzsi2(0x6D000000, 1))
+ return 1;
+ if (test__clzsi2(0x6E000000, 1))
+ return 1;
+ if (test__clzsi2(0x6F000000, 1))
+ return 1;
+ if (test__clzsi2(0x70000000, 1))
+ return 1;
+ if (test__clzsi2(0x71000000, 1))
+ return 1;
+ if (test__clzsi2(0x72000000, 1))
+ return 1;
+ if (test__clzsi2(0x73000000, 1))
+ return 1;
+ if (test__clzsi2(0x74000000, 1))
+ return 1;
+ if (test__clzsi2(0x75000000, 1))
+ return 1;
+ if (test__clzsi2(0x76000000, 1))
+ return 1;
+ if (test__clzsi2(0x77000000, 1))
+ return 1;
+ if (test__clzsi2(0x78000000, 1))
+ return 1;
+ if (test__clzsi2(0x79000000, 1))
+ return 1;
+ if (test__clzsi2(0x7A000000, 1))
+ return 1;
+ if (test__clzsi2(0x7B000000, 1))
+ return 1;
+ if (test__clzsi2(0x7C000000, 1))
+ return 1;
+ if (test__clzsi2(0x7D000000, 1))
+ return 1;
+ if (test__clzsi2(0x7E000000, 1))
+ return 1;
+ if (test__clzsi2(0x7F000000, 1))
+ return 1;
+ if (test__clzsi2(0x80000000, 0))
+ return 1;
+ if (test__clzsi2(0x81000000, 0))
+ return 1;
+ if (test__clzsi2(0x82000000, 0))
+ return 1;
+ if (test__clzsi2(0x83000000, 0))
+ return 1;
+ if (test__clzsi2(0x84000000, 0))
+ return 1;
+ if (test__clzsi2(0x85000000, 0))
+ return 1;
+ if (test__clzsi2(0x86000000, 0))
+ return 1;
+ if (test__clzsi2(0x87000000, 0))
+ return 1;
+ if (test__clzsi2(0x88000000, 0))
+ return 1;
+ if (test__clzsi2(0x89000000, 0))
+ return 1;
+ if (test__clzsi2(0x8A000000, 0))
+ return 1;
+ if (test__clzsi2(0x8B000000, 0))
+ return 1;
+ if (test__clzsi2(0x8C000000, 0))
+ return 1;
+ if (test__clzsi2(0x8D000000, 0))
+ return 1;
+ if (test__clzsi2(0x8E000000, 0))
+ return 1;
+ if (test__clzsi2(0x8F000000, 0))
+ return 1;
+ if (test__clzsi2(0x90000000, 0))
+ return 1;
+ if (test__clzsi2(0x91000000, 0))
+ return 1;
+ if (test__clzsi2(0x92000000, 0))
+ return 1;
+ if (test__clzsi2(0x93000000, 0))
+ return 1;
+ if (test__clzsi2(0x94000000, 0))
+ return 1;
+ if (test__clzsi2(0x95000000, 0))
+ return 1;
+ if (test__clzsi2(0x96000000, 0))
+ return 1;
+ if (test__clzsi2(0x97000000, 0))
+ return 1;
+ if (test__clzsi2(0x98000000, 0))
+ return 1;
+ if (test__clzsi2(0x99000000, 0))
+ return 1;
+ if (test__clzsi2(0x9A000000, 0))
+ return 1;
+ if (test__clzsi2(0x9B000000, 0))
+ return 1;
+ if (test__clzsi2(0x9C000000, 0))
+ return 1;
+ if (test__clzsi2(0x9D000000, 0))
+ return 1;
+ if (test__clzsi2(0x9E000000, 0))
+ return 1;
+ if (test__clzsi2(0x9F000000, 0))
+ return 1;
+ if (test__clzsi2(0xA0000000, 0))
+ return 1;
+ if (test__clzsi2(0xA1000000, 0))
+ return 1;
+ if (test__clzsi2(0xA2000000, 0))
+ return 1;
+ if (test__clzsi2(0xA3000000, 0))
+ return 1;
+ if (test__clzsi2(0xA4000000, 0))
+ return 1;
+ if (test__clzsi2(0xA5000000, 0))
+ return 1;
+ if (test__clzsi2(0xA6000000, 0))
+ return 1;
+ if (test__clzsi2(0xA7000000, 0))
+ return 1;
+ if (test__clzsi2(0xA8000000, 0))
+ return 1;
+ if (test__clzsi2(0xA9000000, 0))
+ return 1;
+ if (test__clzsi2(0xAA000000, 0))
+ return 1;
+ if (test__clzsi2(0xAB000000, 0))
+ return 1;
+ if (test__clzsi2(0xAC000000, 0))
+ return 1;
+ if (test__clzsi2(0xAD000000, 0))
+ return 1;
+ if (test__clzsi2(0xAE000000, 0))
+ return 1;
+ if (test__clzsi2(0xAF000000, 0))
+ return 1;
+ if (test__clzsi2(0xB0000000, 0))
+ return 1;
+ if (test__clzsi2(0xB1000000, 0))
+ return 1;
+ if (test__clzsi2(0xB2000000, 0))
+ return 1;
+ if (test__clzsi2(0xB3000000, 0))
+ return 1;
+ if (test__clzsi2(0xB4000000, 0))
+ return 1;
+ if (test__clzsi2(0xB5000000, 0))
+ return 1;
+ if (test__clzsi2(0xB6000000, 0))
+ return 1;
+ if (test__clzsi2(0xB7000000, 0))
+ return 1;
+ if (test__clzsi2(0xB8000000, 0))
+ return 1;
+ if (test__clzsi2(0xB9000000, 0))
+ return 1;
+ if (test__clzsi2(0xBA000000, 0))
+ return 1;
+ if (test__clzsi2(0xBB000000, 0))
+ return 1;
+ if (test__clzsi2(0xBC000000, 0))
+ return 1;
+ if (test__clzsi2(0xBD000000, 0))
+ return 1;
+ if (test__clzsi2(0xBE000000, 0))
+ return 1;
+ if (test__clzsi2(0xBF000000, 0))
+ return 1;
+ if (test__clzsi2(0xC0000000, 0))
+ return 1;
+ if (test__clzsi2(0xC1000000, 0))
+ return 1;
+ if (test__clzsi2(0xC2000000, 0))
+ return 1;
+ if (test__clzsi2(0xC3000000, 0))
+ return 1;
+ if (test__clzsi2(0xC4000000, 0))
+ return 1;
+ if (test__clzsi2(0xC5000000, 0))
+ return 1;
+ if (test__clzsi2(0xC6000000, 0))
+ return 1;
+ if (test__clzsi2(0xC7000000, 0))
+ return 1;
+ if (test__clzsi2(0xC8000000, 0))
+ return 1;
+ if (test__clzsi2(0xC9000000, 0))
+ return 1;
+ if (test__clzsi2(0xCA000000, 0))
+ return 1;
+ if (test__clzsi2(0xCB000000, 0))
+ return 1;
+ if (test__clzsi2(0xCC000000, 0))
+ return 1;
+ if (test__clzsi2(0xCD000000, 0))
+ return 1;
+ if (test__clzsi2(0xCE000000, 0))
+ return 1;
+ if (test__clzsi2(0xCF000000, 0))
+ return 1;
+ if (test__clzsi2(0xD0000000, 0))
+ return 1;
+ if (test__clzsi2(0xD1000000, 0))
+ return 1;
+ if (test__clzsi2(0xD2000000, 0))
+ return 1;
+ if (test__clzsi2(0xD3000000, 0))
+ return 1;
+ if (test__clzsi2(0xD4000000, 0))
+ return 1;
+ if (test__clzsi2(0xD5000000, 0))
+ return 1;
+ if (test__clzsi2(0xD6000000, 0))
+ return 1;
+ if (test__clzsi2(0xD7000000, 0))
+ return 1;
+ if (test__clzsi2(0xD8000000, 0))
+ return 1;
+ if (test__clzsi2(0xD9000000, 0))
+ return 1;
+ if (test__clzsi2(0xDA000000, 0))
+ return 1;
+ if (test__clzsi2(0xDB000000, 0))
+ return 1;
+ if (test__clzsi2(0xDC000000, 0))
+ return 1;
+ if (test__clzsi2(0xDD000000, 0))
+ return 1;
+ if (test__clzsi2(0xDE000000, 0))
+ return 1;
+ if (test__clzsi2(0xDF000000, 0))
+ return 1;
+ if (test__clzsi2(0xE0000000, 0))
+ return 1;
+ if (test__clzsi2(0xE1000000, 0))
+ return 1;
+ if (test__clzsi2(0xE2000000, 0))
+ return 1;
+ if (test__clzsi2(0xE3000000, 0))
+ return 1;
+ if (test__clzsi2(0xE4000000, 0))
+ return 1;
+ if (test__clzsi2(0xE5000000, 0))
+ return 1;
+ if (test__clzsi2(0xE6000000, 0))
+ return 1;
+ if (test__clzsi2(0xE7000000, 0))
+ return 1;
+ if (test__clzsi2(0xE8000000, 0))
+ return 1;
+ if (test__clzsi2(0xE9000000, 0))
+ return 1;
+ if (test__clzsi2(0xEA000000, 0))
+ return 1;
+ if (test__clzsi2(0xEB000000, 0))
+ return 1;
+ if (test__clzsi2(0xEC000000, 0))
+ return 1;
+ if (test__clzsi2(0xED000000, 0))
+ return 1;
+ if (test__clzsi2(0xEE000000, 0))
+ return 1;
+ if (test__clzsi2(0xEF000000, 0))
+ return 1;
+ if (test__clzsi2(0xF0000000, 0))
+ return 1;
+ if (test__clzsi2(0xF1000000, 0))
+ return 1;
+ if (test__clzsi2(0xF2000000, 0))
+ return 1;
+ if (test__clzsi2(0xF3000000, 0))
+ return 1;
+ if (test__clzsi2(0xF4000000, 0))
+ return 1;
+ if (test__clzsi2(0xF5000000, 0))
+ return 1;
+ if (test__clzsi2(0xF6000000, 0))
+ return 1;
+ if (test__clzsi2(0xF7000000, 0))
+ return 1;
+ if (test__clzsi2(0xF8000000, 0))
+ return 1;
+ if (test__clzsi2(0xF9000000, 0))
+ return 1;
+ if (test__clzsi2(0xFA000000, 0))
+ return 1;
+ if (test__clzsi2(0xFB000000, 0))
+ return 1;
+ if (test__clzsi2(0xFC000000, 0))
+ return 1;
+ if (test__clzsi2(0xFD000000, 0))
+ return 1;
+ if (test__clzsi2(0xFE000000, 0))
+ return 1;
+ if (test__clzsi2(0xFF000000, 0))
+ return 1;
+
+ if (test__clzsi2(0x00000001, 31))
+ return 1;
+ if (test__clzsi2(0x00000002, 30))
+ return 1;
+ if (test__clzsi2(0x00000004, 29))
+ return 1;
+ if (test__clzsi2(0x00000008, 28))
+ return 1;
+ if (test__clzsi2(0x00000010, 27))
+ return 1;
+ if (test__clzsi2(0x00000020, 26))
+ return 1;
+ if (test__clzsi2(0x00000040, 25))
+ return 1;
+ if (test__clzsi2(0x00000080, 24))
+ return 1;
+ if (test__clzsi2(0x00000100, 23))
+ return 1;
+ if (test__clzsi2(0x00000200, 22))
+ return 1;
+ if (test__clzsi2(0x00000400, 21))
+ return 1;
+ if (test__clzsi2(0x00000800, 20))
+ return 1;
+ if (test__clzsi2(0x00001000, 19))
+ return 1;
+ if (test__clzsi2(0x00002000, 18))
+ return 1;
+ if (test__clzsi2(0x00004000, 17))
+ return 1;
+ if (test__clzsi2(0x00008000, 16))
+ return 1;
+ if (test__clzsi2(0x00010000, 15))
+ return 1;
+ if (test__clzsi2(0x00020000, 14))
+ return 1;
+ if (test__clzsi2(0x00040000, 13))
+ return 1;
+ if (test__clzsi2(0x00080000, 12))
+ return 1;
+ if (test__clzsi2(0x00100000, 11))
+ return 1;
+ if (test__clzsi2(0x00200000, 10))
+ return 1;
+ if (test__clzsi2(0x00400000, 9))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/clzti2_test.c b/test/builtins/Unit/clzti2_test.c
new file mode 100644
index 000000000000..5a0e3e8b1e98
--- /dev/null
+++ b/test/builtins/Unit/clzti2_test.c
@@ -0,0 +1,90 @@
+//===-- clzti2_test.c - Test __clzti2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __clzti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: the number of leading 0-bits
+
+// Precondition: a != 0
+
+si_int __clzti2(ti_int a);
+
+int test__clzti2(ti_int a, si_int expected)
+{
+ si_int x = __clzti2(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __clzti2(0x%llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ const int N = (int)(sizeof(ti_int) * CHAR_BIT);
+
+ if (test__clzti2(0x00000001, N-1))
+ return 1;
+ if (test__clzti2(0x00000002, N-2))
+ return 1;
+ if (test__clzti2(0x00000003, N-2))
+ return 1;
+ if (test__clzti2(0x00000004, N-3))
+ return 1;
+ if (test__clzti2(0x00000005, N-3))
+ return 1;
+ if (test__clzti2(0x0000000A, N-4))
+ return 1;
+ if (test__clzti2(0x1000000A, N*3/4+3))
+ return 1;
+ if (test__clzti2(0x2000000A, N*3/4+2))
+ return 1;
+ if (test__clzti2(0x6000000A, N*3/4+1))
+ return 1;
+ if (test__clzti2(0x8000000AuLL, N*3/4))
+ return 1;
+ if (test__clzti2(0x000005008000000AuLL, 85))
+ return 1;
+ if (test__clzti2(0x020005008000000AuLL, 70))
+ return 1;
+ if (test__clzti2(0x720005008000000AuLL, 65))
+ return 1;
+ if (test__clzti2(0x820005008000000AuLL, 64))
+ return 1;
+
+ if (test__clzti2(make_ti(0x0000000080000000LL, 0x8000000800000000LL), 32))
+ return 1;
+ if (test__clzti2(make_ti(0x0000000100000000LL, 0x8000000800000000LL), 31))
+ return 1;
+ if (test__clzti2(make_ti(0x1000000100000000LL, 0x8000000800000000LL), 3))
+ return 1;
+ if (test__clzti2(make_ti(0x7000000100000000LL, 0x8000000800000000LL), 1))
+ return 1;
+ if (test__clzti2(make_ti(0x8000000100000000LL, 0x8000000800000000LL), 0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/cmpdi2_test.c b/test/builtins/Unit/cmpdi2_test.c
new file mode 100644
index 000000000000..609ab1a63a61
--- /dev/null
+++ b/test/builtins/Unit/cmpdi2_test.c
@@ -0,0 +1,77 @@
+//===-- cmpdi2_test.c - Test __cmpdi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __cmpdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: if (a < b) returns 0
+// if (a == b) returns 1
+// if (a > b) returns 2
+
+si_int __cmpdi2(di_int a, di_int b);
+
+int test__cmpdi2(di_int a, di_int b, si_int expected)
+{
+ si_int x = __cmpdi2(a, b);
+ if (x != expected)
+ printf("error in __cmpdi2(0x%llX, 0x%llX) = %d, expected %d\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__cmpdi2(0, 0, 1))
+ return 1;
+ if (test__cmpdi2(1, 1, 1))
+ return 1;
+ if (test__cmpdi2(2, 2, 1))
+ return 1;
+ if (test__cmpdi2(0x7FFFFFFF, 0x7FFFFFFF, 1))
+ return 1;
+ if (test__cmpdi2(0x80000000, 0x80000000, 1))
+ return 1;
+ if (test__cmpdi2(0x80000001, 0x80000001, 1))
+ return 1;
+ if (test__cmpdi2(0xFFFFFFFF, 0xFFFFFFFF, 1))
+ return 1;
+ if (test__cmpdi2(0x000000010000000LL, 0x000000010000000LL, 1))
+ return 1;
+ if (test__cmpdi2(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 1))
+ return 1;
+
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000300000001LL, 0))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000300000002LL, 0))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000300000003LL, 0))
+ return 1;
+
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000100000001LL, 2))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000100000002LL, 2))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000100000003LL, 2))
+ return 1;
+
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000200000001LL, 2))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000200000002LL, 1))
+ return 1;
+ if (test__cmpdi2(0x0000000200000002LL, 0x0000000200000003LL, 0))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/cmpti2_test.c b/test/builtins/Unit/cmpti2_test.c
new file mode 100644
index 000000000000..15ee4fc68d53
--- /dev/null
+++ b/test/builtins/Unit/cmpti2_test.c
@@ -0,0 +1,112 @@
+//===-- cmpti2_test.c - Test __cmpti2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __cmpti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: if (a < b) returns 0
+// if (a == b) returns 1
+// if (a > b) returns 2
+
+si_int __cmpti2(ti_int a, ti_int b);
+
+int test__cmpti2(ti_int a, ti_int b, si_int expected)
+{
+ si_int x = __cmpti2(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ printf("error in __cmpti2(0x%llX%.16llX, 0x%llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__cmpti2(0, 0, 1))
+ return 1;
+ if (test__cmpti2(1, 1, 1))
+ return 1;
+ if (test__cmpti2(2, 2, 1))
+ return 1;
+ if (test__cmpti2(0x7FFFFFFF, 0x7FFFFFFF, 1))
+ return 1;
+ if (test__cmpti2(0x80000000, 0x80000000, 1))
+ return 1;
+ if (test__cmpti2(0x80000001, 0x80000001, 1))
+ return 1;
+ if (test__cmpti2(0xFFFFFFFF, 0xFFFFFFFF, 1))
+ return 1;
+ if (test__cmpti2(0x000000010000000LL, 0x000000010000000LL, 1))
+ return 1;
+ if (test__cmpti2(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 1))
+ return 1;
+
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000300000001LL, 0))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000300000002LL, 0))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000300000003LL, 0))
+ return 1;
+
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000100000001LL, 2))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000100000002LL, 2))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000100000003LL, 2))
+ return 1;
+
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000200000001LL, 2))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000200000002LL, 1))
+ return 1;
+ if (test__cmpti2(0x0000000200000002LL, 0x0000000200000003LL, 0))
+ return 1;
+
+ if (test__cmpti2(make_ti(2, 2), make_ti(3, 1), 0))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(3, 2), 0))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(3, 3), 0))
+ return 1;
+
+ if (test__cmpti2(make_ti(2, 2), make_ti(1, 1), 2))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(1, 2), 2))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(1, 3), 2))
+ return 1;
+
+ if (test__cmpti2(make_ti(2, 2), make_ti(2, 1), 2))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(2, 2), 1))
+ return 1;
+ if (test__cmpti2(make_ti(2, 2), make_ti(2, 3), 0))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/comparedf2_test.c b/test/builtins/Unit/comparedf2_test.c
new file mode 100644
index 000000000000..662372290290
--- /dev/null
+++ b/test/builtins/Unit/comparedf2_test.c
@@ -0,0 +1,479 @@
+//===-- cmpdf2_test.c - Test __cmpdf2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests single-precision soft-double comparisons for the compiler-rt
+// library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+int __eqdf2(double, double);
+int __gedf2(double, double);
+int __gtdf2(double, double);
+int __ledf2(double, double);
+int __ltdf2(double, double);
+int __nedf2(double, double);
+int __unorddf2(double, double);
+
+struct TestVector {
+ double a;
+ double b;
+ int eqReference;
+ int geReference;
+ int gtReference;
+ int leReference;
+ int ltReference;
+ int neReference;
+ int unReference;
+};
+
+int test__cmpdf2(const struct TestVector *vector) {
+
+ if (__eqdf2(vector->a, vector->b) != vector->eqReference) {
+ printf("error in __eqdf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __eqdf2(vector->a, vector->b),
+ vector->eqReference);
+ return 1;
+ }
+
+ if (__gedf2(vector->a, vector->b) != vector->geReference) {
+ printf("error in __gedf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __gedf2(vector->a, vector->b),
+ vector->geReference);
+ return 1;
+ }
+
+ if (__gtdf2(vector->a, vector->b) != vector->gtReference) {
+ printf("error in __gtdf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __gtdf2(vector->a, vector->b),
+ vector->gtReference);
+ return 1;
+ }
+
+ if (__ledf2(vector->a, vector->b) != vector->leReference) {
+ printf("error in __ledf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __ledf2(vector->a, vector->b),
+ vector->leReference);
+ return 1;
+ }
+
+ if (__ltdf2(vector->a, vector->b) != vector->ltReference) {
+ printf("error in __ltdf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __ltdf2(vector->a, vector->b),
+ vector->ltReference);
+ return 1;
+ }
+
+ if (__nedf2(vector->a, vector->b) != vector->neReference) {
+ printf("error in __nedf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __nedf2(vector->a, vector->b),
+ vector->neReference);
+ return 1;
+ }
+
+ if (__unorddf2(vector->a, vector->b) != vector->unReference) {
+ printf("error in __unorddf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __unorddf2(vector->a, vector->b),
+ vector->unReference);
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+void generateVectors() {
+
+ const double arguments[] = {
+ __builtin_nan(""),
+ -__builtin_inf(),
+ -0x1.fffffffffffffp1023,
+ -0x1.0000000000001p0
+ -0x1.0000000000000p0,
+ -0x1.fffffffffffffp-1,
+ -0x1.0000000000000p-1022,
+ -0x0.fffffffffffffp-1022,
+ -0x0.0000000000001p-1022,
+ -0.0,
+ 0.0,
+ 0x0.0000000000001p-1022,
+ 0x0.fffffffffffffp-1022,
+ 0x1.0000000000000p-1022,
+ 0x1.fffffffffffffp-1,
+ 0x1.0000000000000p0,
+ 0x1.0000000000001p0,
+ 0x1.fffffffffffffp1023,
+ __builtin_inf()
+ };
+
+ int numArguments = sizeof arguments / sizeof arguments[0];
+
+ for (int i=0; i<numArguments; ++i) {
+ for (int j=0; j<numArguments; ++j) {
+ const double a = arguments[i];
+ const double b = arguments[j];
+ const int leResult = a < b ? -1 : a == b ? 0 : 1;
+ const int geResult = a > b ? 1 : a == b ? 0 : -1;
+ const int unResult = a != a || b != b ? 1 : 0;
+ printf("{%a,%a,%d,%d,%d,%d,%d,%d,%d},\n",
+ a, b,
+ leResult,
+ geResult,
+ geResult,
+ leResult,
+ leResult,
+ leResult,
+ unResult);
+ }
+ }
+} */
+
+static const struct TestVector vectors[] = {
+ {__builtin_nan(""),__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-__builtin_inf(),1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1.fffffffffffffp+1023,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1p+1,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1.fffffffffffffp-1,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1p-1022,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1.fffffcp-1023,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x1p-1074,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),-0x0p+0,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x0p+0,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1p-1074,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1.fffffcp-1023,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1p-1022,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1.fffffffffffffp-1,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1p+0,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1.0000000000001p+0,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),0x1.fffffffffffffp+1023,1,-1,-1,1,1,1,1},
+ {__builtin_nan(""),__builtin_inf(),1,-1,-1,1,1,1,1},
+ {-__builtin_inf(),__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-__builtin_inf(),-__builtin_inf(),0,0,0,0,0,0,0},
+ {-__builtin_inf(),-0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x1p+1,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inf(),__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffffffffffp+1023,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1.fffffffffffffp+1023,-0x1.fffffffffffffp+1023,0,0,0,0,0,0,0},
+ {-0x1.fffffffffffffp+1023,-0x1p+1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,-0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,-0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,-0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp+1023,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1p+1,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1p+1,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x1p+1,-0x1p+1,0,0,0,0,0,0,0},
+ {-0x1p+1,-0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,-0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,-0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p+1,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffffffffffp-1,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1.fffffffffffffp-1,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x1.fffffffffffffp-1,-0x1p+1,1,1,1,1,1,1,0},
+ {-0x1.fffffffffffffp-1,-0x1.fffffffffffffp-1,0,0,0,0,0,0,0},
+ {-0x1.fffffffffffffp-1,-0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,-0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffffffffffp-1,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1p-1022,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1p-1022,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x1p-1022,-0x1p+1,1,1,1,1,1,1,0},
+ {-0x1p-1022,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {-0x1p-1022,-0x1p-1022,0,0,0,0,0,0,0},
+ {-0x1p-1022,-0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1022,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffcp-1023,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1.fffffcp-1023,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-1023,-0x1p+1,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-1023,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-1023,-0x1p-1022,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-1023,-0x1.fffffcp-1023,0,0,0,0,0,0,0},
+ {-0x1.fffffcp-1023,-0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-1023,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x1p-1074,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1p+1,1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1p-1022,1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {-0x1p-1074,-0x1p-1074,0,0,0,0,0,0,0},
+ {-0x1p-1074,-0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x0p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-1074,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {-0x0p+0,-__builtin_inf(),1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1p+1,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1p-1022,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x1p-1074,1,1,1,1,1,1,0},
+ {-0x0p+0,-0x0p+0,0,0,0,0,0,0,0},
+ {-0x0p+0,0x0p+0,0,0,0,0,0,0,0},
+ {-0x0p+0,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p+0,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x0p+0,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x0p+0,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x0p+0,-0x1p+1,1,1,1,1,1,1,0},
+ {0x0p+0,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x0p+0,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x0p+0,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x0p+0,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x0p+0,-0x0p+0,0,0,0,0,0,0,0},
+ {0x0p+0,0x0p+0,0,0,0,0,0,0,0},
+ {0x0p+0,0x1p-1074,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x0p+0,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1p-1074,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1p-1074,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1p-1074,0x0p+0,1,1,1,1,1,1,0},
+ {0x1p-1074,0x1p-1074,0,0,0,0,0,0,0},
+ {0x1p-1074,0x1.fffffcp-1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1074,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffcp-1023,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffcp-1023,0x1.fffffcp-1023,0,0,0,0,0,0,0},
+ {0x1.fffffcp-1023,0x1p-1022,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-1023,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1022,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1p-1022,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1p-1022,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1p-1022,0x0p+0,1,1,1,1,1,1,0},
+ {0x1p-1022,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1p-1022,0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1p-1022,0x1p-1022,0,0,0,0,0,0,0},
+ {0x1p-1022,0x1.fffffffffffffp-1,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1022,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1022,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1022,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-1022,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffffffffffp-1,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffffffffffp-1,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp-1,0x1.fffffffffffffp-1,0,0,0,0,0,0,0},
+ {0x1.fffffffffffffp-1,0x1p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffffffffffp-1,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffffffffffp-1,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffffffffffp-1,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p+0,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1p+0,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1p+0,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1p+0,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1p+0,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1p+0,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1p+0,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1p+0,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1p+0,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1p+0,0x0p+0,1,1,1,1,1,1,0},
+ {0x1p+0,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1p+0,0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1p+0,0x1p-1022,1,1,1,1,1,1,0},
+ {0x1p+0,0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1p+0,0x1p+0,0,0,0,0,0,0,0},
+ {0x1p+0,0x1.0000000000001p+0,-1,-1,-1,-1,-1,-1,0},
+ {0x1p+0,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1p+0,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.0000000000001p+0,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1.0000000000001p+0,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x0p+0,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1p+0,1,1,1,1,1,1,0},
+ {0x1.0000000000001p+0,0x1.0000000000001p+0,0,0,0,0,0,0,0},
+ {0x1.0000000000001p+0,0x1.fffffffffffffp+1023,-1,-1,-1,-1,-1,-1,0},
+ {0x1.0000000000001p+0,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffffffffffp+1023,__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffffffffffp+1023,-__builtin_inf(),1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1p+1,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,-0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x0p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1p-1074,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1p-1022,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1.0000000000001p+0,1,1,1,1,1,1,0},
+ {0x1.fffffffffffffp+1023,0x1.fffffffffffffp+1023,0,0,0,0,0,0,0},
+ {0x1.fffffffffffffp+1023,__builtin_inf(),-1,-1,-1,-1,-1,-1,0},
+ {__builtin_inf(),__builtin_nan(""),1,-1,-1,1,1,1,1},
+ {__builtin_inf(),-__builtin_inf(),1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1p+1,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1p-1022,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x1p-1074,1,1,1,1,1,1,0},
+ {__builtin_inf(),-0x0p+0,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x0p+0,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1p-1074,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1.fffffcp-1023,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1p-1022,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1.fffffffffffffp-1,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1p+0,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1.0000000000001p+0,1,1,1,1,1,1,0},
+ {__builtin_inf(),0x1.fffffffffffffp+1023,1,1,1,1,1,1,0},
+ {__builtin_inf(),__builtin_inf(),0,0,0,0,0,0,0},
+};
+
+int main(int argc, char *argv[]) {
+ const int numVectors = sizeof vectors / sizeof vectors[0];
+ int i;
+ for (i = 0; i<numVectors; ++i) {
+ if (test__cmpdf2(&vectors[i])) return 1;
+ }
+ return 0;
+}
diff --git a/test/builtins/Unit/comparesf2_test.c b/test/builtins/Unit/comparesf2_test.c
new file mode 100644
index 000000000000..026e90053bcf
--- /dev/null
+++ b/test/builtins/Unit/comparesf2_test.c
@@ -0,0 +1,479 @@
+//===-- cmpsf2_test.c - Test __cmpsf2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests single-precision soft-float comparisons for the compiler-rt
+// library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+int __eqsf2(float, float);
+int __gesf2(float, float);
+int __gtsf2(float, float);
+int __lesf2(float, float);
+int __ltsf2(float, float);
+int __nesf2(float, float);
+int __unordsf2(float, float);
+
+struct TestVector {
+ float a;
+ float b;
+ int eqReference;
+ int geReference;
+ int gtReference;
+ int leReference;
+ int ltReference;
+ int neReference;
+ int unReference;
+};
+
+int test__cmpsf2(const struct TestVector *vector) {
+
+ if (__eqsf2(vector->a, vector->b) != vector->eqReference) {
+ printf("error in __eqsf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __eqsf2(vector->a, vector->b),
+ vector->eqReference);
+ return 1;
+ }
+
+ if (__gesf2(vector->a, vector->b) != vector->geReference) {
+ printf("error in __gesf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __gesf2(vector->a, vector->b),
+ vector->geReference);
+ return 1;
+ }
+
+ if (__gtsf2(vector->a, vector->b) != vector->gtReference) {
+ printf("error in __gtsf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __gtsf2(vector->a, vector->b),
+ vector->gtReference);
+ return 1;
+ }
+
+ if (__lesf2(vector->a, vector->b) != vector->leReference) {
+ printf("error in __lesf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __lesf2(vector->a, vector->b),
+ vector->leReference);
+ return 1;
+ }
+
+ if (__ltsf2(vector->a, vector->b) != vector->ltReference) {
+ printf("error in __ltsf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __ltsf2(vector->a, vector->b),
+ vector->ltReference);
+ return 1;
+ }
+
+ if (__nesf2(vector->a, vector->b) != vector->neReference) {
+ printf("error in __nesf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __nesf2(vector->a, vector->b),
+ vector->neReference);
+ return 1;
+ }
+
+ if (__unordsf2(vector->a, vector->b) != vector->unReference) {
+ printf("error in __unordsf2(%a, %a) = %d, expected %d\n",
+ vector->a, vector->b,
+ __unordsf2(vector->a, vector->b),
+ vector->unReference);
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+void generateVectors() {
+
+ const float arguments[] = {
+ __builtin_nanf(""),
+ -__builtin_inff(),
+ -0x1.fffffep127,
+ -0x1.000002p0
+ -0x1.000000p0,
+ -0x1.fffffep-1f,
+ -0x1.000000p-126f,
+ -0x0.fffffep-126f,
+ -0x0.000002p-126f,
+ -0.0,
+ 0.0,
+ 0x0.000002p-126f,
+ 0x0.fffffep-126f,
+ 0x1.000000p-126f,
+ 0x1.fffffep-1f,
+ 0x1.000000p0,
+ 0x1.000002p0,
+ 0x1.fffffep127,
+ __builtin_inff()
+ };
+
+ int numArguments = sizeof arguments / sizeof arguments[0];
+
+ for (int i=0; i<numArguments; ++i) {
+ for (int j=0; j<numArguments; ++j) {
+ const float a = arguments[i];
+ const float b = arguments[j];
+ const int leResult = a < b ? -1 : a == b ? 0 : 1;
+ const int geResult = a > b ? 1 : a == b ? 0 : -1;
+ const int unResult = a != a || b != b ? 1 : 0;
+ printf("{%a,%a,%d,%d,%d,%d,%d,%d,%d},\n",
+ a, b,
+ leResult,
+ geResult,
+ geResult,
+ leResult,
+ leResult,
+ leResult,
+ unResult);
+ }
+ }
+} */
+
+static const struct TestVector vectors[] = {
+ {__builtin_nanf(""),__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-__builtin_inff(),1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1.fffffep+127f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1p0f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1.fffffep-1f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1p-126f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1.fffffcp-127,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x1p-149f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),-0x0p0f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x0p0f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1p-149f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1.fffffcp-127,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1p-126f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1.fffffep-1f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1p0f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1.000002p0f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),0x1.fffffep+127f,1,-1,-1,1,1,1,1},
+ {__builtin_nanf(""),__builtin_inff(),1,-1,-1,1,1,1,1},
+ {-__builtin_inff(),__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-__builtin_inff(),-__builtin_inff(),0,0,0,0,0,0,0},
+ {-__builtin_inff(),-0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-__builtin_inff(),__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffep+127f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1.fffffep+127f,-0x1.fffffep+127f,0,0,0,0,0,0,0},
+ {-0x1.fffffep+127f,-0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,-0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,-0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,-0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep+127f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1p0f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1p0f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x1p0f,-0x1p0f,0,0,0,0,0,0,0},
+ {-0x1p0f,-0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,-0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,-0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p0f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffep-1f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1.fffffep-1f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x1.fffffep-1f,-0x1p0f,1,1,1,1,1,1,0},
+ {-0x1.fffffep-1f,-0x1.fffffep-1f,0,0,0,0,0,0,0},
+ {-0x1.fffffep-1f,-0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,-0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffep-1f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1p-126f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1p-126f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x1p-126f,-0x1p0f,1,1,1,1,1,1,0},
+ {-0x1p-126f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {-0x1p-126f,-0x1p-126f,0,0,0,0,0,0,0},
+ {-0x1p-126f,-0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-126f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1.fffffcp-127,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1.fffffcp-127,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-127,-0x1p0f,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-127,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-127,-0x1p-126f,1,1,1,1,1,1,0},
+ {-0x1.fffffcp-127,-0x1.fffffcp-127,0,0,0,0,0,0,0},
+ {-0x1.fffffcp-127,-0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1.fffffcp-127,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x1p-149f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1p0f,1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1p-126f,1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {-0x1p-149f,-0x1p-149f,0,0,0,0,0,0,0},
+ {-0x1p-149f,-0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x0p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x1p-149f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {-0x0p0f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1p0f,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1p-126f,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x1p-149f,1,1,1,1,1,1,0},
+ {-0x0p0f,-0x0p0f,0,0,0,0,0,0,0},
+ {-0x0p0f,0x0p0f,0,0,0,0,0,0,0},
+ {-0x0p0f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {-0x0p0f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x0p0f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x0p0f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x0p0f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x0p0f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x0p0f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x0p0f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x0p0f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x0p0f,-0x0p0f,0,0,0,0,0,0,0},
+ {0x0p0f,0x0p0f,0,0,0,0,0,0,0},
+ {0x0p0f,0x1p-149f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x0p0f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1p-149f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1p-149f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1p-149f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1p-149f,0x1p-149f,0,0,0,0,0,0,0},
+ {0x1p-149f,0x1.fffffcp-127,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-149f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffcp-127,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffcp-127,0x1.fffffcp-127,0,0,0,0,0,0,0},
+ {0x1.fffffcp-127,0x1p-126f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffcp-127,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p-126f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1p-126f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1p-126f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1p-126f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1p-126f,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1p-126f,0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1p-126f,0x1p-126f,0,0,0,0,0,0,0},
+ {0x1p-126f,0x1.fffffep-1f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-126f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-126f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-126f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p-126f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffep-1f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffep-1f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.fffffep-1f,0x1.fffffep-1f,0,0,0,0,0,0,0},
+ {0x1.fffffep-1f,0x1p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffep-1f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffep-1f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffep-1f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1p0f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1p0f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1p0f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1p0f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1p0f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1p0f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1p0f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1p0f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1p0f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1p0f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1p0f,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1p0f,0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1p0f,0x1p-126f,1,1,1,1,1,1,0},
+ {0x1p0f,0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1p0f,0x1p0f,0,0,0,0,0,0,0},
+ {0x1p0f,0x1.000002p0f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p0f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1p0f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.000002p0f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1.000002p0f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1p0f,1,1,1,1,1,1,0},
+ {0x1.000002p0f,0x1.000002p0f,0,0,0,0,0,0,0},
+ {0x1.000002p0f,0x1.fffffep+127f,-1,-1,-1,-1,-1,-1,0},
+ {0x1.000002p0f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {0x1.fffffep+127f,__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {0x1.fffffep+127f,-__builtin_inff(),1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,-0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x0p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1p-149f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1p-126f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1.000002p0f,1,1,1,1,1,1,0},
+ {0x1.fffffep+127f,0x1.fffffep+127f,0,0,0,0,0,0,0},
+ {0x1.fffffep+127f,__builtin_inff(),-1,-1,-1,-1,-1,-1,0},
+ {__builtin_inff(),__builtin_nanf(""),1,-1,-1,1,1,1,1},
+ {__builtin_inff(),-__builtin_inff(),1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1p0f,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1p-126f,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x1p-149f,1,1,1,1,1,1,0},
+ {__builtin_inff(),-0x0p0f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x0p0f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1p-149f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1.fffffcp-127,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1p-126f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1.fffffep-1f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1p0f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1.000002p0f,1,1,1,1,1,1,0},
+ {__builtin_inff(),0x1.fffffep+127f,1,1,1,1,1,1,0},
+ {__builtin_inff(),__builtin_inff(),0,0,0,0,0,0,0},
+};
+
+int main(int argc, char *argv[]) {
+ const int numVectors = sizeof vectors / sizeof vectors[0];
+ int i;
+ for (i = 0; i<numVectors; ++i) {
+ if (test__cmpsf2(&vectors[i])) return 1;
+ }
+ return 0;
+}
diff --git a/test/builtins/Unit/ctzdi2_test.c b/test/builtins/Unit/ctzdi2_test.c
new file mode 100644
index 000000000000..1f2d101a1943
--- /dev/null
+++ b/test/builtins/Unit/ctzdi2_test.c
@@ -0,0 +1,67 @@
+//===-- ctzdi2_test.c - Test __ctzdi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ctzdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: the number of trailing 0-bits
+
+// Precondition: a != 0
+
+si_int __ctzdi2(di_int a);
+
+int test__ctzdi2(di_int a, si_int expected)
+{
+ si_int x = __ctzdi2(a);
+ if (x != expected)
+ printf("error in __ctzdi2(0x%llX) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+// if (test__ctzdi2(0x00000000, N)) // undefined
+// return 1;
+ if (test__ctzdi2(0x00000001, 0))
+ return 1;
+ if (test__ctzdi2(0x00000002, 1))
+ return 1;
+ if (test__ctzdi2(0x00000003, 0))
+ return 1;
+ if (test__ctzdi2(0x00000004, 2))
+ return 1;
+ if (test__ctzdi2(0x00000005, 0))
+ return 1;
+ if (test__ctzdi2(0x0000000A, 1))
+ return 1;
+ if (test__ctzdi2(0x10000000, 28))
+ return 1;
+ if (test__ctzdi2(0x20000000, 29))
+ return 1;
+ if (test__ctzdi2(0x60000000, 29))
+ return 1;
+ if (test__ctzdi2(0x80000000uLL, 31))
+ return 1;
+ if (test__ctzdi2(0x0000050000000000uLL, 40))
+ return 1;
+ if (test__ctzdi2(0x0200080000000000uLL, 43))
+ return 1;
+ if (test__ctzdi2(0x7200000000000000uLL, 57))
+ return 1;
+ if (test__ctzdi2(0x8000000000000000uLL, 63))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/ctzsi2_test.c b/test/builtins/Unit/ctzsi2_test.c
new file mode 100644
index 000000000000..36f221595b68
--- /dev/null
+++ b/test/builtins/Unit/ctzsi2_test.c
@@ -0,0 +1,569 @@
+//===-- ctzsi2_test.c - Test __ctzsi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ctzsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: the number of trailing 0-bits
+
+// Precondition: a != 0
+
+si_int __ctzsi2(si_int a);
+
+int test__ctzsi2(si_int a, si_int expected)
+{
+ si_int x = __ctzsi2(a);
+ if (x != expected)
+ printf("error in __ctzsi2(0x%X) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+// if (test__ctzsi2(0x00000000, 32)) // undefined
+// return 1;
+ if (test__ctzsi2(0x00000001, 0))
+ return 1;
+ if (test__ctzsi2(0x00000002, 1))
+ return 1;
+ if (test__ctzsi2(0x00000003, 0))
+ return 1;
+ if (test__ctzsi2(0x00000004, 2))
+ return 1;
+ if (test__ctzsi2(0x00000005, 0))
+ return 1;
+ if (test__ctzsi2(0x00000006, 1))
+ return 1;
+ if (test__ctzsi2(0x00000007, 0))
+ return 1;
+ if (test__ctzsi2(0x00000008, 3))
+ return 1;
+ if (test__ctzsi2(0x00000009, 0))
+ return 1;
+ if (test__ctzsi2(0x0000000A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000000B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000000C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000000D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000000E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000000F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000010, 4))
+ return 1;
+ if (test__ctzsi2(0x00000012, 1))
+ return 1;
+ if (test__ctzsi2(0x00000013, 0))
+ return 1;
+ if (test__ctzsi2(0x00000014, 2))
+ return 1;
+ if (test__ctzsi2(0x00000015, 0))
+ return 1;
+ if (test__ctzsi2(0x00000016, 1))
+ return 1;
+ if (test__ctzsi2(0x00000017, 0))
+ return 1;
+ if (test__ctzsi2(0x00000018, 3))
+ return 1;
+ if (test__ctzsi2(0x00000019, 0))
+ return 1;
+ if (test__ctzsi2(0x0000001A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000001B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000001C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000001D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000001E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000001F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000020, 5))
+ return 1;
+ if (test__ctzsi2(0x00000022, 1))
+ return 1;
+ if (test__ctzsi2(0x00000023, 0))
+ return 1;
+ if (test__ctzsi2(0x00000024, 2))
+ return 1;
+ if (test__ctzsi2(0x00000025, 0))
+ return 1;
+ if (test__ctzsi2(0x00000026, 1))
+ return 1;
+ if (test__ctzsi2(0x00000027, 0))
+ return 1;
+ if (test__ctzsi2(0x00000028, 3))
+ return 1;
+ if (test__ctzsi2(0x00000029, 0))
+ return 1;
+ if (test__ctzsi2(0x0000002A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000002B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000002C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000002D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000002E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000002F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000030, 4))
+ return 1;
+ if (test__ctzsi2(0x00000032, 1))
+ return 1;
+ if (test__ctzsi2(0x00000033, 0))
+ return 1;
+ if (test__ctzsi2(0x00000034, 2))
+ return 1;
+ if (test__ctzsi2(0x00000035, 0))
+ return 1;
+ if (test__ctzsi2(0x00000036, 1))
+ return 1;
+ if (test__ctzsi2(0x00000037, 0))
+ return 1;
+ if (test__ctzsi2(0x00000038, 3))
+ return 1;
+ if (test__ctzsi2(0x00000039, 0))
+ return 1;
+ if (test__ctzsi2(0x0000003A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000003B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000003C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000003D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000003E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000003F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000040, 6))
+ return 1;
+ if (test__ctzsi2(0x00000042, 1))
+ return 1;
+ if (test__ctzsi2(0x00000043, 0))
+ return 1;
+ if (test__ctzsi2(0x00000044, 2))
+ return 1;
+ if (test__ctzsi2(0x00000045, 0))
+ return 1;
+ if (test__ctzsi2(0x00000046, 1))
+ return 1;
+ if (test__ctzsi2(0x00000047, 0))
+ return 1;
+ if (test__ctzsi2(0x00000048, 3))
+ return 1;
+ if (test__ctzsi2(0x00000049, 0))
+ return 1;
+ if (test__ctzsi2(0x0000004A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000004B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000004C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000004D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000004E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000004F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000050, 4))
+ return 1;
+ if (test__ctzsi2(0x00000052, 1))
+ return 1;
+ if (test__ctzsi2(0x00000053, 0))
+ return 1;
+ if (test__ctzsi2(0x00000054, 2))
+ return 1;
+ if (test__ctzsi2(0x00000055, 0))
+ return 1;
+ if (test__ctzsi2(0x00000056, 1))
+ return 1;
+ if (test__ctzsi2(0x00000057, 0))
+ return 1;
+ if (test__ctzsi2(0x00000058, 3))
+ return 1;
+ if (test__ctzsi2(0x00000059, 0))
+ return 1;
+ if (test__ctzsi2(0x0000005A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000005B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000005C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000005D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000005E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000005F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000060, 5))
+ return 1;
+ if (test__ctzsi2(0x00000062, 1))
+ return 1;
+ if (test__ctzsi2(0x00000063, 0))
+ return 1;
+ if (test__ctzsi2(0x00000064, 2))
+ return 1;
+ if (test__ctzsi2(0x00000065, 0))
+ return 1;
+ if (test__ctzsi2(0x00000066, 1))
+ return 1;
+ if (test__ctzsi2(0x00000067, 0))
+ return 1;
+ if (test__ctzsi2(0x00000068, 3))
+ return 1;
+ if (test__ctzsi2(0x00000069, 0))
+ return 1;
+ if (test__ctzsi2(0x0000006A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000006B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000006C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000006D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000006E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000006F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000070, 4))
+ return 1;
+ if (test__ctzsi2(0x00000072, 1))
+ return 1;
+ if (test__ctzsi2(0x00000073, 0))
+ return 1;
+ if (test__ctzsi2(0x00000074, 2))
+ return 1;
+ if (test__ctzsi2(0x00000075, 0))
+ return 1;
+ if (test__ctzsi2(0x00000076, 1))
+ return 1;
+ if (test__ctzsi2(0x00000077, 0))
+ return 1;
+ if (test__ctzsi2(0x00000078, 3))
+ return 1;
+ if (test__ctzsi2(0x00000079, 0))
+ return 1;
+ if (test__ctzsi2(0x0000007A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000007B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000007C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000007D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000007E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000007F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000080, 7))
+ return 1;
+ if (test__ctzsi2(0x00000082, 1))
+ return 1;
+ if (test__ctzsi2(0x00000083, 0))
+ return 1;
+ if (test__ctzsi2(0x00000084, 2))
+ return 1;
+ if (test__ctzsi2(0x00000085, 0))
+ return 1;
+ if (test__ctzsi2(0x00000086, 1))
+ return 1;
+ if (test__ctzsi2(0x00000087, 0))
+ return 1;
+ if (test__ctzsi2(0x00000088, 3))
+ return 1;
+ if (test__ctzsi2(0x00000089, 0))
+ return 1;
+ if (test__ctzsi2(0x0000008A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000008B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000008C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000008D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000008E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000008F, 0))
+ return 1;
+ if (test__ctzsi2(0x00000090, 4))
+ return 1;
+ if (test__ctzsi2(0x00000092, 1))
+ return 1;
+ if (test__ctzsi2(0x00000093, 0))
+ return 1;
+ if (test__ctzsi2(0x00000094, 2))
+ return 1;
+ if (test__ctzsi2(0x00000095, 0))
+ return 1;
+ if (test__ctzsi2(0x00000096, 1))
+ return 1;
+ if (test__ctzsi2(0x00000097, 0))
+ return 1;
+ if (test__ctzsi2(0x00000098, 3))
+ return 1;
+ if (test__ctzsi2(0x00000099, 0))
+ return 1;
+ if (test__ctzsi2(0x0000009A, 1))
+ return 1;
+ if (test__ctzsi2(0x0000009B, 0))
+ return 1;
+ if (test__ctzsi2(0x0000009C, 2))
+ return 1;
+ if (test__ctzsi2(0x0000009D, 0))
+ return 1;
+ if (test__ctzsi2(0x0000009E, 1))
+ return 1;
+ if (test__ctzsi2(0x0000009F, 0))
+ return 1;
+ if (test__ctzsi2(0x000000A0, 5))
+ return 1;
+ if (test__ctzsi2(0x000000A2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000A3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000A4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000A5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000A6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000A7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000A8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000A9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000AA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000AB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000AC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000AD, 0))
+ return 1;
+ if (test__ctzsi2(0x000000AE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000AF, 0))
+ return 1;
+ if (test__ctzsi2(0x000000B0, 4))
+ return 1;
+ if (test__ctzsi2(0x000000B2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000B3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000B4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000B5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000B6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000B7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000B8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000B9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000BA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000BB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000BC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000BD, 0))
+ return 1;
+ if (test__ctzsi2(0x000000BE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000BF, 0))
+ return 1;
+ if (test__ctzsi2(0x000000C0, 6))
+ return 1;
+ if (test__ctzsi2(0x000000C2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000C3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000C4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000C5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000C6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000C7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000C8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000C9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000CA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000CB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000CC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000CD, 0))
+ return 1;
+ if (test__ctzsi2(0x000000CE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000CF, 0))
+ return 1;
+ if (test__ctzsi2(0x000000D0, 4))
+ return 1;
+ if (test__ctzsi2(0x000000D2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000D3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000D4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000D5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000D6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000D7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000D8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000D9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000DA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000DB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000DC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000DD, 0))
+ return 1;
+ if (test__ctzsi2(0x000000DE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000DF, 0))
+ return 1;
+ if (test__ctzsi2(0x000000E0, 5))
+ return 1;
+ if (test__ctzsi2(0x000000E2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000E3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000E4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000E5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000E6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000E7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000E8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000E9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000EA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000EB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000EC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000ED, 0))
+ return 1;
+ if (test__ctzsi2(0x000000EE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000EF, 0))
+ return 1;
+ if (test__ctzsi2(0x000000F0, 4))
+ return 1;
+ if (test__ctzsi2(0x000000F2, 1))
+ return 1;
+ if (test__ctzsi2(0x000000F3, 0))
+ return 1;
+ if (test__ctzsi2(0x000000F4, 2))
+ return 1;
+ if (test__ctzsi2(0x000000F5, 0))
+ return 1;
+ if (test__ctzsi2(0x000000F6, 1))
+ return 1;
+ if (test__ctzsi2(0x000000F7, 0))
+ return 1;
+ if (test__ctzsi2(0x000000F8, 3))
+ return 1;
+ if (test__ctzsi2(0x000000F9, 0))
+ return 1;
+ if (test__ctzsi2(0x000000FA, 1))
+ return 1;
+ if (test__ctzsi2(0x000000FB, 0))
+ return 1;
+ if (test__ctzsi2(0x000000FC, 2))
+ return 1;
+ if (test__ctzsi2(0x000000FD, 0))
+ return 1;
+ if (test__ctzsi2(0x000000FE, 1))
+ return 1;
+ if (test__ctzsi2(0x000000FF, 0))
+ return 1;
+
+ if (test__ctzsi2(0x00000100, 8))
+ return 1;
+ if (test__ctzsi2(0x00000200, 9))
+ return 1;
+ if (test__ctzsi2(0x00000400, 10))
+ return 1;
+ if (test__ctzsi2(0x00000800, 11))
+ return 1;
+ if (test__ctzsi2(0x00001000, 12))
+ return 1;
+ if (test__ctzsi2(0x00002000, 13))
+ return 1;
+ if (test__ctzsi2(0x00004000, 14))
+ return 1;
+ if (test__ctzsi2(0x00008000, 15))
+ return 1;
+ if (test__ctzsi2(0x00010000, 16))
+ return 1;
+ if (test__ctzsi2(0x00020000, 17))
+ return 1;
+ if (test__ctzsi2(0x00040000, 18))
+ return 1;
+ if (test__ctzsi2(0x00080000, 19))
+ return 1;
+ if (test__ctzsi2(0x00100000, 20))
+ return 1;
+ if (test__ctzsi2(0x00200000, 21))
+ return 1;
+ if (test__ctzsi2(0x00400000, 22))
+ return 1;
+ if (test__ctzsi2(0x00800000, 23))
+ return 1;
+ if (test__ctzsi2(0x01000000, 24))
+ return 1;
+ if (test__ctzsi2(0x02000000, 25))
+ return 1;
+ if (test__ctzsi2(0x04000000, 26))
+ return 1;
+ if (test__ctzsi2(0x08000000, 27))
+ return 1;
+ if (test__ctzsi2(0x10000000, 28))
+ return 1;
+ if (test__ctzsi2(0x20000000, 29))
+ return 1;
+ if (test__ctzsi2(0x40000000, 30))
+ return 1;
+ if (test__ctzsi2(0x80000000, 31))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/ctzti2_test.c b/test/builtins/Unit/ctzti2_test.c
new file mode 100644
index 000000000000..9a972f9e2f94
--- /dev/null
+++ b/test/builtins/Unit/ctzti2_test.c
@@ -0,0 +1,84 @@
+//===-- ctzti2_test.c - Test __ctzti2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ctzti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: the number of trailing 0-bits
+
+// Precondition: a != 0
+
+si_int __ctzti2(ti_int a);
+
+int test__ctzti2(ti_int a, si_int expected)
+{
+ si_int x = __ctzti2(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __ctzti2(0x%llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__ctzti2(0x00000001, 0))
+ return 1;
+ if (test__ctzti2(0x00000002, 1))
+ return 1;
+ if (test__ctzti2(0x00000003, 0))
+ return 1;
+ if (test__ctzti2(0x00000004, 2))
+ return 1;
+ if (test__ctzti2(0x00000005, 0))
+ return 1;
+ if (test__ctzti2(0x0000000A, 1))
+ return 1;
+ if (test__ctzti2(0x10000000, 28))
+ return 1;
+ if (test__ctzti2(0x20000000, 29))
+ return 1;
+ if (test__ctzti2(0x60000000, 29))
+ return 1;
+ if (test__ctzti2(0x80000000uLL, 31))
+ return 1;
+ if (test__ctzti2(0x0000050000000000uLL, 40))
+ return 1;
+ if (test__ctzti2(0x0200080000000000uLL, 43))
+ return 1;
+ if (test__ctzti2(0x7200000000000000uLL, 57))
+ return 1;
+ if (test__ctzti2(0x8000000000000000uLL, 63))
+ return 1;
+ if (test__ctzti2(make_ti(0x00000000A0000000LL, 0x0000000000000000LL), 93))
+ return 1;
+ if (test__ctzti2(make_ti(0xF000000000000000LL, 0x0000000000000000LL), 124))
+ return 1;
+ if (test__ctzti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL), 127))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divdc3_test.c b/test/builtins/Unit/divdc3_test.c
new file mode 100644
index 000000000000..9224cddceeb8
--- /dev/null
+++ b/test/builtins/Unit/divdc3_test.c
@@ -0,0 +1,370 @@
+//===-- divdc3_test.c - Test __divdc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divdc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the quotient of (a + ib) / (c + id)
+
+double _Complex __divdc3(double __a, double __b, double __c, double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creal(x)) || isinf(cimag(x)))
+ return inf;
+ if (isnan(creal(x)) && isnan(cimag(x)))
+ return NaN;
+ if (isnan(creal(x)))
+ {
+ if (cimag(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimag(x)))
+ {
+ if (creal(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__divdc3(double a, double b, double c, double d)
+{
+ double _Complex r = __divdc3(a, b, c, d);
+// printf("test__divdc3(%f, %f, %f, %f) = %f + I%f\n",
+// a, b, c, d, creal(r), cimag(r));
+ double _Complex dividend;
+ double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ {
+ double _Complex z = (a * c + b * d) / (c * c + d * d)
+ + (b * c - a * d) / (c * c + d * d) * _Complex_I;
+ if (cabs((r-z)/r) > 1.e-6)
+ return 1;
+ }
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+int main()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__divdc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divdf3vfp_test.c b/test/builtins/Unit/divdf3vfp_test.c
new file mode 100644
index 000000000000..e13822ffcaa0
--- /dev/null
+++ b/test/builtins/Unit/divdf3vfp_test.c
@@ -0,0 +1,48 @@
+//===-- divdf3vfp_test.c - Test __divdf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divdf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#if __arm__
+extern double __divdf3vfp(double a, double b);
+
+int test__divdf3vfp(double a, double b)
+{
+ double actual = __divdf3vfp(a, b);
+ double expected = a / b;
+ if (actual != expected)
+ printf("error in test__divdf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__divdf3vfp(1.0, 1.0))
+ return 1;
+ if (test__divdf3vfp(12345.678, 1.23))
+ return 1;
+ if (test__divdf3vfp(-10.0, 0.25))
+ return 1;
+ if (test__divdf3vfp(10.0, -2.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/divdi3_test.c b/test/builtins/Unit/divdi3_test.c
new file mode 100644
index 000000000000..c25f917a419e
--- /dev/null
+++ b/test/builtins/Unit/divdi3_test.c
@@ -0,0 +1,58 @@
+//===-- divdi3_test.c - Test __divdi3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divdi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a / b
+
+di_int __divdi3(di_int a, di_int b);
+
+int test__divdi3(di_int a, di_int b, di_int expected)
+{
+ di_int x = __divdi3(a, b);
+ if (x != expected)
+ printf("error in __divdi3: %lld / %lld = %lld, expected %lld\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__divdi3(0, 1, 0))
+ return 1;
+ if (test__divdi3(0, -1, 0))
+ return 1;
+
+ if (test__divdi3(2, 1, 2))
+ return 1;
+ if (test__divdi3(2, -1, -2))
+ return 1;
+ if (test__divdi3(-2, 1, -2))
+ return 1;
+ if (test__divdi3(-2, -1, 2))
+ return 1;
+
+ if (test__divdi3(0x8000000000000000LL, 1, 0x8000000000000000LL))
+ return 1;
+ if (test__divdi3(0x8000000000000000LL, -1, 0x8000000000000000LL))
+ return 1;
+ if (test__divdi3(0x8000000000000000LL, -2, 0x4000000000000000LL))
+ return 1;
+ if (test__divdi3(0x8000000000000000LL, 2, 0xC000000000000000LL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divmodsi4_test.c b/test/builtins/Unit/divmodsi4_test.c
new file mode 100644
index 000000000000..bea31ea9a445
--- /dev/null
+++ b/test/builtins/Unit/divmodsi4_test.c
@@ -0,0 +1,73 @@
+//===-- divmodsi4_test.c - Test __divmodsi4 -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divmodsi4 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a / b
+
+extern si_int __divmodsi4(si_int a, si_int b, si_int* rem);
+
+
+int test__divmodsi4(si_int a, si_int b,
+ si_int expected_result, si_int expected_rem)
+{
+ si_int rem;
+ si_int result = __divmodsi4(a, b, &rem);
+ if (result != expected_result) {
+ printf("error in __divmodsi4: %d / %d = %d, expected %d\n",
+ a, b, result, expected_result);
+ return 1;
+ }
+ if (rem != expected_rem) {
+ printf("error in __divmodsi4: %d mod %d = %d, expected %d\n",
+ a, b, rem, expected_rem);
+ return 1;
+ }
+
+ return 0;
+}
+
+
+int main()
+{
+ if (test__divmodsi4(0, 1, 0, 0))
+ return 1;
+ if (test__divmodsi4(0, -1, 0, 0))
+ return 1;
+
+ if (test__divmodsi4(2, 1, 2, 0))
+ return 1;
+ if (test__divmodsi4(2, -1, -2, 0))
+ return 1;
+ if (test__divmodsi4(-2, 1, -2, 0))
+ return 1;
+ if (test__divmodsi4(-2, -1, 2, 0))
+ return 1;
+
+ if (test__divmodsi4(7, 5, 1, 2))
+ return 1;
+ if (test__divmodsi4(-7, 5, -1, -2))
+ return 1;
+ if (test__divmodsi4(19, 5, 3, 4))
+ return 1;
+ if (test__divmodsi4(19, -5, -3, 4))
+ return 1;
+
+ if (test__divmodsi4(0x80000000, 8, 0xf0000000, 0))
+ return 1;
+ if (test__divmodsi4(0x80000007, 8, 0xf0000001, -1))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divsc3_test.c b/test/builtins/Unit/divsc3_test.c
new file mode 100644
index 000000000000..9d060a2d1489
--- /dev/null
+++ b/test/builtins/Unit/divsc3_test.c
@@ -0,0 +1,370 @@
+//===-- divsc3_test.c - Test __divsc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divsc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the quotient of (a + ib) / (c + id)
+
+float _Complex __divsc3(float __a, float __b, float __c, float __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(float _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(crealf(x)) || isinf(cimagf(x)))
+ return inf;
+ if (isnan(crealf(x)) && isnan(cimagf(x)))
+ return NaN;
+ if (isnan(crealf(x)))
+ {
+ if (cimagf(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagf(x)))
+ {
+ if (crealf(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__divsc3(float a, float b, float c, float d)
+{
+ float _Complex r = __divsc3(a, b, c, d);
+// printf("test__divsc3(%f, %f, %f, %f) = %f + I%f\n",
+// a, b, c, d, crealf(r), cimagf(r));
+ float _Complex dividend;
+ float _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ {
+ float _Complex z = (a * c + b * d) / (c * c + d * d)
+ + (b * c - a * d) / (c * c + d * d) * _Complex_I;
+ if (r != z)
+ return 1;
+ }
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+float x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+int main()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__divsc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divsf3vfp_test.c b/test/builtins/Unit/divsf3vfp_test.c
new file mode 100644
index 000000000000..8382558412cf
--- /dev/null
+++ b/test/builtins/Unit/divsf3vfp_test.c
@@ -0,0 +1,48 @@
+//===-- divsf3vfp_test.c - Test __divsf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divsf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __divsf3vfp(float a, float b);
+
+#if __arm__
+int test__divsf3vfp(float a, float b)
+{
+ float actual = __divsf3vfp(a, b);
+ float expected = a / b;
+ if (actual != expected)
+ printf("error in test__divsf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__divsf3vfp(1.0, 1.0))
+ return 1;
+ if (test__divsf3vfp(12345.678, 1.23))
+ return 1;
+ if (test__divsf3vfp(0.0, HUGE_VALF))
+ return 1;
+ if (test__divsf3vfp(10.0, -2.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/divsi3_test.c b/test/builtins/Unit/divsi3_test.c
new file mode 100644
index 000000000000..6fda54ff37ec
--- /dev/null
+++ b/test/builtins/Unit/divsi3_test.c
@@ -0,0 +1,56 @@
+//===-- divsi3_test.c - Test __divsi3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divsi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a / b
+
+si_int __divsi3(si_int a, si_int b);
+
+int test__divsi3(si_int a, si_int b, si_int expected)
+{
+ si_int x = __divsi3(a, b);
+ if (x != expected)
+ printf("error in __divsi3: %d / %d = %d, expected %d\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+ if (test__divsi3(0, 1, 0))
+ return 1;
+ if (test__divsi3(0, -1, 0))
+ return 1;
+
+ if (test__divsi3(2, 1, 2))
+ return 1;
+ if (test__divsi3(2, -1, -2))
+ return 1;
+ if (test__divsi3(-2, 1, -2))
+ return 1;
+ if (test__divsi3(-2, -1, 2))
+ return 1;
+
+ if (test__divsi3(0x80000000, 1, 0x80000000))
+ return 1;
+ if (test__divsi3(0x80000000, -1, 0x80000000))
+ return 1;
+ if (test__divsi3(0x80000000, -2, 0x40000000))
+ return 1;
+ if (test__divsi3(0x80000000, 2, 0xC0000000))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/divtc3_test.c b/test/builtins/Unit/divtc3_test.c
new file mode 100644
index 000000000000..7bb74d755146
--- /dev/null
+++ b/test/builtins/Unit/divtc3_test.c
@@ -0,0 +1,382 @@
+//===-- divtc3_test.c - Test __divtc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divtc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#if _ARCH_PPC
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the quotient of (a + ib) / (c + id)
+
+long double _Complex
+__divtc3(long double __a, long double __b, long double __c, long double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(long double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creall(x)) || isinf(cimagl(x)))
+ return inf;
+ if (isnan(creall(x)) && isnan(cimagl(x)))
+ return NaN;
+ if (isnan(creall(x)))
+ {
+ if (cimagl(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagl(x)))
+ {
+ if (creall(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__divtc3(long double a, long double b, long double c, long double d)
+{
+ long double _Complex r = __divtc3(a, b, c, d);
+// printf("test__divtc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
+// a, b, c, d, creall(r), cimagl(r));
+
+ long double _Complex dividend;
+ long double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ {
+ long double _Complex z = (a * c + b * d) / (c * c + d * d)
+ + (b * c - a * d) / (c * c + d * d) * _Complex_I;
+ if (cabs((r - z)/r) > 1.e-6)
+ return 1;
+ }
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+long double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+#endif
+
+int main()
+{
+#if _ARCH_PPC
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__divtc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+// printf("No errors found.\n");
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/divtf3_test.c b/test/builtins/Unit/divtf3_test.c
new file mode 100644
index 000000000000..dad631cc4f17
--- /dev/null
+++ b/test/builtins/Unit/divtf3_test.c
@@ -0,0 +1,94 @@
+//===--------------- divtf3_test.c - Test __divtf3 ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divtf3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+// Returns: a / b
+long double __divtf3(long double a, long double b);
+
+int test__divtf3(long double a, long double b,
+ uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __divtf3(a, b);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret){
+ printf("error in test__divtf3(%.20Lf, %.20Lf) = %.20Lf, "
+ "expected %.20Lf\n", a, b, x,
+ fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ // qNaN / any = qNaN
+ if (test__divtf3(makeQNaN128(),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // NaN / any = NaN
+ if (test__divtf3(makeNaN128(UINT64_C(0x800030000000)),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf / any = inf
+ if (test__divtf3(makeInf128(),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // any / any
+ if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
+ 0x1.eedcbaba3a94546558237654321fp-1L,
+ UINT64_C(0x4004b0b72924d407),
+ UINT64_C(0x0717e84356c6eba2)))
+ return 1;
+ if (test__divtf3(0x1.a2b34c56d745382f9abf2c3dfeffp-50L,
+ 0x1.ed2c3ba15935332532287654321fp-9L,
+ UINT64_C(0x3fd5b2af3f828c9b),
+ UINT64_C(0x40e51f64cde8b1f2)))
+ return 15;
+ if (test__divtf3(0x1.2345f6aaaa786555f42432abcdefp+456L,
+ 0x1.edacbba9874f765463544dd3621fp+6400L,
+ UINT64_C(0x28c62e15dc464466),
+ UINT64_C(0xb5a07586348557ac)))
+ return 1;
+ if (test__divtf3(0x1.2d3456f789ba6322bc665544edefp-234L,
+ 0x1.eddcdba39f3c8b7a36564354321fp-4455L,
+ UINT64_C(0x507b38442b539266),
+ UINT64_C(0x22ce0f1d024e1252)))
+ return 1;
+ if (test__divtf3(0x1.2345f6b77b7a8953365433abcdefp+234L,
+ 0x1.edcba987d6bb3aa467754354321fp-4055L,
+ UINT64_C(0x50bf2e02f0798d36),
+ UINT64_C(0x5e6fcb6b60044078)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/divti3_test.c b/test/builtins/Unit/divti3_test.c
new file mode 100644
index 000000000000..bc81c2a5418d
--- /dev/null
+++ b/test/builtins/Unit/divti3_test.c
@@ -0,0 +1,78 @@
+//===-- divti3_test.c - Test __divti3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a / b
+
+ti_int __divti3(ti_int a, ti_int b);
+
+int test__divti3(ti_int a, ti_int b, ti_int expected)
+{
+ ti_int x = __divti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __divti3: 0x%llX%.16llX / 0x%llX%.16llX = "
+ "0x%llX%.16llX, expected 0x%llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__divti3(0, 1, 0))
+ return 1;
+ if (test__divti3(0, -1, 0))
+ return 1;
+
+ if (test__divti3(2, 1, 2))
+ return 1;
+ if (test__divti3(2, -1, -2))
+ return 1;
+ if (test__divti3(-2, 1, -2))
+ return 1;
+ if (test__divti3(-2, -1, 2))
+ return 1;
+
+ if (test__divti3(make_ti(0x8000000000000000LL, 0), 1, make_ti(0x8000000000000000LL, 0)))
+ return 1;
+ if (test__divti3(make_ti(0x8000000000000000LL, 0), -1, make_ti(0x8000000000000000LL, 0)))
+ return 1;
+ if (test__divti3(make_ti(0x8000000000000000LL, 0), -2, make_ti(0x4000000000000000LL, 0)))
+ return 1;
+ if (test__divti3(make_ti(0x8000000000000000LL, 0), 2, make_ti(0xC000000000000000LL, 0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/divxc3_test.c b/test/builtins/Unit/divxc3_test.c
new file mode 100644
index 000000000000..aa8a7625d139
--- /dev/null
+++ b/test/builtins/Unit/divxc3_test.c
@@ -0,0 +1,379 @@
+//===-- divxc3_test.c - Test __divxc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __divxc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#if !_ARCH_PPC
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the quotient of (a + ib) / (c + id)
+
+long double _Complex
+__divxc3(long double __a, long double __b, long double __c, long double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(long double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creall(x)) || isinf(cimagl(x)))
+ return inf;
+ if (isnan(creall(x)) && isnan(cimagl(x)))
+ return NaN;
+ if (isnan(creall(x)))
+ {
+ if (cimagl(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagl(x)))
+ {
+ if (creall(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__divxc3(long double a, long double b, long double c, long double d)
+{
+ long double _Complex r = __divxc3(a, b, c, d);
+// printf("test__divxc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
+// a, b, c, d, creall(r), cimagl(r));
+ long double _Complex dividend;
+ long double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ {
+ long double _Complex z = (a * c + b * d) / (c * c + d * d)
+ + (b * c - a * d) / (c * c + d * d) * _Complex_I;
+ if (cabs((r - z)/r) > 1.e-6)
+ return 1;
+ }
+ break;
+ case inf:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+long double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+#endif
+
+int main()
+{
+#if !_ARCH_PPC
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__divxc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/enable_execute_stack_test.c b/test/builtins/Unit/enable_execute_stack_test.c
new file mode 100644
index 000000000000..c0f67b337939
--- /dev/null
+++ b/test/builtins/Unit/enable_execute_stack_test.c
@@ -0,0 +1,72 @@
+//===-- enable_execute_stack_test.c - Test __enable_execute_stack ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#if defined(_WIN32)
+#include <windows.h>
+void __clear_cache(void* start, void* end)
+{
+ if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
+ exit(1);
+}
+void __enable_execute_stack(void *addr)
+{
+ MEMORY_BASIC_INFORMATION b;
+
+ if (!VirtualQuery(addr, &b, sizeof(b)))
+ exit(1);
+ if (!VirtualProtect(b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, &b.Protect))
+ exit(1);
+}
+#else
+#include <sys/mman.h>
+extern void __clear_cache(void* start, void* end);
+extern void __enable_execute_stack(void* addr);
+#endif
+
+typedef int (*pfunc)(void);
+
+int func1()
+{
+ return 1;
+}
+
+int func2()
+{
+ return 2;
+}
+
+
+
+
+int main()
+{
+ unsigned char execution_buffer[128];
+ // mark stack page containing execution_buffer to be executable
+ __enable_execute_stack(execution_buffer);
+
+ // verify you can copy and execute a function
+ memcpy(execution_buffer, (void *)(uintptr_t)&func1, 128);
+ __clear_cache(execution_buffer, &execution_buffer[128]);
+ pfunc f1 = (pfunc)(uintptr_t)execution_buffer;
+ if ((*f1)() != 1)
+ return 1;
+
+ // verify you can overwrite a function with another
+ memcpy(execution_buffer, (void *)(uintptr_t)&func2, 128);
+ __clear_cache(execution_buffer, &execution_buffer[128]);
+ pfunc f2 = (pfunc)(uintptr_t)execution_buffer;
+ if ((*f2)() != 2)
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/endianness.h b/test/builtins/Unit/endianness.h
new file mode 100644
index 000000000000..06c53de0bfa9
--- /dev/null
+++ b/test/builtins/Unit/endianness.h
@@ -0,0 +1,109 @@
+/* ===-- endianness.h - configuration header for libgcc replacement --------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ *
+ * This file is a configuration header for libgcc replacement.
+ * This file is not part of the interface of this library.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#ifndef ENDIANNESS_H
+#define ENDIANNESS_H
+
+/*
+ * Known limitations:
+ * Middle endian systems are not handled currently.
+ */
+
+#if defined(__SVR4) && defined(__sun)
+#include <sys/byteorder.h>
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 0
+#define _YUGA_BIG_ENDIAN 1
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 1
+#define _YUGA_BIG_ENDIAN 0
+#endif /* _BYTE_ORDER */
+
+#endif /* Solaris and AuroraUX. */
+
+/* .. */
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonflyBSD__) || defined(__minix)
+#include <sys/endian.h>
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 0
+#define _YUGA_BIG_ENDIAN 1
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 1
+#define _YUGA_BIG_ENDIAN 0
+#endif /* _BYTE_ORDER */
+
+#endif /* *BSD */
+
+/* .. */
+
+#if defined(__OpenBSD__) || defined(__Bitrig__)
+#include <machine/endian.h>
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 0
+#define _YUGA_BIG_ENDIAN 1
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 1
+#define _YUGA_BIG_ENDIAN 0
+#endif /* _BYTE_ORDER */
+
+#endif /* OpenBSD and Bitrig. */
+
+/* .. */
+
+/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
+#if defined(__APPLE__) && defined(__MACH__) || defined(__ellcc__ )
+
+#ifdef __BIG_ENDIAN__
+#if __BIG_ENDIAN__
+#define _YUGA_LITTLE_ENDIAN 0
+#define _YUGA_BIG_ENDIAN 1
+#endif
+#endif /* __BIG_ENDIAN__ */
+
+#ifdef __LITTLE_ENDIAN__
+#if __LITTLE_ENDIAN__
+#define _YUGA_LITTLE_ENDIAN 1
+#define _YUGA_BIG_ENDIAN 0
+#endif
+#endif /* __LITTLE_ENDIAN__ */
+
+#endif /* Mac OSX */
+
+/* .. */
+
+#if defined(__linux__)
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 0
+#define _YUGA_BIG_ENDIAN 1
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define _YUGA_LITTLE_ENDIAN 1
+#define _YUGA_BIG_ENDIAN 0
+#endif /* __BYTE_ORDER */
+
+#endif /* GNU/Linux */
+
+/* . */
+
+#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
+#error Unable to determine endian
+#endif /* Check we found an endianness correctly. */
+
+#endif /* ENDIANNESS_H */
diff --git a/test/builtins/Unit/eqdf2vfp_test.c b/test/builtins/Unit/eqdf2vfp_test.c
new file mode 100644
index 000000000000..585bd08e9789
--- /dev/null
+++ b/test/builtins/Unit/eqdf2vfp_test.c
@@ -0,0 +1,55 @@
+//===-- eqdf2vfp_test.c - Test __eqdf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __eqdf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __eqdf2vfp(double a, double b);
+
+#if __arm__
+int test__eqdf2vfp(double a, double b)
+{
+ int actual = __eqdf2vfp(a, b);
+ int expected = (a == b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __eqdf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__eqdf2vfp(0.0, 0.0))
+ return 1;
+ if (test__eqdf2vfp(1.0, 1.0))
+ return 1;
+ if (test__eqdf2vfp(0.0, 1.0))
+ return 1;
+ if (test__eqdf2vfp(-1.0, -1.0))
+ return 1;
+ if (test__eqdf2vfp(-1.0, 0.0))
+ return 1;
+ if (test__eqdf2vfp(HUGE_VAL, 1.0))
+ return 1;
+ if (test__eqdf2vfp(1.0, HUGE_VAL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/eqsf2vfp_test.c b/test/builtins/Unit/eqsf2vfp_test.c
new file mode 100644
index 000000000000..b0eed9402a37
--- /dev/null
+++ b/test/builtins/Unit/eqsf2vfp_test.c
@@ -0,0 +1,51 @@
+//===-- eqsf2vfp_test.c - Test __eqsf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __eqsf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __eqsf2vfp(float a, float b);
+
+#if __arm__
+int test__eqsf2vfp(float a, float b)
+{
+ int actual = __eqsf2vfp(a, b);
+ int expected = (a == b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __eqsf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__eqsf2vfp(0.0, 0.0))
+ return 1;
+ if (test__eqsf2vfp(1.0, 1.0))
+ return 1;
+ if (test__eqsf2vfp(-1.0, -1.0))
+ return 1;
+ if (test__eqsf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__eqsf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/eqtf2_test.c b/test/builtins/Unit/eqtf2_test.c
new file mode 100644
index 000000000000..038583503ab2
--- /dev/null
+++ b/test/builtins/Unit/eqtf2_test.c
@@ -0,0 +1,89 @@
+//===------------ eqtf2_test.c - Test __eqtf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __eqtf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __eqtf2(long double a, long double b);
+
+int test__eqtf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __eqtf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__eqtf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__eqtf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // <
+ // exp
+ if (test__eqtf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // mantissa
+ if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // sign
+ if (test__eqtf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // ==
+ if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ NEQUAL_0))
+ return 1;
+ // mantissa
+ if (test__eqtf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // sign
+ if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/extebdsfdf2vfp_test.c b/test/builtins/Unit/extebdsfdf2vfp_test.c
new file mode 100644
index 000000000000..3a009cf2d7f8
--- /dev/null
+++ b/test/builtins/Unit/extebdsfdf2vfp_test.c
@@ -0,0 +1,48 @@
+//===-- extendsfdf2vfp_test.c - Test __extendsfdf2vfp ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __extendsfdf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern double __extendsfdf2vfp(float a);
+
+#if __arm__
+int test__extendsfdf2vfp(float a)
+{
+ double actual = __extendsfdf2vfp(a);
+ double expected = a;
+ if (actual != expected)
+ printf("error in test__extendsfdf2vfp(%f) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__extendsfdf2vfp(0.0))
+ return 1;
+ if (test__extendsfdf2vfp(1.0))
+ return 1;
+ if (test__extendsfdf2vfp(-1.0))
+ return 1;
+ if (test__extendsfdf2vfp(3.1415926535))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/extenddftf2_test.c b/test/builtins/Unit/extenddftf2_test.c
new file mode 100644
index 000000000000..05acc08c0951
--- /dev/null
+++ b/test/builtins/Unit/extenddftf2_test.c
@@ -0,0 +1,82 @@
+//===--------------- extenddftf2_test.c - Test __extenddftf2 --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __extenddftf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+long double __extenddftf2(double a);
+
+int test__extenddftf2(double a, uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __extenddftf2(a);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret){
+ printf("error in test__extenddftf2(%f) = %.20Lf, "
+ "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ // qNaN
+ if (test__extenddftf2(makeQNaN64(),
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // NaN
+ if (test__extenddftf2(makeNaN64(UINT64_C(0x7100000000000)),
+ UINT64_C(0x7fff710000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf
+ if (test__extenddftf2(makeInf64(),
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // zero
+ if (test__extenddftf2(0.0, UINT64_C(0x0), UINT64_C(0x0)))
+ return 1;
+
+ if (test__extenddftf2(0x1.23456789abcdefp+5,
+ UINT64_C(0x400423456789abcd),
+ UINT64_C(0xf000000000000000)))
+ return 1;
+ if (test__extenddftf2(0x1.edcba987654321fp-9,
+ UINT64_C(0x3ff6edcba9876543),
+ UINT64_C(0x2000000000000000)))
+ return 1;
+ if (test__extenddftf2(0x1.23456789abcdefp+45,
+ UINT64_C(0x402c23456789abcd),
+ UINT64_C(0xf000000000000000)))
+ return 1;
+ if (test__extenddftf2(0x1.edcba987654321fp-45,
+ UINT64_C(0x3fd2edcba9876543),
+ UINT64_C(0x2000000000000000)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/extendsftf2_test.c b/test/builtins/Unit/extendsftf2_test.c
new file mode 100644
index 000000000000..5f41928b862f
--- /dev/null
+++ b/test/builtins/Unit/extendsftf2_test.c
@@ -0,0 +1,83 @@
+//===--------------- extendsftf2_test.c - Test __extendsftf2 --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __extendsftf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+long double __extendsftf2(float a);
+
+int test__extendsftf2(float a, uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __extendsftf2(a);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret)
+ {
+ printf("error in test__extendsftf2(%f) = %.20Lf, "
+ "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ // qNaN
+ if (test__extendsftf2(makeQNaN32(),
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // NaN
+ if (test__extendsftf2(makeNaN32(UINT32_C(0x410000)),
+ UINT64_C(0x7fff820000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf
+ if (test__extendsftf2(makeInf32(),
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // zero
+ if (test__extendsftf2(0.0f, UINT64_C(0x0), UINT64_C(0x0)))
+ return 1;
+
+ if (test__extendsftf2(0x1.23456p+5f,
+ UINT64_C(0x4004234560000000),
+ UINT64_C(0x0)))
+ return 1;
+ if (test__extendsftf2(0x1.edcbap-9f,
+ UINT64_C(0x3ff6edcba0000000),
+ UINT64_C(0x0)))
+ return 1;
+ if (test__extendsftf2(0x1.23456p+45f,
+ UINT64_C(0x402c234560000000),
+ UINT64_C(0x0)))
+ return 1;
+ if (test__extendsftf2(0x1.edcbap-45f,
+ UINT64_C(0x3fd2edcba0000000),
+ UINT64_C(0x0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ffsdi2_test.c b/test/builtins/Unit/ffsdi2_test.c
new file mode 100644
index 000000000000..9041127d1a62
--- /dev/null
+++ b/test/builtins/Unit/ffsdi2_test.c
@@ -0,0 +1,66 @@
+//===-- ffsdi2_test.c - Test __ffsdi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ffsdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// 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.
+
+si_int __ffsdi2(di_int a);
+
+int test__ffsdi2(di_int a, si_int expected)
+{
+ si_int x = __ffsdi2(a);
+ if (x != expected)
+ printf("error in __ffsdi2(0x%llX) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__ffsdi2(0x00000000, 0))
+ return 1;
+ if (test__ffsdi2(0x00000001, 1))
+ return 1;
+ if (test__ffsdi2(0x00000002, 2))
+ return 1;
+ if (test__ffsdi2(0x00000003, 1))
+ return 1;
+ if (test__ffsdi2(0x00000004, 3))
+ return 1;
+ if (test__ffsdi2(0x00000005, 1))
+ return 1;
+ if (test__ffsdi2(0x0000000A, 2))
+ return 1;
+ if (test__ffsdi2(0x10000000, 29))
+ return 1;
+ if (test__ffsdi2(0x20000000, 30))
+ return 1;
+ if (test__ffsdi2(0x60000000, 30))
+ return 1;
+ if (test__ffsdi2(0x80000000uLL, 32))
+ return 1;
+ if (test__ffsdi2(0x0000050000000000uLL, 41))
+ return 1;
+ if (test__ffsdi2(0x0200080000000000uLL, 44))
+ return 1;
+ if (test__ffsdi2(0x7200000000000000uLL, 58))
+ return 1;
+ if (test__ffsdi2(0x8000000000000000uLL, 64))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/ffsti2_test.c b/test/builtins/Unit/ffsti2_test.c
new file mode 100644
index 000000000000..f944ed0a1e45
--- /dev/null
+++ b/test/builtins/Unit/ffsti2_test.c
@@ -0,0 +1,83 @@
+//===-- ffsti2_test.c - Test __ffsti2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ffsti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// 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.
+
+si_int __ffsti2(ti_int a);
+
+int test__ffsti2(ti_int a, si_int expected)
+{
+ si_int x = __ffsti2(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __ffsti2(0x%llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__ffsti2(0x00000000, 0))
+ return 1;
+ if (test__ffsti2(0x00000001, 1))
+ return 1;
+ if (test__ffsti2(0x00000002, 2))
+ return 1;
+ if (test__ffsti2(0x00000003, 1))
+ return 1;
+ if (test__ffsti2(0x00000004, 3))
+ return 1;
+ if (test__ffsti2(0x00000005, 1))
+ return 1;
+ if (test__ffsti2(0x0000000A, 2))
+ return 1;
+ if (test__ffsti2(0x10000000, 29))
+ return 1;
+ if (test__ffsti2(0x20000000, 30))
+ return 1;
+ if (test__ffsti2(0x60000000, 30))
+ return 1;
+ if (test__ffsti2(0x80000000uLL, 32))
+ return 1;
+ if (test__ffsti2(0x0000050000000000uLL, 41))
+ return 1;
+ if (test__ffsti2(0x0200080000000000uLL, 44))
+ return 1;
+ if (test__ffsti2(0x7200000000000000uLL, 58))
+ return 1;
+ if (test__ffsti2(0x8000000000000000uLL, 64))
+ return 1;
+ if (test__ffsti2(make_ti(0x8000000800000000uLL, 0), 100))
+ return 1;
+ if (test__ffsti2(make_ti(0x8000000000000000uLL, 0), 128))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixdfdi_test.c b/test/builtins/Unit/fixdfdi_test.c
new file mode 100644
index 000000000000..d08afe3a5336
--- /dev/null
+++ b/test/builtins/Unit/fixdfdi_test.c
@@ -0,0 +1,94 @@
+//===-- fixdfdi_test.c - Test __fixdfdi -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixdfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// su_int is a 32 bit integral type
+// value in double is representable in di_int (no range checking performed)
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+di_int __fixdfdi(double a);
+
+int test__fixdfdi(double a, di_int expected)
+{
+ di_int x = __fixdfdi(a);
+ if (x != expected)
+ printf("error in __fixdfdi(%A) = %llX, expected %llX\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+int main()
+{
+ if (test__fixdfdi(0.0, 0))
+ return 1;
+
+ if (test__fixdfdi(0.5, 0))
+ return 1;
+ if (test__fixdfdi(0.99, 0))
+ return 1;
+ if (test__fixdfdi(1.0, 1))
+ return 1;
+ if (test__fixdfdi(1.5, 1))
+ return 1;
+ if (test__fixdfdi(1.99, 1))
+ return 1;
+ if (test__fixdfdi(2.0, 2))
+ return 1;
+ if (test__fixdfdi(2.01, 2))
+ return 1;
+ if (test__fixdfdi(-0.5, 0))
+ return 1;
+ if (test__fixdfdi(-0.99, 0))
+ return 1;
+ if (test__fixdfdi(-1.0, -1))
+ return 1;
+ if (test__fixdfdi(-1.5, -1))
+ return 1;
+ if (test__fixdfdi(-1.99, -1))
+ return 1;
+ if (test__fixdfdi(-2.0, -2))
+ return 1;
+ if (test__fixdfdi(-2.01, -2))
+ return 1;
+
+ if (test__fixdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixdfdi(-0x1.FFFFFEp+62, 0x8000008000000000LL))
+ return 1;
+ if (test__fixdfdi(-0x1.FFFFFCp+62, 0x8000010000000000LL))
+ return 1;
+
+ if (test__fixdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixdfdi(-0x1.FFFFFFFFFFFFFp+62, 0x8000000000000400LL))
+ return 1;
+ if (test__fixdfdi(-0x1.FFFFFFFFFFFFEp+62, 0x8000000000000800LL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixdfsivfp_test.c b/test/builtins/Unit/fixdfsivfp_test.c
new file mode 100644
index 000000000000..c6102e274ee5
--- /dev/null
+++ b/test/builtins/Unit/fixdfsivfp_test.c
@@ -0,0 +1,50 @@
+//===-- fixdfsivfp_test.c - Test __fixdfsivfp -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixdfsivfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern int __fixdfsivfp(double a);
+
+#if __arm__
+int test__fixdfsivfp(double a)
+{
+ int actual = __fixdfsivfp(a);
+ int expected = a;
+ if (actual != expected)
+ printf("error in test__fixdfsivfp(%f) = %d, expected %d\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__fixdfsivfp(0.0))
+ return 1;
+ if (test__fixdfsivfp(1.0))
+ return 1;
+ if (test__fixdfsivfp(-1.0))
+ return 1;
+ if (test__fixdfsivfp(2147483647))
+ return 1;
+ if (test__fixdfsivfp(-2147483648.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixdfti_test.c b/test/builtins/Unit/fixdfti_test.c
new file mode 100644
index 000000000000..bfa88fd70e14
--- /dev/null
+++ b/test/builtins/Unit/fixdfti_test.c
@@ -0,0 +1,123 @@
+//===-- fixdfti_test.c - Test __fixdfti -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixdfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// su_int is a 32 bit integral type
+// value in double is representable in ti_int (no range checking performed)
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+ti_int __fixdfti(double a);
+
+int test__fixdfti(double a, ti_int expected)
+{
+ ti_int x = __fixdfti(a);
+ if (x != expected)
+ {
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixdfti(%A) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixdfti(0.0, 0))
+ return 1;
+
+ if (test__fixdfti(0.5, 0))
+ return 1;
+ if (test__fixdfti(0.99, 0))
+ return 1;
+ if (test__fixdfti(1.0, 1))
+ return 1;
+ if (test__fixdfti(1.5, 1))
+ return 1;
+ if (test__fixdfti(1.99, 1))
+ return 1;
+ if (test__fixdfti(2.0, 2))
+ return 1;
+ if (test__fixdfti(2.01, 2))
+ return 1;
+ if (test__fixdfti(-0.5, 0))
+ return 1;
+ if (test__fixdfti(-0.99, 0))
+ return 1;
+ if (test__fixdfti(-1.0, -1))
+ return 1;
+ if (test__fixdfti(-1.5, -1))
+ return 1;
+ if (test__fixdfti(-1.99, -1))
+ return 1;
+ if (test__fixdfti(-2.0, -2))
+ return 1;
+ if (test__fixdfti(-2.01, -2))
+ return 1;
+
+ if (test__fixdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixdfti(-0x1.FFFFFEp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000008000000000LL)))
+ return 1;
+ if (test__fixdfti(-0x1.FFFFFCp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000010000000000LL)))
+ return 1;
+
+ if (test__fixdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixdfti(-0x1.FFFFFFFFFFFFFp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000400LL)))
+ return 1;
+ if (test__fixdfti(-0x1.FFFFFFFFFFFFEp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000800LL)))
+ return 1;
+
+ if (test__fixdfti(0x1.FFFFFFFFFFFFFp+126, make_ti(0x7FFFFFFFFFFFFC00LL, 0)))
+ return 1;
+ if (test__fixdfti(0x1.FFFFFFFFFFFFEp+126, make_ti(0x7FFFFFFFFFFFF800LL, 0)))
+ return 1;
+
+ if (test__fixdfti(-0x1.FFFFFFFFFFFFFp+126, make_ti(0x8000000000000400LL, 0)))
+ return 1;
+ if (test__fixdfti(-0x1.FFFFFFFFFFFFEp+126, make_ti(0x8000000000000800LL, 0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixsfdi_test.c b/test/builtins/Unit/fixsfdi_test.c
new file mode 100644
index 000000000000..d3e934a5c02a
--- /dev/null
+++ b/test/builtins/Unit/fixsfdi_test.c
@@ -0,0 +1,84 @@
+//===-- fixsfdi_test.c - Test __fixsfdi -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixsfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// su_int is a 32 bit integral type
+// value in float is representable in di_int (no range checking performed)
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+di_int __fixsfdi(float a);
+
+int test__fixsfdi(float a, di_int expected)
+{
+ di_int x = __fixsfdi(a);
+ if (x != expected)
+ printf("error in __fixsfdi(%A) = %llX, expected %llX\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__fixsfdi(0.0F, 0))
+ return 1;
+
+ if (test__fixsfdi(0.5F, 0))
+ return 1;
+ if (test__fixsfdi(0.99F, 0))
+ return 1;
+ if (test__fixsfdi(1.0F, 1))
+ return 1;
+ if (test__fixsfdi(1.5F, 1))
+ return 1;
+ if (test__fixsfdi(1.99F, 1))
+ return 1;
+ if (test__fixsfdi(2.0F, 2))
+ return 1;
+ if (test__fixsfdi(2.01F, 2))
+ return 1;
+ if (test__fixsfdi(-0.5F, 0))
+ return 1;
+ if (test__fixsfdi(-0.99F, 0))
+ return 1;
+ if (test__fixsfdi(-1.0F, -1))
+ return 1;
+ if (test__fixsfdi(-1.5F, -1))
+ return 1;
+ if (test__fixsfdi(-1.99F, -1))
+ return 1;
+ if (test__fixsfdi(-2.0F, -2))
+ return 1;
+ if (test__fixsfdi(-2.01F, -2))
+ return 1;
+
+ if (test__fixsfdi(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixsfdi(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixsfdi(-0x1.FFFFFEp+62F, 0x8000008000000000LL))
+ return 1;
+ if (test__fixsfdi(-0x1.FFFFFCp+62F, 0x8000010000000000LL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixsfsivfp_test.c b/test/builtins/Unit/fixsfsivfp_test.c
new file mode 100644
index 000000000000..9abf5e856476
--- /dev/null
+++ b/test/builtins/Unit/fixsfsivfp_test.c
@@ -0,0 +1,52 @@
+//===-- fixsfsivfp_test.c - Test __fixsfsivfp -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixsfsivfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern int __fixsfsivfp(float a);
+
+#if __arm__
+int test__fixsfsivfp(float a)
+{
+ int actual = __fixsfsivfp(a);
+ int expected = a;
+ if (actual != expected)
+ printf("error in test__fixsfsivfp(%f) = %u, expected %u\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__fixsfsivfp(0.0))
+ return 1;
+ if (test__fixsfsivfp(1.0))
+ return 1;
+ if (test__fixsfsivfp(-1.0))
+ return 1;
+ if (test__fixsfsivfp(2147483647.0))
+ return 1;
+ if (test__fixsfsivfp(-2147483648.0))
+ return 1;
+ if (test__fixsfsivfp(65536.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixsfti_test.c b/test/builtins/Unit/fixsfti_test.c
new file mode 100644
index 000000000000..2b0b99774819
--- /dev/null
+++ b/test/builtins/Unit/fixsfti_test.c
@@ -0,0 +1,111 @@
+//===-- fixsfti_test.c - Test __fixsfti -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixsfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// su_int is a 32 bit integral type
+// value in float is representable in ti_int (no range checking performed)
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+ti_int __fixsfti(float a);
+
+int test__fixsfti(float a, ti_int expected)
+{
+ ti_int x = __fixsfti(a);
+ if (x != expected)
+ {
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixsfti(%A) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixsfti(0.0F, 0))
+ return 1;
+
+ if (test__fixsfti(0.5F, 0))
+ return 1;
+ if (test__fixsfti(0.99F, 0))
+ return 1;
+ if (test__fixsfti(1.0F, 1))
+ return 1;
+ if (test__fixsfti(1.5F, 1))
+ return 1;
+ if (test__fixsfti(1.99F, 1))
+ return 1;
+ if (test__fixsfti(2.0F, 2))
+ return 1;
+ if (test__fixsfti(2.01F, 2))
+ return 1;
+ if (test__fixsfti(-0.5F, 0))
+ return 1;
+ if (test__fixsfti(-0.99F, 0))
+ return 1;
+ if (test__fixsfti(-1.0F, -1))
+ return 1;
+ if (test__fixsfti(-1.5F, -1))
+ return 1;
+ if (test__fixsfti(-1.99F, -1))
+ return 1;
+ if (test__fixsfti(-2.0F, -2))
+ return 1;
+ if (test__fixsfti(-2.01F, -2))
+ return 1;
+
+ if (test__fixsfti(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixsfti(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixsfti(-0x1.FFFFFEp+62F, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000008000000000LL)))
+ return 1;
+ if (test__fixsfti(-0x1.FFFFFCp+62F, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000010000000000LL)))
+ return 1;
+
+ if (test__fixsfti(0x1.FFFFFEp+126F, make_ti(0x7FFFFF8000000000LL, 0)))
+ return 1;
+ if (test__fixsfti(0x1.FFFFFCp+126F, make_ti(0x7FFFFF0000000000LL, 0)))
+ return 1;
+
+ if (test__fixsfti(-0x1.FFFFFEp+126F, make_ti(0x8000008000000000LL, 0)))
+ return 1;
+ if (test__fixsfti(-0x1.FFFFFCp+126F, make_ti(0x8000010000000000LL, 0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsdfdi_test.c b/test/builtins/Unit/fixunsdfdi_test.c
new file mode 100644
index 000000000000..0803fd28f5bb
--- /dev/null
+++ b/test/builtins/Unit/fixunsdfdi_test.c
@@ -0,0 +1,106 @@
+//===-- fixunsdfdi_test.c - Test __fixunsdfdi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsdfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// du_int is a 64 bit integral type
+// value in double is representable in du_int or is negative
+// (no range checking performed)
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+du_int __fixunsdfdi(double a);
+
+int test__fixunsdfdi(double a, du_int expected)
+{
+ du_int x = __fixunsdfdi(a);
+ if (x != expected)
+ printf("error in __fixunsdfdi(%A) = %llX, expected %llX\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(su_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+int main()
+{
+ if (test__fixunsdfdi(0.0, 0))
+ return 1;
+
+ if (test__fixunsdfdi(0.5, 0))
+ return 1;
+ if (test__fixunsdfdi(0.99, 0))
+ return 1;
+ if (test__fixunsdfdi(1.0, 1))
+ return 1;
+ if (test__fixunsdfdi(1.5, 1))
+ return 1;
+ if (test__fixunsdfdi(1.99, 1))
+ return 1;
+ if (test__fixunsdfdi(2.0, 2))
+ return 1;
+ if (test__fixunsdfdi(2.01, 2))
+ return 1;
+ if (test__fixunsdfdi(-0.5, 0))
+ return 1;
+ if (test__fixunsdfdi(-0.99, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunsdfdi(-1.0, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunsdfdi(-1.5, 0))
+ return 1;
+ if (test__fixunsdfdi(-1.99, 0))
+ return 1;
+ if (test__fixunsdfdi(-2.0, 0))
+ return 1;
+ if (test__fixunsdfdi(-2.01, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunsdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsdfdi(-0x1.FFFFFEp+62, 0))
+ return 1;
+ if (test__fixunsdfdi(-0x1.FFFFFCp+62, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800LL))
+ return 1;
+ if (test__fixunsdfdi(0x1.0000000000000p+63, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixunsdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsdfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
+ return 1;
+ if (test__fixunsdfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsdfsi_test.c b/test/builtins/Unit/fixunsdfsi_test.c
new file mode 100644
index 000000000000..54fe35b5c35a
--- /dev/null
+++ b/test/builtins/Unit/fixunsdfsi_test.c
@@ -0,0 +1,100 @@
+//===-- fixunsdfsi_test.c - Test __fixunsdfsi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsdfsi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned int, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// su_int is a 32 bit integral type
+// value in double is representable in su_int or is negative
+// (no range checking performed)
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+su_int __fixunsdfsi(double a);
+
+int test__fixunsdfsi(double a, su_int expected)
+{
+ su_int x = __fixunsdfsi(a);
+ if (x != expected)
+ printf("error in __fixunsdfsi(%A) = %X, expected %X\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+int main()
+{
+ if (test__fixunsdfsi(0.0, 0))
+ return 1;
+
+ if (test__fixunsdfsi(0.5, 0))
+ return 1;
+ if (test__fixunsdfsi(0.99, 0))
+ return 1;
+ if (test__fixunsdfsi(1.0, 1))
+ return 1;
+ if (test__fixunsdfsi(1.5, 1))
+ return 1;
+ if (test__fixunsdfsi(1.99, 1))
+ return 1;
+ if (test__fixunsdfsi(2.0, 2))
+ return 1;
+ if (test__fixunsdfsi(2.01, 2))
+ return 1;
+ if (test__fixunsdfsi(-0.5, 0))
+ return 1;
+ if (test__fixunsdfsi(-0.99, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunsdfsi(-1.0, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunsdfsi(-1.5, 0))
+ return 1;
+ if (test__fixunsdfsi(-1.99, 0))
+ return 1;
+ if (test__fixunsdfsi(-2.0, 0))
+ return 1;
+ if (test__fixunsdfsi(-2.01, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfsi(0x1.000000p+31, 0x80000000))
+ return 1;
+ if (test__fixunsdfsi(0x1.FFFFFEp+31, 0xFFFFFF00))
+ return 1;
+ if (test__fixunsdfsi(0x1.FFFFFEp+30, 0x7FFFFF80))
+ return 1;
+ if (test__fixunsdfsi(0x1.FFFFFCp+30, 0x7FFFFF00))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsdfsi(-0x1.FFFFFEp+30, 0))
+ return 1;
+ if (test__fixunsdfsi(-0x1.FFFFFCp+30, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfsi(0x1.FFFFFFFEp+31, 0xFFFFFFFF))
+ return 1;
+ if (test__fixunsdfsi(0x1.FFFFFFFC00000p+30, 0x7FFFFFFF))
+ return 1;
+ if (test__fixunsdfsi(0x1.FFFFFFF800000p+30, 0x7FFFFFFE))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsdfsivfp_test.c b/test/builtins/Unit/fixunsdfsivfp_test.c
new file mode 100644
index 000000000000..3727cf7b02fb
--- /dev/null
+++ b/test/builtins/Unit/fixunsdfsivfp_test.c
@@ -0,0 +1,50 @@
+//===-- fixunsdfsivfp_test.c - Test __fixunsdfsivfp -----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsdfsivfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern unsigned int __fixunsdfsivfp(double a);
+
+#if __arm__
+int test__fixunsdfsivfp(double a)
+{
+ unsigned int actual = __fixunsdfsivfp(a);
+ unsigned int expected = a;
+ if (actual != expected)
+ printf("error in test__fixunsdfsivfp(%f) = %u, expected %u\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__fixunsdfsivfp(0.0))
+ return 1;
+ if (test__fixunsdfsivfp(1.0))
+ return 1;
+ if (test__fixunsdfsivfp(-1.0))
+ return 1;
+ if (test__fixunsdfsivfp(4294967295.0))
+ return 1;
+ if (test__fixunsdfsivfp(65536.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsdfti_test.c b/test/builtins/Unit/fixunsdfti_test.c
new file mode 100644
index 000000000000..9f89de493680
--- /dev/null
+++ b/test/builtins/Unit/fixunsdfti_test.c
@@ -0,0 +1,128 @@
+//===-- fixunsdfti_test.c - Test __fixunsdfti -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsdfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// tu_int is a 64 bit integral type
+// value in double is representable in tu_int or is negative
+// (no range checking performed)
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+#ifdef CRT_HAS_128BIT
+
+tu_int __fixunsdfti(double a);
+
+int test__fixunsdfti(double a, tu_int expected)
+{
+ tu_int x = __fixunsdfti(a);
+ if (x != expected)
+ {
+ utwords xt;
+ xt.all = x;
+ utwords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixunsdfti(%A) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixunsdfti(0.0, 0))
+ return 1;
+
+ if (test__fixunsdfti(0.5, 0))
+ return 1;
+ if (test__fixunsdfti(0.99, 0))
+ return 1;
+ if (test__fixunsdfti(1.0, 1))
+ return 1;
+ if (test__fixunsdfti(1.5, 1))
+ return 1;
+ if (test__fixunsdfti(1.99, 1))
+ return 1;
+ if (test__fixunsdfti(2.0, 2))
+ return 1;
+ if (test__fixunsdfti(2.01, 2))
+ return 1;
+ if (test__fixunsdfti(-0.5, 0))
+ return 1;
+ if (test__fixunsdfti(-0.99, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunsdfti(-1.0, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunsdfti(-1.5, 0))
+ return 1;
+ if (test__fixunsdfti(-1.99, 0))
+ return 1;
+ if (test__fixunsdfti(-2.0, 0))
+ return 1;
+ if (test__fixunsdfti(-2.01, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunsdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsdfti(-0x1.FFFFFEp+62, 0))
+ return 1;
+ if (test__fixunsdfti(-0x1.FFFFFCp+62, 0))
+ return 1;
+#endif
+
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800LL))
+ return 1;
+ if (test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, make_ti(0xFFFFFFFFFFFFF800LL, 0)))
+ return 1;
+ if (test__fixunsdfti(0x1.0000000000000p+127, make_ti(0x8000000000000000LL, 0)))
+ return 1;
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+126, make_ti(0x7FFFFFFFFFFFFC00LL, 0)))
+ return 1;
+ if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+126, make_ti(0x7FFFFFFFFFFFF800LL, 0)))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsdfti(-0x1.FFFFFFFFFFFFFp+62, 0))
+ return 1;
+ if (test__fixunsdfti(-0x1.FFFFFFFFFFFFEp+62, 0))
+ return 1;
+#endif
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunssfdi_test.c b/test/builtins/Unit/fixunssfdi_test.c
new file mode 100644
index 000000000000..ac89be7bbb27
--- /dev/null
+++ b/test/builtins/Unit/fixunssfdi_test.c
@@ -0,0 +1,95 @@
+//===-- fixunssfdi_test.c - Test __fixunssfdi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunssfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// du_int is a 64 bit integral type
+// value in float is representable in du_int or is negative
+// (no range checking performed)
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+du_int __fixunssfdi(float a);
+
+int test__fixunssfdi(float a, du_int expected)
+{
+ du_int x = __fixunssfdi(a);
+ if (x != expected)
+ printf("error in __fixunssfdi(%A) = %llX, expected %llX\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__fixunssfdi(0.0F, 0))
+ return 1;
+
+ if (test__fixunssfdi(0.5F, 0))
+ return 1;
+ if (test__fixunssfdi(0.99F, 0))
+ return 1;
+ if (test__fixunssfdi(1.0F, 1))
+ return 1;
+ if (test__fixunssfdi(1.5F, 1))
+ return 1;
+ if (test__fixunssfdi(1.99F, 1))
+ return 1;
+ if (test__fixunssfdi(2.0F, 2))
+ return 1;
+ if (test__fixunssfdi(2.01F, 2))
+ return 1;
+ if (test__fixunssfdi(-0.5F, 0))
+ return 1;
+ if (test__fixunssfdi(-0.99F, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunssfdi(-1.0F, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunssfdi(-1.5F, 0))
+ return 1;
+ if (test__fixunssfdi(-1.99F, 0))
+ return 1;
+ if (test__fixunssfdi(-2.0F, 0))
+ return 1;
+ if (test__fixunssfdi(-2.01F, 0))
+ return 1;
+#endif
+
+ if (test__fixunssfdi(0x1.FFFFFEp+63F, 0xFFFFFF0000000000LL))
+ return 1;
+ if (test__fixunssfdi(0x1.000000p+63F, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunssfdi(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunssfdi(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunssfdi(-0x1.FFFFFEp+62F, 0x0000000000000000LL))
+ return 1;
+ if (test__fixunssfdi(-0x1.FFFFFCp+62F, 0x0000000000000000LL))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunssfsi_test.c b/test/builtins/Unit/fixunssfsi_test.c
new file mode 100644
index 000000000000..ce6a9287515f
--- /dev/null
+++ b/test/builtins/Unit/fixunssfsi_test.c
@@ -0,0 +1,93 @@
+//===-- fixunssfsi_test.c - Test __fixunssfsi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunssfsi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned int, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// su_int is a 32 bit integral type
+// value in float is representable in su_int or is negative
+// (no range checking performed)
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+su_int __fixunssfsi(float a);
+
+int test__fixunssfsi(float a, su_int expected)
+{
+ su_int x = __fixunssfsi(a);
+ if (x != expected)
+ printf("error in __fixunssfsi(%A) = %X, expected %X\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__fixunssfsi(0.0F, 0))
+ return 1;
+
+ if (test__fixunssfsi(0.5F, 0))
+ return 1;
+ if (test__fixunssfsi(0.99F, 0))
+ return 1;
+ if (test__fixunssfsi(1.0F, 1))
+ return 1;
+ if (test__fixunssfsi(1.5F, 1))
+ return 1;
+ if (test__fixunssfsi(1.99F, 1))
+ return 1;
+ if (test__fixunssfsi(2.0F, 2))
+ return 1;
+ if (test__fixunssfsi(2.01F, 2))
+ return 1;
+ if (test__fixunssfsi(-0.5F, 0))
+ return 1;
+ if (test__fixunssfsi(-0.99F, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunssfsi(-1.0F, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunssfsi(-1.5F, 0))
+ return 1;
+ if (test__fixunssfsi(-1.99F, 0))
+ return 1;
+ if (test__fixunssfsi(-2.0F, 0))
+ return 1;
+ if (test__fixunssfsi(-2.01F, 0))
+ return 1;
+#endif
+
+ if (test__fixunssfsi(0x1.000000p+31F, 0x80000000))
+ return 1;
+ if (test__fixunssfsi(0x1.FFFFFEp+31F, 0xFFFFFF00))
+ return 1;
+ if (test__fixunssfsi(0x1.FFFFFEp+30F, 0x7FFFFF80))
+ return 1;
+ if (test__fixunssfsi(0x1.FFFFFCp+30F, 0x7FFFFF00))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunssfsi(-0x1.FFFFFEp+30F, 0))
+ return 1;
+ if (test__fixunssfsi(-0x1.FFFFFCp+30F, 0))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunssfsivfp_test.c b/test/builtins/Unit/fixunssfsivfp_test.c
new file mode 100644
index 000000000000..c8e45f408b63
--- /dev/null
+++ b/test/builtins/Unit/fixunssfsivfp_test.c
@@ -0,0 +1,50 @@
+//===-- fixunssfsivfp_test.c - Test __fixunssfsivfp -----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunssfsivfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern unsigned int __fixunssfsivfp(float a);
+
+#if __arm__
+int test__fixunssfsivfp(float a)
+{
+ unsigned int actual = __fixunssfsivfp(a);
+ unsigned int expected = a;
+ if (actual != expected)
+ printf("error in test__fixunssfsivfp(%f) = %u, expected %u\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__fixunssfsivfp(0.0))
+ return 1;
+ if (test__fixunssfsivfp(1.0))
+ return 1;
+ if (test__fixunssfsivfp(-1.0))
+ return 1;
+ if (test__fixunssfsivfp(4294967295.0))
+ return 1;
+ if (test__fixunssfsivfp(65536.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunssfti_test.c b/test/builtins/Unit/fixunssfti_test.c
new file mode 100644
index 000000000000..7965b9500d05
--- /dev/null
+++ b/test/builtins/Unit/fixunssfti_test.c
@@ -0,0 +1,120 @@
+//===-- fixunssfti_test.c - Test __fixunssfti -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunssfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// tu_int is a 64 bit integral type
+// value in float is representable in tu_int or is negative
+// (no range checking performed)
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+tu_int __fixunssfti(float a);
+
+int test__fixunssfti(float a, tu_int expected)
+{
+ tu_int x = __fixunssfti(a);
+ if (x != expected)
+ {
+ utwords xt;
+ xt.all = x;
+ utwords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixunssfti(%A) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixunssfti(0.0F, 0))
+ return 1;
+
+ if (test__fixunssfti(0.5F, 0))
+ return 1;
+ if (test__fixunssfti(0.99F, 0))
+ return 1;
+ if (test__fixunssfti(1.0F, 1))
+ return 1;
+ if (test__fixunssfti(1.5F, 1))
+ return 1;
+ if (test__fixunssfti(1.99F, 1))
+ return 1;
+ if (test__fixunssfti(2.0F, 2))
+ return 1;
+ if (test__fixunssfti(2.01F, 2))
+ return 1;
+ if (test__fixunssfti(-0.5F, 0))
+ return 1;
+ if (test__fixunssfti(-0.99F, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunssfti(-1.0F, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunssfti(-1.5F, 0))
+ return 1;
+ if (test__fixunssfti(-1.99F, 0))
+ return 1;
+ if (test__fixunssfti(-2.0F, 0))
+ return 1;
+ if (test__fixunssfti(-2.01F, 0))
+ return 1;
+#endif
+
+ if (test__fixunssfti(0x1.FFFFFEp+63F, 0xFFFFFF0000000000LL))
+ return 1;
+ if (test__fixunssfti(0x1.000000p+63F, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunssfti(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunssfti(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixunssfti(0x1.FFFFFEp+127F, make_ti(0xFFFFFF0000000000LL, 0)))
+ return 1;
+ if (test__fixunssfti(0x1.000000p+127F, make_ti(0x8000000000000000LL, 0)))
+ return 1;
+ if (test__fixunssfti(0x1.FFFFFEp+126F, make_ti(0x7FFFFF8000000000LL, 0)))
+ return 1;
+ if (test__fixunssfti(0x1.FFFFFCp+126F, make_ti(0x7FFFFF0000000000LL, 0)))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunssfti(-0x1.FFFFFEp+62F, 0x0000000000000000LL))
+ return 1;
+ if (test__fixunssfti(-0x1.FFFFFCp+62F, 0x0000000000000000LL))
+ return 1;
+ if (test__fixunssfti(-0x1.FFFFFEp+126F, 0x0000000000000000LL))
+ return 1;
+ if (test__fixunssfti(-0x1.FFFFFCp+126F, 0x0000000000000000LL))
+ return 1;
+#endif
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunstfdi_test.c b/test/builtins/Unit/fixunstfdi_test.c
new file mode 100644
index 000000000000..d0a5db7a9c97
--- /dev/null
+++ b/test/builtins/Unit/fixunstfdi_test.c
@@ -0,0 +1,121 @@
+//===-- fixunstfdi_test.c - Test __fixunstfdi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunstfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#if _ARCH_PPC
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: long double is a ppc 128 bit floating point type
+// du_int is a 64 bit integral type
+// value in long double is representable in du_int or is negative
+// (no range checking performed)
+
+du_int __fixunstfdi(long double a);
+
+int test__fixunstfdi(long double a, du_int expected)
+{
+ du_int x = __fixunstfdi(a);
+ if (x != expected)
+ printf("error in __fixunstfdi(%LA) = %llX, expected %llX\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(su_int)] = {0};
+char assumption_2[sizeof(du_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if _ARCH_PPC
+ if (test__fixunstfdi(0.0, 0))
+ return 1;
+
+ if (test__fixunstfdi(0.5, 0))
+ return 1;
+ if (test__fixunstfdi(0.99, 0))
+ return 1;
+ if (test__fixunstfdi(1.0, 1))
+ return 1;
+ if (test__fixunstfdi(1.5, 1))
+ return 1;
+ if (test__fixunstfdi(1.99, 1))
+ return 1;
+ if (test__fixunstfdi(2.0, 2))
+ return 1;
+ if (test__fixunstfdi(2.01, 2))
+ return 1;
+ if (test__fixunstfdi(-0.5, 0))
+ return 1;
+ if (test__fixunstfdi(-0.99, 0))
+ return 1;
+ if (test__fixunstfdi(-1.0, 0))
+ return 1;
+ if (test__fixunstfdi(-1.5, 0))
+ return 1;
+ if (test__fixunstfdi(-1.99, 0))
+ return 1;
+ if (test__fixunstfdi(-2.0, 0))
+ return 1;
+ if (test__fixunstfdi(-2.01, 0))
+ return 1;
+
+ if (test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixunstfdi(-0x1.FFFFFEp+62, 0))
+ return 1;
+ if (test__fixunstfdi(-0x1.FFFFFCp+62, 0))
+ return 1;
+
+ if (test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
+ return 1;
+ if (test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
+ return 1;
+
+ if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunstfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
+ return 1;
+ if (test__fixunstfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+ return 1;
+
+ if (test__fixunstfdi(-0x1.0000000000000000p+63L, 0))
+ return 1;
+ if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
+ return 1;
+ if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsxfdi_test.c b/test/builtins/Unit/fixunsxfdi_test.c
new file mode 100644
index 000000000000..4308f6f4ef1f
--- /dev/null
+++ b/test/builtins/Unit/fixunsxfdi_test.c
@@ -0,0 +1,124 @@
+//===-- fixunsxfdi_test.c - Test __fixunsxfdi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsxfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <limits.h>
+
+
+#if HAS_80_BIT_LONG_DOUBLE
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
+// du_int is a 64 bit integral type
+// value in long double is representable in du_int or is negative
+// (no range checking performed)
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+du_int __fixunsxfdi(long double a);
+
+int test__fixunsxfdi(long double a, du_int expected)
+{
+ du_int x = __fixunsxfdi(a);
+ if (x != expected)
+ printf("error in __fixunsxfdi(%LA) = %llX, expected %llX\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(su_int)] = {0};
+char assumption_2[sizeof(du_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+#endif
+
+int main()
+{
+#if HAS_80_BIT_LONG_DOUBLE
+ if (test__fixunsxfdi(0.0, 0))
+ return 1;
+
+ if (test__fixunsxfdi(0.5, 0))
+ return 1;
+ if (test__fixunsxfdi(0.99, 0))
+ return 1;
+ if (test__fixunsxfdi(1.0, 1))
+ return 1;
+ if (test__fixunsxfdi(1.5, 1))
+ return 1;
+ if (test__fixunsxfdi(1.99, 1))
+ return 1;
+ if (test__fixunsxfdi(2.0, 2))
+ return 1;
+ if (test__fixunsxfdi(2.01, 2))
+ return 1;
+ if (test__fixunsxfdi(-0.5, 0))
+ return 1;
+ if (test__fixunsxfdi(-0.99, 0))
+ return 1;
+ if (test__fixunsxfdi(-1.0, 0))
+ return 1;
+ if (test__fixunsxfdi(-1.5, 0))
+ return 1;
+ if (test__fixunsxfdi(-1.99, 0))
+ return 1;
+ if (test__fixunsxfdi(-2.0, 0))
+ return 1;
+ if (test__fixunsxfdi(-2.01, 0))
+ return 1;
+
+ if (test__fixunsxfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunsxfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixunsxfdi(-0x1.FFFFFEp+62, 0))
+ return 1;
+ if (test__fixunsxfdi(-0x1.FFFFFCp+62, 0))
+ return 1;
+
+ if (test__fixunsxfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixunsxfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixunsxfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
+ return 1;
+ if (test__fixunsxfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
+ return 1;
+
+ if (test__fixunsxfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunsxfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
+ return 1;
+ if (test__fixunsxfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunsxfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunsxfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+ return 1;
+
+ if (test__fixunsxfdi(-0x1.0000000000000000p+63L, 0))
+ return 1;
+ if (test__fixunsxfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
+ return 1;
+ if (test__fixunsxfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsxfsi_test.c b/test/builtins/Unit/fixunsxfsi_test.c
new file mode 100644
index 000000000000..cb2a7f487210
--- /dev/null
+++ b/test/builtins/Unit/fixunsxfsi_test.c
@@ -0,0 +1,105 @@
+//===-- fixunsxfsi_test.c - Test __fixunsxfsi -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsxfsi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#if HAS_80_BIT_LONG_DOUBLE
+// Returns: convert a to a unsigned int, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
+// su_int is a 32 bit integral type
+// value in long double is representable in su_int or is negative
+// (no range checking performed)
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+su_int __fixunsxfsi(long double a);
+
+int test__fixunsxfsi(long double a, su_int expected)
+{
+ su_int x = __fixunsxfsi(a);
+ if (x != expected)
+ printf("error in __fixunsxfsi(%LA) = %X, expected %X\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+#endif
+
+int main()
+{
+#if HAS_80_BIT_LONG_DOUBLE
+ if (test__fixunsxfsi(0.0, 0))
+ return 1;
+
+ if (test__fixunsxfsi(0.5, 0))
+ return 1;
+ if (test__fixunsxfsi(0.99, 0))
+ return 1;
+ if (test__fixunsxfsi(1.0, 1))
+ return 1;
+ if (test__fixunsxfsi(1.5, 1))
+ return 1;
+ if (test__fixunsxfsi(1.99, 1))
+ return 1;
+ if (test__fixunsxfsi(2.0, 2))
+ return 1;
+ if (test__fixunsxfsi(2.01, 2))
+ return 1;
+ if (test__fixunsxfsi(-0.5, 0))
+ return 1;
+ if (test__fixunsxfsi(-0.99, 0))
+ return 1;
+#if !TARGET_LIBGCC
+ if (test__fixunsxfsi(-1.0, 0)) // libgcc ignores "returns 0 for negative input" spec
+ return 1;
+ if (test__fixunsxfsi(-1.5, 0))
+ return 1;
+ if (test__fixunsxfsi(-1.99, 0))
+ return 1;
+ if (test__fixunsxfsi(-2.0, 0))
+ return 1;
+ if (test__fixunsxfsi(-2.01, 0))
+ return 1;
+#endif
+
+ if (test__fixunsxfsi(0x1.000000p+31, 0x80000000))
+ return 1;
+ if (test__fixunsxfsi(0x1.FFFFFEp+31, 0xFFFFFF00))
+ return 1;
+ if (test__fixunsxfsi(0x1.FFFFFEp+30, 0x7FFFFF80))
+ return 1;
+ if (test__fixunsxfsi(0x1.FFFFFCp+30, 0x7FFFFF00))
+ return 1;
+
+#if !TARGET_LIBGCC
+ if (test__fixunsxfsi(-0x1.FFFFFEp+30, 0))
+ return 1;
+ if (test__fixunsxfsi(-0x1.FFFFFCp+30, 0))
+ return 1;
+#endif
+
+ if (test__fixunsxfsi(0x1.FFFFFFFEp+31, 0xFFFFFFFF))
+ return 1;
+ if (test__fixunsxfsi(0x1.FFFFFFFC00000p+30, 0x7FFFFFFF))
+ return 1;
+ if (test__fixunsxfsi(0x1.FFFFFFF800000p+30, 0x7FFFFFFE))
+ return 1;
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixunsxfti_test.c b/test/builtins/Unit/fixunsxfti_test.c
new file mode 100644
index 000000000000..7d18b1267b3a
--- /dev/null
+++ b/test/builtins/Unit/fixunsxfti_test.c
@@ -0,0 +1,141 @@
+//===-- fixunsxfti_test.c - Test __fixunsxfti -----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixunsxfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a unsigned long long, rounding toward zero.
+// Negative values all become zero.
+
+// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
+// tu_int is a 64 bit integral type
+// value in long double is representable in tu_int or is negative
+// (no range checking performed)
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+tu_int __fixunsxfti(long double a);
+
+int test__fixunsxfti(long double a, tu_int expected)
+{
+ tu_int x = __fixunsxfti(a);
+ if (x != expected)
+ {
+ utwords xt;
+ xt.all = x;
+ utwords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixunsxfti(%LA) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixunsxfti(0.0, 0))
+ return 1;
+
+ if (test__fixunsxfti(0.5, 0))
+ return 1;
+ if (test__fixunsxfti(0.99, 0))
+ return 1;
+ if (test__fixunsxfti(1.0, 1))
+ return 1;
+ if (test__fixunsxfti(1.5, 1))
+ return 1;
+ if (test__fixunsxfti(1.99, 1))
+ return 1;
+ if (test__fixunsxfti(2.0, 2))
+ return 1;
+ if (test__fixunsxfti(2.01, 2))
+ return 1;
+ if (test__fixunsxfti(-0.5, 0))
+ return 1;
+ if (test__fixunsxfti(-0.99, 0))
+ return 1;
+ if (test__fixunsxfti(-1.0, 0))
+ return 1;
+ if (test__fixunsxfti(-1.5, 0))
+ return 1;
+ if (test__fixunsxfti(-1.99, 0))
+ return 1;
+ if (test__fixunsxfti(-2.0, 0))
+ return 1;
+ if (test__fixunsxfti(-2.01, 0))
+ return 1;
+
+ if (test__fixunsxfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixunsxfti(-0x1.FFFFFEp+62, 0))
+ return 1;
+ if (test__fixunsxfti(-0x1.FFFFFCp+62, 0))
+ return 1;
+
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixunsxfti(-0x1.FFFFFFFFFFFFFp+62, 0))
+ return 1;
+ if (test__fixunsxfti(-0x1.FFFFFFFFFFFFEp+62, 0))
+ return 1;
+
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunsxfti(0x1.0000000000000002p+63L, 0x8000000000000001LL))
+ return 1;
+ if (test__fixunsxfti(0x1.0000000000000000p+63L, 0x8000000000000000LL))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+ return 1;
+
+ if (test__fixunsxfti(-0x1.0000000000000000p+63L, 0))
+ return 1;
+ if (test__fixunsxfti(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
+ return 1;
+ if (test__fixunsxfti(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
+ return 1;
+
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFFEp+127L, make_ti(0xFFFFFFFFFFFFFFFFLL, 0)))
+ return 1;
+ if (test__fixunsxfti(0x1.0000000000000002p+127L, make_ti(0x8000000000000001LL, 0)))
+ return 1;
+ if (test__fixunsxfti(0x1.0000000000000000p+127L, make_ti(0x8000000000000000LL, 0)))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFFCp+126L, make_ti(0x7FFFFFFFFFFFFFFFLL, 0)))
+ return 1;
+ if (test__fixunsxfti(0x1.FFFFFFFFFFFFFFF8p+126L, make_ti(0x7FFFFFFFFFFFFFFELL, 0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixxfdi_test.c b/test/builtins/Unit/fixxfdi_test.c
new file mode 100644
index 000000000000..43ac0f8aaa3c
--- /dev/null
+++ b/test/builtins/Unit/fixxfdi_test.c
@@ -0,0 +1,115 @@
+//===-- fixxfdi_test.c - Test __fixxfdi -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixxfdi for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+
+#if HAS_80_BIT_LONG_DOUBLE
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
+// su_int is a 32 bit integral type
+// value in long double is representable in di_int (no range checking performed)
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+di_int __fixxfdi(long double a);
+
+int test__fixxfdi(long double a, di_int expected)
+{
+ di_int x = __fixxfdi(a);
+ if (x != expected)
+ printf("error in __fixxfdi(%LA) = %llX, expected %llX\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+#endif
+
+int main()
+{
+#if HAS_80_BIT_LONG_DOUBLE
+ if (test__fixxfdi(0.0, 0))
+ return 1;
+
+ if (test__fixxfdi(0.5, 0))
+ return 1;
+ if (test__fixxfdi(0.99, 0))
+ return 1;
+ if (test__fixxfdi(1.0, 1))
+ return 1;
+ if (test__fixxfdi(1.5, 1))
+ return 1;
+ if (test__fixxfdi(1.99, 1))
+ return 1;
+ if (test__fixxfdi(2.0, 2))
+ return 1;
+ if (test__fixxfdi(2.01, 2))
+ return 1;
+ if (test__fixxfdi(-0.5, 0))
+ return 1;
+ if (test__fixxfdi(-0.99, 0))
+ return 1;
+ if (test__fixxfdi(-1.0, -1))
+ return 1;
+ if (test__fixxfdi(-1.5, -1))
+ return 1;
+ if (test__fixxfdi(-1.99, -1))
+ return 1;
+ if (test__fixxfdi(-2.0, -2))
+ return 1;
+ if (test__fixxfdi(-2.01, -2))
+ return 1;
+
+ if (test__fixxfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixxfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixxfdi(-0x1.FFFFFEp+62, 0x8000008000000000LL))
+ return 1;
+ if (test__fixxfdi(-0x1.FFFFFCp+62, 0x8000010000000000LL))
+ return 1;
+
+ if (test__fixxfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixxfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixxfdi(-0x1.FFFFFFFFFFFFFp+62, 0x8000000000000400LL))
+ return 1;
+ if (test__fixxfdi(-0x1.FFFFFFFFFFFFEp+62, 0x8000000000000800LL))
+ return 1;
+
+ if (test__fixxfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixxfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+ return 1;
+
+ if (test__fixxfdi(-0x1.0000000000000000p+63L, 0x8000000000000000LL))
+ return 1;
+ if (test__fixxfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0x8000000000000001LL))
+ return 1;
+ if (test__fixxfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0x8000000000000002LL))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fixxfti_test.c b/test/builtins/Unit/fixxfti_test.c
new file mode 100644
index 000000000000..87914c5341bd
--- /dev/null
+++ b/test/builtins/Unit/fixxfti_test.c
@@ -0,0 +1,146 @@
+//===-- fixxfti_test.c - Test __fixxfti -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __fixxfti for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a signed long long, rounding toward zero.
+
+// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
+// su_int is a 32 bit integral type
+// value in long double is representable in ti_int (no range checking performed)
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+ti_int __fixxfti(long double a);
+
+int test__fixxfti(long double a, ti_int expected)
+{
+ ti_int x = __fixxfti(a);
+ if (x != expected)
+ {
+ utwords xt;
+ xt.all = x;
+ utwords expectedt;
+ expectedt.all = expected;
+ printf("error in __fixxfti(%LA) = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__fixxfti(0.0, 0))
+ return 1;
+
+ if (test__fixxfti(0.5, 0))
+ return 1;
+ if (test__fixxfti(0.99, 0))
+ return 1;
+ if (test__fixxfti(1.0, 1))
+ return 1;
+ if (test__fixxfti(1.5, 1))
+ return 1;
+ if (test__fixxfti(1.99, 1))
+ return 1;
+ if (test__fixxfti(2.0, 2))
+ return 1;
+ if (test__fixxfti(2.01, 2))
+ return 1;
+ if (test__fixxfti(-0.5, 0))
+ return 1;
+ if (test__fixxfti(-0.99, 0))
+ return 1;
+ if (test__fixxfti(-1.0, -1))
+ return 1;
+ if (test__fixxfti(-1.5, -1))
+ return 1;
+ if (test__fixxfti(-1.99, -1))
+ return 1;
+ if (test__fixxfti(-2.0, -2))
+ return 1;
+ if (test__fixxfti(-2.01, -2))
+ return 1;
+
+ if (test__fixxfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+ return 1;
+ if (test__fixxfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+ return 1;
+
+ if (test__fixxfti(-0x1.FFFFFEp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000008000000000LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFCp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000010000000000LL)))
+ return 1;
+
+ if (test__fixxfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+ return 1;
+ if (test__fixxfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+ return 1;
+
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFFp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000400LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFEp+62, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000800LL)))
+ return 1;
+
+ if (test__fixxfti(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__fixxfti(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+ return 1;
+
+ if (test__fixxfti(-0x1.0000000000000000p+63L, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000000LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFFFFCp+62L, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000001LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFFFF8p+62L, make_ti(0xFFFFFFFFFFFFFFFFLL,
+ 0x8000000000000002LL)))
+ return 1;
+
+ if (test__fixxfti(0x1.FFFFFFFFFFFFFFFEp+126L, make_ti(0x7FFFFFFFFFFFFFFFLL,
+ 0x8000000000000000LL)))
+ return 1;
+ if (test__fixxfti(0x1.FFFFFFFFFFFFFFFCp+126L, make_ti(0x7FFFFFFFFFFFFFFFLL,
+ 0x0000000000000000LL)))
+
+ return 1;
+
+ if (test__fixxfti(-0x1.0000000000000000p+127L, make_ti(0x8000000000000000LL,
+ 0x0000000000000000LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFFFFEp+126L, make_ti(0x8000000000000000LL,
+ 0x8000000000000000LL)))
+ return 1;
+ if (test__fixxfti(-0x1.FFFFFFFFFFFFFFFCp+126L, make_ti(0x8000000000000001LL,
+ 0x0000000000000000LL)))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatdidf_test.c b/test/builtins/Unit/floatdidf_test.c
new file mode 100644
index 000000000000..af3dacd4f38b
--- /dev/null
+++ b/test/builtins/Unit/floatdidf_test.c
@@ -0,0 +1,137 @@
+//===-- floatdidf.c - Test __floatdidf ------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatdidf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+// Returns: convert a to a double, rounding toward even.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// di_int is a 64 bit integral type
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+double __floatdidf(di_int a);
+
+int test__floatdidf(di_int a, double expected)
+{
+ double x = __floatdidf(a);
+ if (x != expected)
+ printf("error in __floatdidf(%llX) = %a, expected %a\n", a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+int main()
+{
+ if (test__floatdidf(0, 0.0))
+ return 1;
+
+ if (test__floatdidf(1, 1.0))
+ return 1;
+ if (test__floatdidf(2, 2.0))
+ return 1;
+ if (test__floatdidf(20, 20.0))
+ return 1;
+ if (test__floatdidf(-1, -1.0))
+ return 1;
+ if (test__floatdidf(-2, -2.0))
+ return 1;
+ if (test__floatdidf(-20, -20.0))
+ return 1;
+
+ if (test__floatdidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatdidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatdidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatdidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatdidf(0x8000008000000000LL, -0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatdidf(0x8000000000000800LL, -0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatdidf(0x8000010000000000LL, -0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatdidf(0x8000000000001000LL, -0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatdidf(0x8000000000000000LL, -0x1.000000p+63))
+ return 1;
+ if (test__floatdidf(0x8000000000000001LL, -0x1.000000p+63))
+ return 1;
+
+ if (test__floatdidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatdidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatdidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatdidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatdidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatdidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/floatdisf_test.c b/test/builtins/Unit/floatdisf_test.c
new file mode 100644
index 000000000000..3e71df7b2228
--- /dev/null
+++ b/test/builtins/Unit/floatdisf_test.c
@@ -0,0 +1,95 @@
+//===-- floatdisf_test.c - Test __floatdisf -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatdisf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+// Returns: convert a to a float, rounding toward even.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// di_int is a 64 bit integral type
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+float __floatdisf(di_int a);
+
+int test__floatdisf(di_int a, float expected)
+{
+ float x = __floatdisf(a);
+ if (x != expected)
+ printf("error in __floatdisf(%llX) = %a, expected %a\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__floatdisf(0, 0.0F))
+ return 1;
+
+ if (test__floatdisf(1, 1.0F))
+ return 1;
+ if (test__floatdisf(2, 2.0F))
+ return 1;
+ if (test__floatdisf(-1, -1.0F))
+ return 1;
+ if (test__floatdisf(-2, -2.0F))
+ return 1;
+
+ if (test__floatdisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floatdisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floatdisf(0x8000008000000000LL, -0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floatdisf(0x8000010000000000LL, -0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floatdisf(0x8000000000000000LL, -0x1.000000p+63F))
+ return 1;
+ if (test__floatdisf(0x8000000000000001LL, -0x1.000000p+63F))
+ return 1;
+
+ if (test__floatdisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatdisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatdisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatdisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/floatdixf_test.c b/test/builtins/Unit/floatdixf_test.c
new file mode 100644
index 000000000000..337666426318
--- /dev/null
+++ b/test/builtins/Unit/floatdixf_test.c
@@ -0,0 +1,144 @@
+//===-- floatdixf_test.c - Test __floatdixf -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatdixf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#if HAS_80_BIT_LONG_DOUBLE
+// Returns: convert a to a long double, rounding toward even.
+
+// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
+// di_int is a 64 bit integral type
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+long double __floatdixf(di_int a);
+
+int test__floatdixf(di_int a, long double expected)
+{
+ long double x = __floatdixf(a);
+ if (x != expected)
+ printf("error in __floatdixf(%llX) = %LA, expected %LA\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+#endif
+
+int main()
+{
+#if HAS_80_BIT_LONG_DOUBLE
+ if (test__floatdixf(0, 0.0))
+ return 1;
+
+ if (test__floatdixf(1, 1.0))
+ return 1;
+ if (test__floatdixf(2, 2.0))
+ return 1;
+ if (test__floatdixf(20, 20.0))
+ return 1;
+ if (test__floatdixf(-1, -1.0))
+ return 1;
+ if (test__floatdixf(-2, -2.0))
+ return 1;
+ if (test__floatdixf(-20, -20.0))
+ return 1;
+
+ if (test__floatdixf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatdixf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatdixf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatdixf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatdixf(0x8000008000000000LL, -0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatdixf(0x8000000000000800LL, -0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatdixf(0x8000010000000000LL, -0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatdixf(0x8000000000001000LL, -0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatdixf(0x8000000000000000LL, -0x1.000000p+63))
+ return 1;
+ if (test__floatdixf(0x8000000000000001LL, -0x1.FFFFFFFFFFFFFFFCp+62L))
+ return 1;
+
+ if (test__floatdixf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatdixf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatdixf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatdixf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatdixf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DA1LL, 0x8.D1E7F43824B684p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DB0LL, 0x8.D1E7f43824B6Cp+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DB8LL, 0x8.D1E7F43824B6Ep+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DB6LL, 0x8.D1E7F43824B6D8p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DBFLL, 0x8.D1E7F43824B6FCp+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DC1LL, 0x8.D1E7F43824B704p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DC7LL, 0x8.D1E7F43824B71Cp+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DC8LL, 0x8.D1E7F43824B72p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DCFLL, 0x8.D1E7F43824B73Cp+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DD0LL, 0x8.D1E7F43824B74p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DD1LL, 0x8.D1E7F43824B744p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DD8LL, 0x8.D1E7F43824B76p+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DDFLL, 0x8.D1E7F43824B77Cp+54L))
+ return 1;
+ if (test__floatdixf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatsidfvfp_test.c b/test/builtins/Unit/floatsidfvfp_test.c
new file mode 100644
index 000000000000..e21ecda59945
--- /dev/null
+++ b/test/builtins/Unit/floatsidfvfp_test.c
@@ -0,0 +1,50 @@
+//===-- floatsidfvfp_test.c - Test __floatsidfvfp -------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatsidfvfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern double __floatsidfvfp(int a);
+
+#if __arm__
+int test__floatsidfvfp(int a)
+{
+ double actual = __floatsidfvfp(a);
+ double expected = a;
+ if (actual != expected)
+ printf("error in test__ floatsidfvfp(%d) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__floatsidfvfp(0))
+ return 1;
+ if (test__floatsidfvfp(1))
+ return 1;
+ if (test__floatsidfvfp(-1))
+ return 1;
+ if (test__floatsidfvfp(0x7FFFFFFF))
+ return 1;
+ if (test__floatsidfvfp(0x80000000))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatsisfvfp_test.c b/test/builtins/Unit/floatsisfvfp_test.c
new file mode 100644
index 000000000000..d20905bd91e3
--- /dev/null
+++ b/test/builtins/Unit/floatsisfvfp_test.c
@@ -0,0 +1,50 @@
+//===-- floatsisfvfp_test.c - Test __floatsisfvfp -------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatsisfvfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __floatsisfvfp(int a);
+
+#if __arm__
+int test__floatsisfvfp(int a)
+{
+ float actual = __floatsisfvfp(a);
+ float expected = a;
+ if (actual != expected)
+ printf("error in test__floatsisfvfp(%d) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__floatsisfvfp(0))
+ return 1;
+ if (test__floatsisfvfp(1))
+ return 1;
+ if (test__floatsisfvfp(-1))
+ return 1;
+ if (test__floatsisfvfp(0x7FFFFFFF))
+ return 1;
+ if (test__floatsisfvfp(0x80000000))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatsitf_test.c b/test/builtins/Unit/floatsitf_test.c
new file mode 100644
index 000000000000..db4d020af2a9
--- /dev/null
+++ b/test/builtins/Unit/floatsitf_test.c
@@ -0,0 +1,58 @@
+//===--------------- floatsitf_test.c - Test __floatsitf ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatsitf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+long double __floatsitf(int a);
+
+int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __floatsitf(a);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret)
+ {
+ printf("error in test__floatsitf(%d) = %.20Lf, "
+ "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
+ return 1;
+ if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
+ return 1;
+ if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0)))
+ return 1;
+ if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
+ return 1;
+ if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floattidf_test.c b/test/builtins/Unit/floattidf_test.c
new file mode 100644
index 000000000000..476304f96f10
--- /dev/null
+++ b/test/builtins/Unit/floattidf_test.c
@@ -0,0 +1,180 @@
+//===-- floattidf.c - Test __floattidf ------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floattidf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a double, rounding toward even.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// ti_int is a 64 bit integral type
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+double __floattidf(ti_int a);
+
+int test__floattidf(ti_int a, double expected)
+{
+ double x = __floattidf(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __floattidf(0x%.16llX%.16llX) = %a, expected %a\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floattidf(0, 0.0))
+ return 1;
+
+ if (test__floattidf(1, 1.0))
+ return 1;
+ if (test__floattidf(2, 2.0))
+ return 1;
+ if (test__floattidf(20, 20.0))
+ return 1;
+ if (test__floattidf(-1, -1.0))
+ return 1;
+ if (test__floattidf(-2, -2.0))
+ return 1;
+ if (test__floattidf(-20, -20.0))
+ return 1;
+
+ if (test__floattidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floattidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floattidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floattidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floattidf(make_ti(0x8000008000000000LL, 0), -0x1.FFFFFEp+126))
+ return 1;
+ if (test__floattidf(make_ti(0x8000000000000800LL, 0), -0x1.FFFFFFFFFFFFEp+126))
+ return 1;
+ if (test__floattidf(make_ti(0x8000010000000000LL, 0), -0x1.FFFFFCp+126))
+ return 1;
+ if (test__floattidf(make_ti(0x8000000000001000LL, 0), -0x1.FFFFFFFFFFFFCp+126))
+ return 1;
+
+ if (test__floattidf(make_ti(0x8000000000000000LL, 0), -0x1.000000p+127))
+ return 1;
+ if (test__floattidf(make_ti(0x8000000000000001LL, 0), -0x1.000000p+127))
+ return 1;
+
+ if (test__floattidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floattidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floattidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floattidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floattidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floattidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floattidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floattidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floattidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floattidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floattidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floattidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floattidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ if (test__floattidf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496Dp+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floattidf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floattisf_test.c b/test/builtins/Unit/floattisf_test.c
new file mode 100644
index 000000000000..75b8e917f76d
--- /dev/null
+++ b/test/builtins/Unit/floattisf_test.c
@@ -0,0 +1,136 @@
+//===-- floattisf_test.c - Test __floattisf -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floattisf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a float, rounding toward even.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// ti_int is a 64 bit integral type
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+float __floattisf(ti_int a);
+
+int test__floattisf(ti_int a, float expected)
+{
+ float x = __floattisf(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __floattisf(0x%.16llX%.16llX) = %a, expected %a\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floattisf(0, 0.0F))
+ return 1;
+
+ if (test__floattisf(1, 1.0F))
+ return 1;
+ if (test__floattisf(2, 2.0F))
+ return 1;
+ if (test__floattisf(-1, -1.0F))
+ return 1;
+ if (test__floattisf(-2, -2.0F))
+ return 1;
+
+ if (test__floattisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floattisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000008000000000LL),
+ -0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000010000000000LL),
+ -0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000000LL),
+ -0x1.000000p+63F))
+ return 1;
+ if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL),
+ -0x1.000000p+63F))
+ return 1;
+
+ if (test__floattisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floattisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floattisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floattisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F))
+ return 1;
+
+ if (test__floattisf(make_ti(0x0007FB72E8000000LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+
+ if (test__floattisf(make_ti(0x0007FB72EA000000LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72EB000000LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72EBFFFFFFLL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72EC000000LL, 0), 0x1.FEDCBCp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72E8000001LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+
+ if (test__floattisf(make_ti(0x0007FB72E6000000LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72E7000000LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72E7FFFFFFLL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72E4000001LL, 0), 0x1.FEDCBAp+114F))
+ return 1;
+ if (test__floattisf(make_ti(0x0007FB72E4000000LL, 0), 0x1.FEDCB8p+114F))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floattixf_test.c b/test/builtins/Unit/floattixf_test.c
new file mode 100644
index 000000000000..ce3566867a47
--- /dev/null
+++ b/test/builtins/Unit/floattixf_test.c
@@ -0,0 +1,212 @@
+//===-- floattixf.c - Test __floattixf ------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floattixf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a long double, rounding toward even.
+
+// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
+// ti_int is a 128 bit integral type
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+long double __floattixf(ti_int a);
+
+int test__floattixf(ti_int a, long double expected)
+{
+ long double x = __floattixf(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __floattixf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floattixf(0, 0.0))
+ return 1;
+
+ if (test__floattixf(1, 1.0))
+ return 1;
+ if (test__floattixf(2, 2.0))
+ return 1;
+ if (test__floattixf(20, 20.0))
+ return 1;
+ if (test__floattixf(-1, -1.0))
+ return 1;
+ if (test__floattixf(-2, -2.0))
+ return 1;
+ if (test__floattixf(-20, -20.0))
+ return 1;
+
+ if (test__floattixf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floattixf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floattixf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floattixf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floattixf(make_ti(0x8000008000000000LL, 0), -0x1.FFFFFEp+126))
+ return 1;
+ if (test__floattixf(make_ti(0x8000000000000800LL, 0), -0x1.FFFFFFFFFFFFEp+126))
+ return 1;
+ if (test__floattixf(make_ti(0x8000010000000000LL, 0), -0x1.FFFFFCp+126))
+ return 1;
+ if (test__floattixf(make_ti(0x8000000000001000LL, 0), -0x1.FFFFFFFFFFFFCp+126))
+ return 1;
+
+ if (test__floattixf(make_ti(0x8000000000000000LL, 0), -0x1.000000p+127))
+ return 1;
+ if (test__floattixf(make_ti(0x8000000000000001LL, 0), -0x1.FFFFFFFFFFFFFFFCp+126L))
+ return 1;
+
+ if (test__floattixf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floattixf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floattixf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floattixf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floattixf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floattixf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floattixf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floattixf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floattixf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floattixf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floattixf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floattixf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L))
+ return 1;
+ if (test__floattixf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ if (test__floattixf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L))
+ return 1;
+ if (test__floattixf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L))
+ return 1;
+
+ if (test__floattixf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L))
+ return 1;
+
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456100000000001LL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456200000000000LL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x34562FFFFFFFFFFFLL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456300000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456400000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x34564FFFFFFFFFFFLL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456500000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x3456500000000001LL),
+ 0x1.2345678901234566p+108L))
+ return 1;
+ if (test__floattixf(make_ti(0x0000123456789012LL, 0x34566FFFFFFFFFFFLL),
+ 0x1.2345678901234566p+108L))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatundidf_test.c b/test/builtins/Unit/floatundidf_test.c
new file mode 100644
index 000000000000..ae91ac374eb0
--- /dev/null
+++ b/test/builtins/Unit/floatundidf_test.c
@@ -0,0 +1,132 @@
+//===-- floatundidf_test.c - Test __floatundidf ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatundidf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+// Returns: convert a to a double, rounding toward even.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// du_int is a 64 bit integral type
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+double __floatundidf(du_int a);
+
+int test__floatundidf(di_int a, double expected)
+{
+ double x = __floatundidf(a);
+ if (x != expected)
+ printf("error in __floatundidf(%llX) = %a, expected %a\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+int main()
+{
+ if (test__floatundidf(0, 0.0))
+ return 1;
+
+ if (test__floatundidf(1, 1.0))
+ return 1;
+ if (test__floatundidf(2, 2.0))
+ return 1;
+ if (test__floatundidf(20, 20.0))
+ return 1;
+
+ if (test__floatundidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatundidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatundidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatundidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatundidf(0x8000008000000000LL, 0x1.000001p+63))
+ return 1;
+ if (test__floatundidf(0x8000000000000800LL, 0x1.0000000000001p+63))
+ return 1;
+ if (test__floatundidf(0x8000010000000000LL, 0x1.000002p+63))
+ return 1;
+ if (test__floatundidf(0x8000000000001000LL, 0x1.0000000000002p+63))
+ return 1;
+
+ if (test__floatundidf(0x8000000000000000LL, 0x1p+63))
+ return 1;
+ if (test__floatundidf(0x8000000000000001LL, 0x1p+63))
+ return 1;
+
+ if (test__floatundidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatundidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatundidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatundidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatundidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatundidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/floatundisf_test.c b/test/builtins/Unit/floatundisf_test.c
new file mode 100644
index 000000000000..394c945a3919
--- /dev/null
+++ b/test/builtins/Unit/floatundisf_test.c
@@ -0,0 +1,96 @@
+//===-- floatundisf_test.c - Test __floatundisf ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatundisf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+// Returns: convert a to a float, rounding toward even.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// du_int is a 64 bit integral type
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+float __floatundisf(du_int a);
+
+int test__floatundisf(du_int a, float expected)
+{
+ float x = __floatundisf(a);
+ if (x != expected)
+ printf("error in __floatundisf(%llX) = %a, expected %a\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(du_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__floatundisf(0, 0.0F))
+ return 1;
+
+ if (test__floatundisf(1, 1.0F))
+ return 1;
+ if (test__floatundisf(2, 2.0F))
+ return 1;
+
+ if (test__floatundisf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floatundisf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floatundisf(0x8000008000000000ULL, 0x1p+63F))
+ return 1;
+ if (test__floatundisf(0x8000010000000000LL, 0x1.000002p+63F))
+ return 1;
+
+ if (test__floatundisf(0x8000000000000000LL, 0x1p+63F))
+ return 1;
+ if (test__floatundisf(0x8000000000000001LL, 0x1p+63F))
+ return 1;
+
+ if (test__floatundisf(0xFFFFFFFFFFFFFFFELL, 0x1p+64F))
+ return 1;
+ if (test__floatundisf(0xFFFFFFFFFFFFFFFFLL, 0x1p+64F))
+ return 1;
+
+ if (test__floatundisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatundisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatundisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatundisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/floatundixf_test.c b/test/builtins/Unit/floatundixf_test.c
new file mode 100644
index 000000000000..1974fa01012a
--- /dev/null
+++ b/test/builtins/Unit/floatundixf_test.c
@@ -0,0 +1,145 @@
+//===-- floatundixf_test.c - Test __floatundixf ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatundixf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+
+#if HAS_80_BIT_LONG_DOUBLE
+// Returns: convert a to a long double, rounding toward even.
+
+// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
+// du_int is a 64 bit integral type
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+long double __floatundixf(du_int a);
+
+int test__floatundixf(du_int a, long double expected)
+{
+ long double x = __floatundixf(a);
+ if (x != expected)
+ printf("error in __floatundixf(%llX) = %LA, expected %LA\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(du_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(du_int)*CHAR_BIT == 64] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+#endif
+
+int main()
+{
+#if HAS_80_BIT_LONG_DOUBLE
+ if (test__floatundixf(0, 0.0))
+ return 1;
+
+ if (test__floatundixf(1, 1.0))
+ return 1;
+ if (test__floatundixf(2, 2.0))
+ return 1;
+ if (test__floatundixf(20, 20.0))
+ return 1;
+
+ if (test__floatundixf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatundixf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatundixf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatundixf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+ if (test__floatundixf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L))
+ return 1;
+ if (test__floatundixf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L))
+ return 1;
+ if (test__floatundixf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L))
+ return 1;
+
+ if (test__floatundixf(0x8000008000000000ULL, 0x8.000008p+60))
+ return 1;
+ if (test__floatundixf(0x8000000000000800ULL, 0x8.0000000000008p+60))
+ return 1;
+ if (test__floatundixf(0x8000010000000000ULL, 0x8.00001p+60))
+ return 1;
+ if (test__floatundixf(0x8000000000001000ULL, 0x8.000000000001p+60))
+ return 1;
+
+ if (test__floatundixf(0x8000000000000000ULL, 0x8p+60))
+ return 1;
+ if (test__floatundixf(0x8000000000000001ULL, 0x8.000000000000001p+60L))
+ return 1;
+
+ if (test__floatundixf(0x0007FB72E8000000ULL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatundixf(0x0007FB72EA000000ULL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72EB000000ULL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72EBFFFFFFULL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72EC000000ULL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72E8000001ULL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatundixf(0x0007FB72E6000000ULL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72E7000000ULL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72E7FFFFFFULL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72E4000001ULL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatundixf(0x0007FB72E4000000ULL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatundixf(0x023479FD0E092DC0ULL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DA1ULL, 0x8.D1E7F43824B684p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DB0ULL, 0x8.D1E7f43824B6Cp+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DB8ULL, 0x8.D1E7F43824B6Ep+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DB6ULL, 0x8.D1E7F43824B6D8p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DBFULL, 0x8.D1E7F43824B6FCp+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DC1ULL, 0x8.D1E7F43824B704p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DC7ULL, 0x8.D1E7F43824B71Cp+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DC8ULL, 0x8.D1E7F43824B72p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DCFULL, 0x8.D1E7F43824B73Cp+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DD0ULL, 0x8.D1E7F43824B74p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DD1ULL, 0x8.D1E7F43824B744p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DD8ULL, 0x8.D1E7F43824B76p+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DDFULL, 0x8.D1E7F43824B77Cp+54L))
+ return 1;
+ if (test__floatundixf(0x023479FD0E092DE0ULL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatunsitf_test.c b/test/builtins/Unit/floatunsitf_test.c
new file mode 100644
index 000000000000..1af72d246ab2
--- /dev/null
+++ b/test/builtins/Unit/floatunsitf_test.c
@@ -0,0 +1,55 @@
+//===--------------- floatunsitf_test.c - Test __floatunsitf --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatunsitf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+long double __floatunsitf(unsigned int a);
+
+int test__floatunsitf(unsigned int a, uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __floatunsitf(a);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret){
+ printf("error in test__floatunsitf(%u) = %.20Lf, "
+ "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ if (test__floatunsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
+ return 1;
+ if (test__floatunsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
+ return 1;
+ if (test__floatunsitf(0xffffffff, UINT64_C(0x401efffffffe0000), UINT64_C(0x0)))
+ return 1;
+ if (test__floatunsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatunssidfvfp_test.c b/test/builtins/Unit/floatunssidfvfp_test.c
new file mode 100644
index 000000000000..4883af1cf5fa
--- /dev/null
+++ b/test/builtins/Unit/floatunssidfvfp_test.c
@@ -0,0 +1,50 @@
+//===-- floatunssidfvfp_test.c - Test __floatunssidfvfp -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatunssidfvfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern double __floatunssidfvfp(unsigned int a);
+
+#if __arm__
+int test__floatunssidfvfp(unsigned int a)
+{
+ double actual = __floatunssidfvfp(a);
+ double expected = a;
+ if (actual != expected)
+ printf("error in test__floatunssidfvfp(%u) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__floatunssidfvfp(0))
+ return 1;
+ if (test__floatunssidfvfp(1))
+ return 1;
+ if (test__floatunssidfvfp(0x7FFFFFFF))
+ return 1;
+ if (test__floatunssidfvfp(0x80000000))
+ return 1;
+ if (test__floatunssidfvfp(0xFFFFFFFF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatunssisfvfp_test.c b/test/builtins/Unit/floatunssisfvfp_test.c
new file mode 100644
index 000000000000..917061a91b18
--- /dev/null
+++ b/test/builtins/Unit/floatunssisfvfp_test.c
@@ -0,0 +1,50 @@
+//===-- floatunssisfvfp_test.c - Test __floatunssisfvfp -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatunssisfvfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __floatunssisfvfp(unsigned int a);
+
+#if __arm__
+int test__floatunssisfvfp(unsigned int a)
+{
+ float actual = __floatunssisfvfp(a);
+ float expected = a;
+ if (actual != expected)
+ printf("error in test__floatunssisfvfp(%u) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__floatunssisfvfp(0))
+ return 1;
+ if (test__floatunssisfvfp(1))
+ return 1;
+ if (test__floatunssisfvfp(0x7FFFFFFF))
+ return 1;
+ if (test__floatunssisfvfp(0x80000000))
+ return 1;
+ if (test__floatunssisfvfp(0xFFFFFFFF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatuntidf_test.c b/test/builtins/Unit/floatuntidf_test.c
new file mode 100644
index 000000000000..3cab027051c7
--- /dev/null
+++ b/test/builtins/Unit/floatuntidf_test.c
@@ -0,0 +1,174 @@
+//===-- floatuntidf.c - Test __floatuntidf --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatuntidf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a double, rounding toward even.
+
+// Assumption: double is a IEEE 64 bit floating point type
+// tu_int is a 64 bit integral type
+
+// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+double __floatuntidf(tu_int a);
+
+int test__floatuntidf(tu_int a, double expected)
+{
+ double x = __floatuntidf(a);
+ if (x != expected)
+ {
+ utwords at;
+ at.all = a;
+ printf("error in __floatuntidf(0x%.16llX%.16llX) = %a, expected %a\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(double)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floatuntidf(0, 0.0))
+ return 1;
+
+ if (test__floatuntidf(1, 1.0))
+ return 1;
+ if (test__floatuntidf(2, 2.0))
+ return 1;
+ if (test__floatuntidf(20, 20.0))
+ return 1;
+
+ if (test__floatuntidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatuntidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatuntidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatuntidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+
+ if (test__floatuntidf(make_ti(0x8000008000000000LL, 0), 0x1.000001p+127))
+ return 1;
+ if (test__floatuntidf(make_ti(0x8000000000000800LL, 0), 0x1.0000000000001p+127))
+ return 1;
+ if (test__floatuntidf(make_ti(0x8000010000000000LL, 0), 0x1.000002p+127))
+ return 1;
+ if (test__floatuntidf(make_ti(0x8000000000001000LL, 0), 0x1.0000000000002p+127))
+ return 1;
+
+ if (test__floatuntidf(make_ti(0x8000000000000000LL, 0), 0x1.000000p+127))
+ return 1;
+ if (test__floatuntidf(make_ti(0x8000000000000001LL, 0), 0x1.0000000000000002p+127))
+ return 1;
+
+ if (test__floatuntidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatuntidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatuntidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatuntidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatuntidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+ if (test__floatuntidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ if (test__floatuntidf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496Dp+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496Ep+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496Fp+121))
+ return 1;
+ if (test__floatuntidf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatuntisf_test.c b/test/builtins/Unit/floatuntisf_test.c
new file mode 100644
index 000000000000..aeac3ee41e54
--- /dev/null
+++ b/test/builtins/Unit/floatuntisf_test.c
@@ -0,0 +1,165 @@
+//===-- floatuntisf.c - Test __floatuntisf --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatuntisf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a float, rounding toward even.
+
+// Assumption: float is a IEEE 32 bit floating point type
+// tu_int is a 128 bit integral type
+
+// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
+
+float __floatuntisf(tu_int a);
+
+int test__floatuntisf(tu_int a, float expected)
+{
+ float x = __floatuntisf(a);
+ if (x != expected)
+ {
+ utwords at;
+ at.all = a;
+ printf("error in __floatuntisf(0x%.16llX%.16llX) = %a, expected %a\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floatuntisf(0, 0.0F))
+ return 1;
+
+ if (test__floatuntisf(1, 1.0F))
+ return 1;
+ if (test__floatuntisf(2, 2.0F))
+ return 1;
+ if (test__floatuntisf(20, 20.0F))
+ return 1;
+
+ if (test__floatuntisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F))
+ return 1;
+ if (test__floatuntisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F))
+ return 1;
+
+ if (test__floatuntisf(make_ti(0x8000008000000000LL, 0), 0x1.000001p+127F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x8000000000000800LL, 0), 0x1.0p+127F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x8000010000000000LL, 0), 0x1.000002p+127F))
+ return 1;
+
+ if (test__floatuntisf(make_ti(0x8000000000000000LL, 0), 0x1.000000p+127F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50F))
+ return 1;
+
+ if (test__floatuntisf(0xFFFFFFFFFFFFFFFELL, 0x1p+64F))
+ return 1;
+ if (test__floatuntisf(0xFFFFFFFFFFFFFFFFLL, 0x1p+64F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+
+ if (test__floatuntisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F))
+ return 1;
+ if (test__floatuntisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F))
+ return 1;
+
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCB90000000000001LL),
+ 0x1.FEDCBAp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBA0000000000000LL),
+ 0x1.FEDCBAp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBAFFFFFFFFFFFFFLL),
+ 0x1.FEDCBAp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBB0000000000000LL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBB0000000000001LL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBBFFFFFFFFFFFFFLL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBC0000000000000LL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBC0000000000001LL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBD0000000000000LL),
+ 0x1.FEDCBCp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBD0000000000001LL),
+ 0x1.FEDCBEp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBDFFFFFFFFFFFFFLL),
+ 0x1.FEDCBEp+76F))
+ return 1;
+ if (test__floatuntisf(make_ti(0x0000000000001FEDLL, 0xCBE0000000000000LL),
+ 0x1.FEDCBEp+76F))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/floatuntixf_test.c b/test/builtins/Unit/floatuntixf_test.c
new file mode 100644
index 000000000000..9c3434fdde0c
--- /dev/null
+++ b/test/builtins/Unit/floatuntixf_test.c
@@ -0,0 +1,219 @@
+//===-- floatuntixf.c - Test __floatuntixf --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __floatuntixf for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <float.h>
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: convert a to a long double, rounding toward even.
+
+// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
+// tu_int is a 128 bit integral type
+
+// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
+// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+
+long double __floatuntixf(tu_int a);
+
+int test__floatuntixf(tu_int a, long double expected)
+{
+ long double x = __floatuntixf(a);
+ if (x != expected)
+ {
+ utwords at;
+ at.all = a;
+ printf("error in __floatuntixf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__floatuntixf(0, 0.0))
+ return 1;
+
+ if (test__floatuntixf(1, 1.0))
+ return 1;
+ if (test__floatuntixf(2, 2.0))
+ return 1;
+ if (test__floatuntixf(20, 20.0))
+ return 1;
+
+ if (test__floatuntixf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62))
+ return 1;
+ if (test__floatuntixf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62))
+ return 1;
+ if (test__floatuntixf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62))
+ return 1;
+ if (test__floatuntixf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62))
+ return 1;
+ if (test__floatuntixf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L))
+ return 1;
+ if (test__floatuntixf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L))
+ return 1;
+ if (test__floatuntixf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L))
+ return 1;
+
+ if (test__floatuntixf(0x8000008000000000ULL, 0x8.000008p+60))
+ return 1;
+ if (test__floatuntixf(0x8000000000000800ULL, 0x8.0000000000008p+60))
+ return 1;
+ if (test__floatuntixf(0x8000010000000000ULL, 0x8.00001p+60))
+ return 1;
+ if (test__floatuntixf(0x8000000000001000ULL, 0x8.000000000001p+60))
+ return 1;
+
+ if (test__floatuntixf(0x8000000000000000ULL, 0x8p+60))
+ return 1;
+ if (test__floatuntixf(0x8000000000000001ULL, 0x8.000000000000001p+60L))
+ return 1;
+
+ if (test__floatuntixf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50))
+ return 1;
+
+ if (test__floatuntixf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50))
+ return 1;
+
+ if (test__floatuntixf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50))
+ return 1;
+ if (test__floatuntixf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50))
+ return 1;
+
+ if (test__floatuntixf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L))
+ return 1;
+ if (test__floatuntixf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57))
+ return 1;
+
+ if (test__floatuntixf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L))
+ return 1;
+
+ if (test__floatuntixf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L))
+ return 1;
+
+ if (test__floatuntixf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x0000000000000000LL),
+ 0x1.FFFFFFFFFFFFFFFEp+127L))
+ return 1;
+ if (test__floatuntixf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 0x1.0000000000000000p+128L))
+ return 1;
+
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456100000000001LL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456200000000000LL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x34562FFFFFFFFFFFLL),
+ 0x1.2345678901234562p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456300000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456400000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x34564FFFFFFFFFFFLL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456500000000000LL),
+ 0x1.2345678901234564p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x3456500000000001LL),
+ 0x1.2345678901234566p+108L))
+ return 1;
+ if (test__floatuntixf(make_ti(0x0000123456789012LL, 0x34566FFFFFFFFFFFLL),
+ 0x1.2345678901234566p+108L))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/fp_test.h b/test/builtins/Unit/fp_test.h
new file mode 100644
index 000000000000..da58ca989cda
--- /dev/null
+++ b/test/builtins/Unit/fp_test.h
@@ -0,0 +1,223 @@
+//===--------------------------- fp_test.h - ------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines shared functions for the test.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+
+enum EXPECTED_RESULT {
+ LESS_0, LESS_EQUAL_0, EQUAL_0, GREATER_0, GREATER_EQUAL_0, NEQUAL_0
+};
+
+static inline float fromRep32(uint32_t x)
+{
+ float ret;
+ memcpy(&ret, &x, 4);
+ return ret;
+}
+
+static inline double fromRep64(uint64_t x)
+{
+ double ret;
+ memcpy(&ret, &x, 8);
+ return ret;
+}
+
+static inline long double fromRep128(uint64_t hi, uint64_t lo)
+{
+ __uint128_t x = ((__uint128_t)hi << 64) + lo;
+ long double ret;
+ memcpy(&ret, &x, 16);
+ return ret;
+}
+
+static inline uint32_t toRep32(float x)
+{
+ uint32_t ret;
+ memcpy(&ret, &x, 4);
+ return ret;
+}
+
+static inline uint64_t toRep64(double x)
+{
+ uint64_t ret;
+ memcpy(&ret, &x, 8);
+ return ret;
+}
+
+static inline __uint128_t toRep128(long double x)
+{
+ __uint128_t ret;
+ memcpy(&ret, &x, 16);
+ return ret;
+}
+
+static inline int compareResultF(float result,
+ uint32_t expected)
+{
+ uint32_t rep = toRep32(result);
+
+ if (rep == expected){
+ return 0;
+ }
+ // test other posible NaN representation(signal NaN)
+ else if (expected == 0x7fc00000U){
+ if ((rep & 0x7f800000U) == 0x7f800000U &&
+ (rep & 0x7fffffU) > 0){
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static inline int compareResultD(double result,
+ uint64_t expected)
+{
+ uint64_t rep = toRep64(result);
+
+ if (rep == expected){
+ return 0;
+ }
+ // test other posible NaN representation(signal NaN)
+ else if (expected == 0x7ff8000000000000UL){
+ if ((rep & 0x7ff0000000000000UL) == 0x7ff0000000000000UL &&
+ (rep & 0xfffffffffffffUL) > 0){
+ return 0;
+ }
+ }
+ return 1;
+}
+
+// return 0 if equal
+// use two 64-bit integers intead of one 128-bit integer
+// because 128-bit integer constant can't be assigned directly
+static inline int compareResultLD(long double result,
+ uint64_t expectedHi,
+ uint64_t expectedLo)
+{
+ __uint128_t rep = toRep128(result);
+ uint64_t hi = rep >> 64;
+ uint64_t lo = rep;
+
+ if (hi == expectedHi && lo == expectedLo){
+ return 0;
+ }
+ // test other posible NaN representation(signal NaN)
+ else if (expectedHi == 0x7fff800000000000UL && expectedLo == 0x0UL){
+ if ((hi & 0x7fff000000000000UL) == 0x7fff000000000000UL &&
+ ((hi & 0xffffffffffffUL) > 0 || lo > 0)){
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static inline int compareResultCMP(int result,
+ enum EXPECTED_RESULT expected)
+{
+ switch(expected){
+ case LESS_0:
+ if (result < 0)
+ return 0;
+ break;
+ case LESS_EQUAL_0:
+ if (result <= 0)
+ return 0;
+ break;
+ case EQUAL_0:
+ if (result == 0)
+ return 0;
+ break;
+ case NEQUAL_0:
+ if (result != 0)
+ return 0;
+ break;
+ case GREATER_EQUAL_0:
+ if (result >= 0)
+ return 0;
+ break;
+ case GREATER_0:
+ if (result > 0)
+ return 0;
+ break;
+ default:
+ return 1;
+ }
+ return 1;
+}
+
+static inline char *expectedStr(enum EXPECTED_RESULT expected)
+{
+ switch(expected){
+ case LESS_0:
+ return "<0";
+ case LESS_EQUAL_0:
+ return "<=0";
+ case EQUAL_0:
+ return "=0";
+ case NEQUAL_0:
+ return "!=0";
+ case GREATER_EQUAL_0:
+ return ">=0";
+ case GREATER_0:
+ return ">0";
+ default:
+ return "";
+ }
+ return "";
+}
+
+static inline float makeQNaN32()
+{
+ return fromRep32(0x7fc00000U);
+}
+
+static inline double makeQNaN64()
+{
+ return fromRep64(0x7ff8000000000000UL);
+}
+
+static inline long double makeQNaN128()
+{
+ return fromRep128(0x7fff800000000000UL, 0x0UL);
+}
+
+static inline float makeNaN32(uint32_t rand)
+{
+ return fromRep32(0x7f800000U | (rand & 0x7fffffU));
+}
+
+static inline double makeNaN64(uint64_t rand)
+{
+ return fromRep64(0x7ff0000000000000UL | (rand & 0xfffffffffffffUL));
+}
+
+static inline long double makeNaN128(uint64_t rand)
+{
+ return fromRep128(0x7fff000000000000UL | (rand & 0xffffffffffffUL), 0x0UL);
+}
+
+static inline float makeInf32()
+{
+ return fromRep32(0x7f800000U);
+}
+
+static inline double makeInf64()
+{
+ return fromRep64(0x7ff0000000000000UL);
+}
+
+static inline long double makeInf128()
+{
+ return fromRep128(0x7fff000000000000UL, 0x0UL);
+}
diff --git a/test/builtins/Unit/gcc_personality_test.c b/test/builtins/Unit/gcc_personality_test.c
new file mode 100644
index 000000000000..f9598c697eb6
--- /dev/null
+++ b/test/builtins/Unit/gcc_personality_test.c
@@ -0,0 +1,42 @@
+/* ===-- gcc_personality_test.c - Tests __gcc_personality_v0 -------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+extern void foo_clean(void* x);
+extern void bar_clean(void* x);
+extern void register_foo_local(int* x);
+extern void register_bar_local(int* x);
+extern void done_foo();
+extern void done_bar();
+
+
+/*
+ * foo() is called by main() in gcc_personality_test_helper.cxx.
+ * done_bar() is implemented in C++ and will throw an exception.
+ * main() will catch the exception and verify that the cleanup
+ * routines for foo() and bar() were called by the personality
+ * function.
+ */
+
+void bar() {
+ int x __attribute__((cleanup(bar_clean))) = 0;
+ register_bar_local(&x);
+ done_bar();
+}
+
+void foo() {
+ int x __attribute__((cleanup(foo_clean))) = 0;
+ register_foo_local(&x);
+ bar();
+ done_foo();
+}
diff --git a/test/builtins/Unit/gcc_personality_test_helper.cxx b/test/builtins/Unit/gcc_personality_test_helper.cxx
new file mode 100644
index 000000000000..7d1ddfb5d960
--- /dev/null
+++ b/test/builtins/Unit/gcc_personality_test_helper.cxx
@@ -0,0 +1,85 @@
+//===-- gcc_personality_test_helper.cxx -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdio.h>
+
+extern "C" {
+ extern void foo_clean(void* x);
+ extern void bar_clean(void* x);
+ extern void register_foo_local(int* x);
+ extern void register_bar_local(int* x);
+ extern void done_foo();
+ extern void done_bar();
+ extern void foo();
+}
+
+static int* foo_x = NULL;
+void register_foo_local(int* x)
+{
+ foo_x = x;
+}
+
+static int* bar_x = NULL;
+void register_bar_local(int* x)
+{
+ bar_x = x;
+}
+
+static bool foo_clean_called = false;
+void foo_clean(void* x)
+{
+ if ( foo_x == NULL )
+ abort();
+ if ( foo_x != (int*)x)
+ abort();
+ foo_clean_called = true;
+}
+
+static bool bar_clean_called = false;
+void bar_clean(void* x)
+{
+ if ( bar_x == NULL )
+ abort();
+ if ( bar_x != (int*)x)
+ abort();
+ bar_clean_called = true;
+}
+
+void done_foo()
+{
+}
+
+void done_bar()
+{
+ throw "done";
+}
+
+
+//
+// foo() is in gcc_personality_test.c and calls bar() which
+// calls done_bar() which throws an exception.
+// main() will catch the exception and verify that the cleanup
+// routines for foo() and bar() were called by the personality
+// function.
+//
+int main()
+{
+ try {
+ foo();
+ }
+ catch(...) {
+ if ( !foo_clean_called )
+ abort();
+ if ( !bar_clean_called )
+ abort();
+ return 0;
+ }
+ abort();
+}
diff --git a/test/builtins/Unit/gedf2vfp_test.c b/test/builtins/Unit/gedf2vfp_test.c
new file mode 100644
index 000000000000..e280ce0780a5
--- /dev/null
+++ b/test/builtins/Unit/gedf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- gedf2vfp_test.c - Test __gedf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __gedf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __gedf2vfp(double a, double b);
+
+#if __arm__
+int test__gedf2vfp(double a, double b)
+{
+ int actual = __gedf2vfp(a, b);
+ int expected = (a >= b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __gedf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__gedf2vfp(0.0, 0.0))
+ return 1;
+ if (test__gedf2vfp(1.0, 0.0))
+ return 1;
+ if (test__gedf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__gedf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__gedf2vfp(HUGE_VAL, 1.0))
+ return 1;
+ if (test__gedf2vfp(1.0, HUGE_VAL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/gesf2vfp_test.c b/test/builtins/Unit/gesf2vfp_test.c
new file mode 100644
index 000000000000..aa53eb739979
--- /dev/null
+++ b/test/builtins/Unit/gesf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- gesf2vfp_test.c - Test __gesf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __gesf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __gesf2vfp(float a, float b);
+
+#if __arm__
+int test__gesf2vfp(float a, float b)
+{
+ int actual = __gesf2vfp(a, b);
+ int expected = (a >= b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __gesf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__gesf2vfp(0.0, 0.0))
+ return 1;
+ if (test__gesf2vfp(1.1, 1.0))
+ return 1;
+ if (test__gesf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__gesf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__gesf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__gesf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/getf2_test.c b/test/builtins/Unit/getf2_test.c
new file mode 100644
index 000000000000..9796b8ab845d
--- /dev/null
+++ b/test/builtins/Unit/getf2_test.c
@@ -0,0 +1,89 @@
+//===------------ getf2_test.c - Test __getf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __getf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __getf2(long double a, long double b);
+
+int test__getf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __getf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__getf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__getf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // <
+ // exp
+ if (test__getf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // mantissa
+ if (test__getf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // sign
+ if (test__getf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // ==
+ if (test__getf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__getf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // mantissa
+ if (test__getf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // sign
+ if (test__getf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/gtdf2vfp_test.c b/test/builtins/Unit/gtdf2vfp_test.c
new file mode 100644
index 000000000000..fd54e0b4e59f
--- /dev/null
+++ b/test/builtins/Unit/gtdf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- gtdf2vfp_test.c - Test __gtdf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __gtdf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __gtdf2vfp(double a, double b);
+
+#if __arm__
+int test__gtdf2vfp(double a, double b)
+{
+ int actual = __gtdf2vfp(a, b);
+ int expected = (a > b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __gtdf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__gtdf2vfp(0.0, 0.0))
+ return 1;
+ if (test__gtdf2vfp(1.0, 0.0))
+ return 1;
+ if (test__gtdf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__gtdf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__gtdf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__gtdf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/gtsf2vfp_test.c b/test/builtins/Unit/gtsf2vfp_test.c
new file mode 100644
index 000000000000..2f4ad99a63d6
--- /dev/null
+++ b/test/builtins/Unit/gtsf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- gtsf2vfp_test.c - Test __gtsf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __gtsf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __gtsf2vfp(float a, float b);
+
+#if __arm__
+int test__gtsf2vfp(float a, float b)
+{
+ int actual = __gtsf2vfp(a, b);
+ int expected = (a > b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __gtsf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__gtsf2vfp(0.0, 0.0))
+ return 1;
+ if (test__gtsf2vfp(1.0, 0.0))
+ return 1;
+ if (test__gtsf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__gtsf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__gtsf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__gtsf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/gttf2_test.c b/test/builtins/Unit/gttf2_test.c
new file mode 100644
index 000000000000..6508d4b978c9
--- /dev/null
+++ b/test/builtins/Unit/gttf2_test.c
@@ -0,0 +1,89 @@
+//===------------ gttf2_test.c - Test __gttf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __gttf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __gttf2(long double a, long double b);
+
+int test__gttf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __gttf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__gttf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__gttf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // <
+ // exp
+ if (test__gttf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // mantissa
+ if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // sign
+ if (test__gttf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // ==
+ if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ GREATER_0))
+ return 1;
+ // mantissa
+ if (test__gttf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_0))
+ return 1;
+ // sign
+ if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ledf2vfp_test.c b/test/builtins/Unit/ledf2vfp_test.c
new file mode 100644
index 000000000000..5683590778c0
--- /dev/null
+++ b/test/builtins/Unit/ledf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- ledf2vfp_test.c - Test __ledf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ledf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __ledf2vfp(double a, double b);
+
+#if __arm__
+int test__ledf2vfp(double a, double b)
+{
+ int actual = __ledf2vfp(a, b);
+ int expected = (a <= b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __ledf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__ledf2vfp(0.0, 0.0))
+ return 1;
+ if (test__ledf2vfp(1.0, 1.0))
+ return 1;
+ if (test__ledf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__ledf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__ledf2vfp(HUGE_VAL, 1.0))
+ return 1;
+ if (test__ledf2vfp(1.0, HUGE_VAL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/lesf2vfp_test.c b/test/builtins/Unit/lesf2vfp_test.c
new file mode 100644
index 000000000000..b5c20f61e8ad
--- /dev/null
+++ b/test/builtins/Unit/lesf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- lesf2vfp_test.c - Test __lesf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __lesf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __lesf2vfp(float a, float b);
+
+#if __arm__
+int test__lesf2vfp(float a, float b)
+{
+ int actual = __lesf2vfp(a, b);
+ int expected = (a <= b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __lesf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__lesf2vfp(0.0, 0.0))
+ return 1;
+ if (test__lesf2vfp(1.0, 1.0))
+ return 1;
+ if (test__lesf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__lesf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__lesf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__lesf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/letf2_test.c b/test/builtins/Unit/letf2_test.c
new file mode 100644
index 000000000000..1842e3c55620
--- /dev/null
+++ b/test/builtins/Unit/letf2_test.c
@@ -0,0 +1,89 @@
+//===------------ letf2_test.c - Test __letf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __letf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __letf2(long double a, long double b);
+
+int test__letf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __letf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__letf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__letf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_0))
+ return 1;
+ // <
+ // exp
+ if (test__letf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // mantissa
+ if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // sign
+ if (test__letf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // ==
+ if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ GREATER_0))
+ return 1;
+ // mantissa
+ if (test__letf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_0))
+ return 1;
+ // sign
+ if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/lshrdi3_test.c b/test/builtins/Unit/lshrdi3_test.c
new file mode 100644
index 000000000000..ffc6a69d0e9f
--- /dev/null
+++ b/test/builtins/Unit/lshrdi3_test.c
@@ -0,0 +1,118 @@
+//===-- lshrdi3_test.c - Test __lshrdi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __lshrdi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: logical a >> b
+
+// Precondition: 0 <= b < bits_in_dword
+
+di_int __lshrdi3(di_int a, si_int b);
+
+int test__lshrdi3(di_int a, si_int b, di_int expected)
+{
+ di_int x = __lshrdi3(a, b);
+ if (x != expected)
+ printf("error in __lshrdi3: %llX >> %d = %llX, expected %llX\n",
+ a, b, __lshrdi3(a, b), expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 1, 0x91A2B3C4D5E6F7LL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BLL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 3, 0x2468ACF13579BDLL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 4, 0x123456789ABCDELL))
+ return 1;
+
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 28, 0x12345678LL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 29, 0x91A2B3CLL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 30, 0x48D159ELL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 31, 0x2468ACFLL))
+ return 1;
+
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 32, 0x1234567LL))
+ return 1;
+
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 33, 0x91A2B3LL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 34, 0x48D159LL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 35, 0x2468ACLL))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 36, 0x123456LL))
+ return 1;
+
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 60, 0))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 61, 0))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 62, 0))
+ return 1;
+ if (test__lshrdi3(0x0123456789ABCDEFLL, 63, 0))
+ return 1;
+
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 0, 0xFEDCBA9876543210LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 1, 0x7F6E5D4C3B2A1908LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 2, 0x3FB72EA61D950C84LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 3, 0x1FDB97530ECA8642LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 4, 0xFEDCBA987654321LL))
+ return 1;
+
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 28, 0xFEDCBA987LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 29, 0x7F6E5D4C3LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 30, 0x3FB72EA61LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 31, 0x1FDB97530LL))
+ return 1;
+
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 32, 0xFEDCBA98LL))
+ return 1;
+
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 33, 0x7F6E5D4CLL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 34, 0x3FB72EA6LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 35, 0x1FDB9753LL))
+ return 1;
+ if (test__lshrdi3(0xFEDCBA9876543210LL, 36, 0xFEDCBA9LL))
+ return 1;
+
+ if (test__lshrdi3(0xAEDCBA9876543210LL, 60, 0xALL))
+ return 1;
+ if (test__lshrdi3(0xAEDCBA9876543210LL, 61, 0x5LL))
+ return 1;
+ if (test__lshrdi3(0xAEDCBA9876543210LL, 62, 0x2LL))
+ return 1;
+ if (test__lshrdi3(0xAEDCBA9876543210LL, 63, 0x1LL))
+ return 1;
+ return 0;
+}
diff --git a/test/builtins/Unit/lshrti3_test.c b/test/builtins/Unit/lshrti3_test.c
new file mode 100644
index 000000000000..3f33c089cd62
--- /dev/null
+++ b/test/builtins/Unit/lshrti3_test.c
@@ -0,0 +1,173 @@
+//===-- lshrti3_test.c - Test __lshrti3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __lshrti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: logical a >> b
+
+// Precondition: 0 <= b < bits_in_dword
+
+ti_int __lshrti3(ti_int a, si_int b);
+
+int test__lshrti3(ti_int a, si_int b, ti_int expected)
+{
+ ti_int x = __lshrti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __lshrti3: 0x%llX%.16llX >> %d = 0x%llX%.16llX,"
+ " expected 0x%llX%.16llX\n",
+ at.s.high, at.s.low, b, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0,
+ make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1,
+ make_ti(0x7F6E5D4C3B2A190ALL, 0xFF6E5D4C3B2A190ALL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2,
+ make_ti(0x3FB72EA61D950C85LL, 0x7FB72EA61D950C85LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3,
+ make_ti(0x1FDB97530ECA8642LL, 0xBFDB97530ECA8642LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4,
+ make_ti(0x0FEDCBA987654321LL, 0x5FEDCBA987654321LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28,
+ make_ti(0x0000000FEDCBA987LL, 0x6543215FEDCBA987LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29,
+ make_ti(0x00000007F6E5D4C3LL, 0xB2A190AFF6E5D4C3LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30,
+ make_ti(0x00000003FB72EA61LL, 0xD950C857FB72EA61LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31,
+ make_ti(0x00000001FDB97530LL, 0xECA8642BFDB97530LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32,
+ make_ti(0x00000000FEDCBA98LL, 0x76543215FEDCBA98LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33,
+ make_ti(0x000000007F6E5D4CLL, 0x3B2A190AFF6E5D4CLL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34,
+ make_ti(0x000000003FB72EA6LL, 0x1D950C857FB72EA6LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35,
+ make_ti(0x000000001FDB9753LL, 0x0ECA8642BFDB9753LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36,
+ make_ti(0x000000000FEDCBA9LL, 0x876543215FEDCBA9LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60,
+ make_ti(0x000000000000000FLL, 0xEDCBA9876543215FLL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61,
+ make_ti(0x0000000000000007LL, 0xF6E5D4C3B2A190AFLL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62,
+ make_ti(0x0000000000000003LL, 0xFB72EA61D950C857LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63,
+ make_ti(0x0000000000000001LL, 0xFDB97530ECA8642BLL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64,
+ make_ti(0x0000000000000000LL, 0xFEDCBA9876543215LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65,
+ make_ti(0x0000000000000000LL, 0x7F6E5D4C3B2A190ALL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66,
+ make_ti(0x0000000000000000LL, 0x3FB72EA61D950C85LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67,
+ make_ti(0x0000000000000000LL, 0x1FDB97530ECA8642LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68,
+ make_ti(0x0000000000000000LL, 0x0FEDCBA987654321LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92,
+ make_ti(0x0000000000000000LL, 0x0000000FEDCBA987LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93,
+ make_ti(0x0000000000000000LL, 0x00000007F6E5D4C3LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94,
+ make_ti(0x0000000000000000LL, 0x00000003FB72EA61LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95,
+ make_ti(0x0000000000000000LL, 0x00000001FDB97530LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96,
+ make_ti(0x0000000000000000LL, 0x00000000FEDCBA98LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97,
+ make_ti(0x0000000000000000LL, 0x000000007F6E5D4CLL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98,
+ make_ti(0x0000000000000000LL, 0x000000003FB72EA6LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99,
+ make_ti(0x0000000000000000LL, 0x000000001FDB9753LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100,
+ make_ti(0x0000000000000000LL, 0x000000000FEDCBA9LL)))
+ return 1;
+
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124,
+ make_ti(0x0000000000000000LL, 0x000000000000000FLL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125,
+ make_ti(0x0000000000000000LL, 0x0000000000000007LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126,
+ make_ti(0x0000000000000000LL, 0x0000000000000003LL)))
+ return 1;
+ if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127,
+ make_ti(0x0000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ltdf2vfp_test.c b/test/builtins/Unit/ltdf2vfp_test.c
new file mode 100644
index 000000000000..7319397c5e4d
--- /dev/null
+++ b/test/builtins/Unit/ltdf2vfp_test.c
@@ -0,0 +1,51 @@
+//===-- ltdf2vfp_test.c - Test __ltdf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ltdf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __ltdf2vfp(double a, double b);
+
+#if __arm__
+int test__ltdf2vfp(double a, double b)
+{
+ int actual = __ltdf2vfp(a, b);
+ int expected = (a < b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __ltdf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__ltdf2vfp(0.0, 0.0))
+ return 1;
+ if (test__ltdf2vfp(1.0, 1.0))
+ return 1;
+ if (test__ltdf2vfp(-1.0, -1.0))
+ return 1;
+ if (test__ltdf2vfp(HUGE_VAL, 1.0))
+ return 1;
+ if (test__ltdf2vfp(1.0, HUGE_VAL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/ltsf2vfp_test.c b/test/builtins/Unit/ltsf2vfp_test.c
new file mode 100644
index 000000000000..2d920c959326
--- /dev/null
+++ b/test/builtins/Unit/ltsf2vfp_test.c
@@ -0,0 +1,53 @@
+//===-- ltsf2vfp_test.c - Test __ltsf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __ltsf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __ltsf2vfp(float a, float b);
+
+#if __arm__
+int test__ltsf2vfp(float a, float b)
+{
+ int actual = __ltsf2vfp(a, b);
+ int expected = (a < b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __ltsf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__ltsf2vfp(0.0, 0.0))
+ return 1;
+ if (test__ltsf2vfp(-1.0, 1.0))
+ return 1;
+ if (test__ltsf2vfp(-1.0, -2.0))
+ return 1;
+ if (test__ltsf2vfp(-2.0, -1.0))
+ return 1;
+ if (test__ltsf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__ltsf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/lttf2_test.c b/test/builtins/Unit/lttf2_test.c
new file mode 100644
index 000000000000..e8f9dc17c6f7
--- /dev/null
+++ b/test/builtins/Unit/lttf2_test.c
@@ -0,0 +1,89 @@
+//===------------ lttf2_test.c - Test __lttf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __lttf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __lttf2(long double a, long double b);
+
+int test__lttf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __lttf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__lttf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__lttf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // <
+ // exp
+ if (test__lttf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // mantissa
+ if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // sign
+ if (test__lttf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ LESS_0))
+ return 1;
+ // ==
+ if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // mantissa
+ if (test__lttf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+ // sign
+ if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ GREATER_EQUAL_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/moddi3_test.c b/test/builtins/Unit/moddi3_test.c
new file mode 100644
index 000000000000..9f6801d6f41b
--- /dev/null
+++ b/test/builtins/Unit/moddi3_test.c
@@ -0,0 +1,62 @@
+//===-- moddi3_test.c - Test __moddi3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __moddi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a % b
+
+di_int __moddi3(di_int a, di_int b);
+
+int test__moddi3(di_int a, di_int b, di_int expected)
+{
+ di_int x = __moddi3(a, b);
+ if (x != expected)
+ printf("error in __moddi3: %lld %% %lld = %lld, expected %lld\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__moddi3(0, 1, 0))
+ return 1;
+ if (test__moddi3(0, -1, 0))
+ return 1;
+
+ if (test__moddi3(5, 3, 2))
+ return 1;
+ if (test__moddi3(5, -3, 2))
+ return 1;
+ if (test__moddi3(-5, 3, -2))
+ return 1;
+ if (test__moddi3(-5, -3, -2))
+ return 1;
+
+ if (test__moddi3(0x8000000000000000LL, 1, 0x0LL))
+ return 1;
+ if (test__moddi3(0x8000000000000000LL, -1, 0x0LL))
+ return 1;
+ if (test__moddi3(0x8000000000000000LL, 2, 0x0LL))
+ return 1;
+ if (test__moddi3(0x8000000000000000LL, -2, 0x0LL))
+ return 1;
+ if (test__moddi3(0x8000000000000000LL, 3, -2))
+ return 1;
+ if (test__moddi3(0x8000000000000000LL, -3, -2))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/modsi3_test.c b/test/builtins/Unit/modsi3_test.c
new file mode 100644
index 000000000000..52ec9a0ae36b
--- /dev/null
+++ b/test/builtins/Unit/modsi3_test.c
@@ -0,0 +1,57 @@
+/* ===-- modsi3_test.c - Test __modsi3 -------------------------------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ *
+ * This file tests __modsi3 for the compiler_rt library.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include "int_lib.h"
+#include <stdio.h>
+
+/* Returns: a % b */
+
+si_int __modsi3(si_int a, si_int b);
+
+int test__modsi3(si_int a, si_int b, si_int expected) {
+ si_int x = __modsi3(a, b);
+ if (x != expected)
+ fprintf(stderr, "error in __modsi3: %d %% %d = %d, expected %d\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main() {
+ if (test__modsi3(0, 1, 0))
+ return 1;
+ if (test__modsi3(0, -1, 0))
+ return 1;
+
+ if (test__modsi3(5, 3, 2))
+ return 1;
+ if (test__modsi3(5, -3, 2))
+ return 1;
+ if (test__modsi3(-5, 3, -2))
+ return 1;
+ if (test__modsi3(-5, -3, -2))
+ return 1;
+
+ if (test__modsi3(0x80000000, 1, 0x0))
+ return 1;
+ if (test__modsi3(0x80000000, 2, 0x0))
+ return 1;
+ if (test__modsi3(0x80000000, -2, 0x0))
+ return 1;
+ if (test__modsi3(0x80000000, 3, -2))
+ return 1;
+ if (test__modsi3(0x80000000, -3, -2))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/modti3_test.c b/test/builtins/Unit/modti3_test.c
new file mode 100644
index 000000000000..ba9f9804dfca
--- /dev/null
+++ b/test/builtins/Unit/modti3_test.c
@@ -0,0 +1,95 @@
+//===-- modti3_test.c - Test __modti3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __modti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a % b
+
+ti_int __modti3(ti_int a, ti_int b);
+
+int test__modti3(ti_int a, ti_int b, ti_int expected)
+{
+ ti_int x = __modti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __modti3: 0x%.16llX%.16llX %% 0x%.16llX%.16llX = "
+ "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__modti3(0, 1, 0))
+ return 1;
+ if (test__modti3(0, -1, 0))
+ return 1;
+
+ if (test__modti3(5, 3, 2))
+ return 1;
+ if (test__modti3(5, -3, 2))
+ return 1;
+ if (test__modti3(-5, 3, -2))
+ return 1;
+ if (test__modti3(-5, -3, -2))
+ return 1;
+
+ if (test__modti3(0x8000000000000000LL, 1, 0x0LL))
+ return 1;
+ if (test__modti3(0x8000000000000000LL, -1, 0x0LL))
+ return 1;
+ if (test__modti3(0x8000000000000000LL, 2, 0x0LL))
+ return 1;
+ if (test__modti3(0x8000000000000000LL, -2, 0x0LL))
+ return 1;
+ if (test__modti3(0x8000000000000000LL, 3, 2))
+ return 1;
+ if (test__modti3(0x8000000000000000LL, -3, 2))
+ return 1;
+
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), 1, 0x0LL))
+ return 1;
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), -1, 0x0LL))
+ return 1;
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), 2, 0x0LL))
+ return 1;
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), -2, 0x0LL))
+ return 1;
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), 3, -2))
+ return 1;
+ if (test__modti3(make_ti(0x8000000000000000LL, 0), -3, -2))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/muldc3_test.c b/test/builtins/Unit/muldc3_test.c
new file mode 100644
index 000000000000..112b6120358a
--- /dev/null
+++ b/test/builtins/Unit/muldc3_test.c
@@ -0,0 +1,366 @@
+//===-- muldc3_test.c - Test __muldc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __muldc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the product of a + ib and c + id
+
+double _Complex __muldc3(double __a, double __b, double __c, double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creal(x)) || isinf(cimag(x)))
+ return inf;
+ if (isnan(creal(x)) && isnan(cimag(x)))
+ return NaN;
+ if (isnan(creal(x)))
+ {
+ if (cimag(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimag(x)))
+ {
+ if (creal(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__muldc3(double a, double b, double c, double d)
+{
+ double _Complex r = __muldc3(a, b, c, d);
+// printf("test__muldc3(%f, %f, %f, %f) = %f + I%f\n",
+// a, b, c, d, creal(r), cimag(r));
+ double _Complex dividend;
+ double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ if (r != a * c - b * d + _Complex_I*(a * d + b * c))
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+int main()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__muldc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/builtins/Unit/muldf3vfp_test.c b/test/builtins/Unit/muldf3vfp_test.c
new file mode 100644
index 000000000000..73454bf290aa
--- /dev/null
+++ b/test/builtins/Unit/muldf3vfp_test.c
@@ -0,0 +1,50 @@
+//===-- muldf3vfp_test.c - Test __muldf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __muldf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#if __arm__
+extern double __muldf3vfp(double a, double b);
+
+int test__muldf3vfp(double a, double b)
+{
+ double actual = __muldf3vfp(a, b);
+ double expected = a * b;
+ if (actual != expected)
+ printf("error in test__muldf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__muldf3vfp(0.5, 10.0))
+ return 1;
+ if (test__muldf3vfp(-0.5, -2.0))
+ return 1;
+ if (test__muldf3vfp(HUGE_VALF, 0.25))
+ return 1;
+ if (test__muldf3vfp(-0.125, HUGE_VALF))
+ return 1;
+ if (test__muldf3vfp(0.0, -0.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/muldi3_test.c b/test/builtins/Unit/muldi3_test.c
new file mode 100644
index 000000000000..83b525592645
--- /dev/null
+++ b/test/builtins/Unit/muldi3_test.c
@@ -0,0 +1,110 @@
+//===-- muldi3_test.c - Test __muldi3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __muldi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+di_int __muldi3(di_int a, di_int b);
+
+int test__muldi3(di_int a, di_int b, di_int expected)
+{
+ di_int x = __muldi3(a, b);
+ if (x != expected)
+ printf("error in __muldi3: %lld * %lld = %lld, expected %lld\n",
+ a, b, __muldi3(a, b), expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__muldi3(0, 0, 0))
+ return 1;
+ if (test__muldi3(0, 1, 0))
+ return 1;
+ if (test__muldi3(1, 0, 0))
+ return 1;
+ if (test__muldi3(0, 10, 0))
+ return 1;
+ if (test__muldi3(10, 0, 0))
+ return 1;
+ if (test__muldi3(0, 81985529216486895LL, 0))
+ return 1;
+ if (test__muldi3(81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__muldi3(0, -1, 0))
+ return 1;
+ if (test__muldi3(-1, 0, 0))
+ return 1;
+ if (test__muldi3(0, -10, 0))
+ return 1;
+ if (test__muldi3(-10, 0, 0))
+ return 1;
+ if (test__muldi3(0, -81985529216486895LL, 0))
+ return 1;
+ if (test__muldi3(-81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__muldi3(1, 1, 1))
+ return 1;
+ if (test__muldi3(1, 10, 10))
+ return 1;
+ if (test__muldi3(10, 1, 10))
+ return 1;
+ if (test__muldi3(1, 81985529216486895LL, 81985529216486895LL))
+ return 1;
+ if (test__muldi3(81985529216486895LL, 1, 81985529216486895LL))
+ return 1;
+
+ if (test__muldi3(1, -1, -1))
+ return 1;
+ if (test__muldi3(1, -10, -10))
+ return 1;
+ if (test__muldi3(-10, 1, -10))
+ return 1;
+ if (test__muldi3(1, -81985529216486895LL, -81985529216486895LL))
+ return 1;
+ if (test__muldi3(-81985529216486895LL, 1, -81985529216486895LL))
+ return 1;
+
+ if (test__muldi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
+ return 1;
+ if (test__muldi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__muldi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__muldi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
+ return 1;
+
+ if (test__muldi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
+ return 1;
+ if (test__muldi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__muldi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__muldi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__muldi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
+ return 1;
+ if (test__muldi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__muldi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__muldi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/mulodi4_test.c b/test/builtins/Unit/mulodi4_test.c
new file mode 100644
index 000000000000..10a0eaac61f9
--- /dev/null
+++ b/test/builtins/Unit/mulodi4_test.c
@@ -0,0 +1,178 @@
+//===-- mulodi4_test.c - Test __mulodi4 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulodi4 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+extern di_int __mulodi4(di_int a, di_int b, int* overflow);
+
+int test__mulodi4(di_int a, di_int b, di_int expected, int expected_overflow)
+{
+ int ov;
+ di_int x = __mulodi4(a, b, &ov);
+ if (ov != expected_overflow)
+ printf("error in __mulodi4: overflow=%d expected=%d\n",
+ ov, expected_overflow);
+ else if (!expected_overflow && x != expected) {
+ printf("error in __mulodi4: 0x%llX * 0x%llX = 0x%llX (overflow=%d), "
+ "expected 0x%llX (overflow=%d)\n",
+ a, b, x, ov, expected, expected_overflow);
+ return 1;
+ }
+ return 0;
+}
+
+int main()
+{
+ if (test__mulodi4(0, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 1, 0, 0))
+ return 1;
+ if (test__mulodi4(1, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 10, 0, 0))
+ return 1;
+ if (test__mulodi4(10, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 81985529216486895LL, 0, 0))
+ return 1;
+ if (test__mulodi4(81985529216486895LL, 0, 0, 0))
+ return 1;
+
+ if (test__mulodi4(0, -1, 0, 0))
+ return 1;
+ if (test__mulodi4(-1, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, -10, 0, 0))
+ return 1;
+ if (test__mulodi4(-10, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, -81985529216486895LL, 0, 0))
+ return 1;
+ if (test__mulodi4(-81985529216486895LL, 0, 0, 0))
+ return 1;
+
+ if (test__mulodi4(1, 1, 1, 0))
+ return 1;
+ if (test__mulodi4(1, 10, 10, 0))
+ return 1;
+ if (test__mulodi4(10, 1, 10, 0))
+ return 1;
+ if (test__mulodi4(1, 81985529216486895LL, 81985529216486895LL, 0))
+ return 1;
+ if (test__mulodi4(81985529216486895LL, 1, 81985529216486895LL, 0))
+ return 1;
+
+ if (test__mulodi4(1, -1, -1, 0))
+ return 1;
+ if (test__mulodi4(1, -10, -10, 0))
+ return 1;
+ if (test__mulodi4(-10, 1, -10, 0))
+ return 1;
+ if (test__mulodi4(1, -81985529216486895LL, -81985529216486895LL, 0))
+ return 1;
+ if (test__mulodi4(-81985529216486895LL, 1, -81985529216486895LL, 0))
+ return 1;
+
+ if (test__mulodi4(3037000499LL, 3037000499LL, 9223372030926249001LL, 0))
+ return 1;
+ if (test__mulodi4(-3037000499LL, 3037000499LL, -9223372030926249001LL, 0))
+ return 1;
+ if (test__mulodi4(3037000499LL, -3037000499LL, -9223372030926249001LL, 0))
+ return 1;
+ if (test__mulodi4(-3037000499LL, -3037000499LL, 9223372030926249001LL, 0))
+ return 1;
+
+ if (test__mulodi4(4398046511103LL, 2097152LL, 9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(-4398046511103LL, 2097152LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(4398046511103LL, -2097152LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(-4398046511103LL, -2097152LL, 9223372036852678656LL, 0))
+ return 1;
+
+ if (test__mulodi4(2097152LL, 4398046511103LL, 9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(-2097152LL, 4398046511103LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(2097152LL, -4398046511103LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__mulodi4(-2097152LL, -4398046511103LL, 9223372036852678656LL, 0))
+ return 1;
+
+ if (test__mulodi4(0x7FFFFFFFFFFFFFFFLL, -2, 2, 1))
+ return 1;
+ if (test__mulodi4(-2, 0x7FFFFFFFFFFFFFFFLL, 2, 1))
+ return 1;
+ if (test__mulodi4(0x7FFFFFFFFFFFFFFFLL, -1, 0x8000000000000001LL, 0))
+ return 1;
+ if (test__mulodi4(-1, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL, 0))
+ return 1;
+ if (test__mulodi4(0x7FFFFFFFFFFFFFFFLL, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 0x7FFFFFFFFFFFFFFFLL, 0, 0))
+ return 1;
+ if (test__mulodi4(0x7FFFFFFFFFFFFFFFLL, 1, 0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__mulodi4(1, 0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__mulodi4(0x7FFFFFFFFFFFFFFFLL, 2, 0x8000000000000001LL, 1))
+ return 1;
+ if (test__mulodi4(2, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL, 1))
+ return 1;
+
+ if (test__mulodi4(0x8000000000000000LL, -2, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(-2, 0x8000000000000000LL, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(0x8000000000000000LL, -1, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(-1, 0x8000000000000000LL, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(0x8000000000000000LL, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 0x8000000000000000LL, 0, 0))
+ return 1;
+ if (test__mulodi4(0x8000000000000000LL, 1, 0x8000000000000000LL, 0))
+ return 1;
+ if (test__mulodi4(1, 0x8000000000000000LL, 0x8000000000000000LL, 0))
+ return 1;
+ if (test__mulodi4(0x8000000000000000LL, 2, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(2, 0x8000000000000000LL, 0x8000000000000000LL, 1))
+ return 1;
+
+ if (test__mulodi4(0x8000000000000001LL, -2, 0x8000000000000001LL, 1))
+ return 1;
+ if (test__mulodi4(-2, 0x8000000000000001LL, 0x8000000000000001LL, 1))
+ return 1;
+ if (test__mulodi4(0x8000000000000001LL, -1, 0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__mulodi4(-1, 0x8000000000000001LL, 0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__mulodi4(0x8000000000000001LL, 0, 0, 0))
+ return 1;
+ if (test__mulodi4(0, 0x8000000000000001LL, 0, 0))
+ return 1;
+ if (test__mulodi4(0x8000000000000001LL, 1, 0x8000000000000001LL, 0))
+ return 1;
+ if (test__mulodi4(1, 0x8000000000000001LL, 0x8000000000000001LL, 0))
+ return 1;
+ if (test__mulodi4(0x8000000000000001LL, 2, 0x8000000000000000LL, 1))
+ return 1;
+ if (test__mulodi4(2, 0x8000000000000001LL, 0x8000000000000000LL, 1))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/mulosi4_test.c b/test/builtins/Unit/mulosi4_test.c
new file mode 100644
index 000000000000..fc509db2c178
--- /dev/null
+++ b/test/builtins/Unit/mulosi4_test.c
@@ -0,0 +1,156 @@
+//===-- mulosi4_test.c - Test __mulosi4 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulosi4 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a * b
+
+// Effects: aborts if a * b overflows
+
+si_int __mulosi4(si_int a, si_int b, int *overflow);
+
+int test__mulosi4(si_int a, si_int b, si_int expected, int expected_overflow)
+{
+ int ov;
+ si_int x = __mulosi4(a, b, &ov);
+ if (ov != expected_overflow)
+ printf("error in __mulosi4: overflow=%d expected=%d\n",
+ ov, expected_overflow);
+ else if (!expected_overflow && x != expected) {
+ printf("error in __mulosi4: 0x%X * 0x%X = 0x%X (overflow=%d), "
+ "expected 0x%X (overflow=%d)\n",
+ a, b, x, ov, expected, expected_overflow);
+ return 1;
+ }
+ return 0;
+}
+
+
+int main()
+{
+ if (test__mulosi4(0, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 1, 0, 0))
+ return 1;
+ if (test__mulosi4(1, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 10, 0, 0))
+ return 1;
+ if (test__mulosi4(10, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 0x1234567, 0, 0))
+ return 1;
+ if (test__mulosi4(0x1234567, 0, 0, 0))
+ return 1;
+
+ if (test__mulosi4(0, -1, 0, 0))
+ return 1;
+ if (test__mulosi4(-1, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, -10, 0, 0))
+ return 1;
+ if (test__mulosi4(-10, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, -0x1234567, 0, 0))
+ return 1;
+ if (test__mulosi4(-0x1234567, 0, 0, 0))
+ return 1;
+
+ if (test__mulosi4(1, 1, 1, 0))
+ return 1;
+ if (test__mulosi4(1, 10, 10, 0))
+ return 1;
+ if (test__mulosi4(10, 1, 10, 0))
+ return 1;
+ if (test__mulosi4(1, 0x1234567, 0x1234567, 0))
+ return 1;
+ if (test__mulosi4(0x1234567, 1, 0x1234567, 0))
+ return 1;
+
+ if (test__mulosi4(1, -1, -1, 0))
+ return 1;
+ if (test__mulosi4(1, -10, -10, 0))
+ return 1;
+ if (test__mulosi4(-10, 1, -10, 0))
+ return 1;
+ if (test__mulosi4(1, -0x1234567, -0x1234567, 0))
+ return 1;
+ if (test__mulosi4(-0x1234567, 1, -0x1234567, 0))
+ return 1;
+
+ if (test__mulosi4(0x7FFFFFFF, -2, 0x80000001, 1))
+ return 1;
+ if (test__mulosi4(-2, 0x7FFFFFFF, 0x80000001, 1))
+ return 1;
+ if (test__mulosi4(0x7FFFFFFF, -1, 0x80000001, 0))
+ return 1;
+ if (test__mulosi4(-1, 0x7FFFFFFF, 0x80000001, 0))
+ return 1;
+ if (test__mulosi4(0x7FFFFFFF, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 0x7FFFFFFF, 0, 0))
+ return 1;
+ if (test__mulosi4(0x7FFFFFFF, 1, 0x7FFFFFFF, 0))
+ return 1;
+ if (test__mulosi4(1, 0x7FFFFFFF, 0x7FFFFFFF, 0))
+ return 1;
+ if (test__mulosi4(0x7FFFFFFF, 2, 0x80000001, 1))
+ return 1;
+ if (test__mulosi4(2, 0x7FFFFFFF, 0x80000001, 1))
+ return 1;
+
+ if (test__mulosi4(0x80000000, -2, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(-2, 0x80000000, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(0x80000000, -1, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(-1, 0x80000000, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(0x80000000, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 0x80000000, 0, 0))
+ return 1;
+ if (test__mulosi4(0x80000000, 1, 0x80000000, 0))
+ return 1;
+ if (test__mulosi4(1, 0x80000000, 0x80000000, 0))
+ return 1;
+ if (test__mulosi4(0x80000000, 2, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(2, 0x80000000, 0x80000000, 1))
+ return 1;
+
+ if (test__mulosi4(0x80000001, -2, 0x80000001, 1))
+ return 1;
+ if (test__mulosi4(-2, 0x80000001, 0x80000001, 1))
+ return 1;
+ if (test__mulosi4(0x80000001, -1, 0x7FFFFFFF, 0))
+ return 1;
+ if (test__mulosi4(-1, 0x80000001, 0x7FFFFFFF, 0))
+ return 1;
+ if (test__mulosi4(0x80000001, 0, 0, 0))
+ return 1;
+ if (test__mulosi4(0, 0x80000001, 0, 0))
+ return 1;
+ if (test__mulosi4(0x80000001, 1, 0x80000001, 0))
+ return 1;
+ if (test__mulosi4(1, 0x80000001, 0x80000001, 0))
+ return 1;
+ if (test__mulosi4(0x80000001, 2, 0x80000000, 1))
+ return 1;
+ if (test__mulosi4(2, 0x80000001, 0x80000000, 1))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/muloti4_test.c b/test/builtins/Unit/muloti4_test.c
new file mode 100644
index 000000000000..95439a4197a3
--- /dev/null
+++ b/test/builtins/Unit/muloti4_test.c
@@ -0,0 +1,280 @@
+//===-- muloti4_test.c - Test __muloti4 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __muloti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a * b
+
+// Effects: sets overflow if a * b overflows
+
+ti_int __muloti4(ti_int a, ti_int b, int *overflow);
+
+int test__muloti4(ti_int a, ti_int b, ti_int expected, int expected_overflow)
+{
+ int ov;
+ ti_int x = __muloti4(a, b, &ov);
+ if (ov != expected_overflow) {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+
+ printf("error in __muloti4: overflow=%d expected=%d\n",
+ ov, expected_overflow);
+ printf("error in __muloti4: 0x%.16llX%.16llX * 0x%.16llX%.16llX = "
+ "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ return 1;
+ }
+ else if (!expected_overflow && x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __muloti4: 0x%.16llX%.16llX * 0x%.16llX%.16llX = "
+ "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ return 1;
+ }
+ return 0;
+}
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__muloti4(0, 0, 0, 0))
+ return 1;
+ if (test__muloti4(0, 1, 0, 0))
+ return 1;
+ if (test__muloti4(1, 0, 0, 0))
+ return 1;
+ if (test__muloti4(0, 10, 0, 0))
+ return 1;
+ if (test__muloti4(10, 0, 0, 0))
+ return 1;
+ if (test__muloti4(0, 81985529216486895LL, 0, 0))
+ return 1;
+ if (test__muloti4(81985529216486895LL, 0, 0, 0))
+ return 1;
+
+ if (test__muloti4(0, -1, 0, 0))
+ return 1;
+ if (test__muloti4(-1, 0, 0, 0))
+ return 1;
+ if (test__muloti4(0, -10, 0, 0))
+ return 1;
+ if (test__muloti4(-10, 0, 0, 0))
+ return 1;
+ if (test__muloti4(0, -81985529216486895LL, 0, 0))
+ return 1;
+ if (test__muloti4(-81985529216486895LL, 0, 0, 0))
+ return 1;
+
+ if (test__muloti4(1, 1, 1, 0))
+ return 1;
+ if (test__muloti4(1, 10, 10, 0))
+ return 1;
+ if (test__muloti4(10, 1, 10, 0))
+ return 1;
+ if (test__muloti4(1, 81985529216486895LL, 81985529216486895LL, 0))
+ return 1;
+ if (test__muloti4(81985529216486895LL, 1, 81985529216486895LL, 0))
+ return 1;
+
+ if (test__muloti4(1, -1, -1, 0))
+ return 1;
+ if (test__muloti4(1, -10, -10, 0))
+ return 1;
+ if (test__muloti4(-10, 1, -10, 0))
+ return 1;
+ if (test__muloti4(1, -81985529216486895LL, -81985529216486895LL, 0))
+ return 1;
+ if (test__muloti4(-81985529216486895LL, 1, -81985529216486895LL, 0))
+ return 1;
+
+ if (test__muloti4(3037000499LL, 3037000499LL, 9223372030926249001LL, 0))
+ return 1;
+ if (test__muloti4(-3037000499LL, 3037000499LL, -9223372030926249001LL, 0))
+ return 1;
+ if (test__muloti4(3037000499LL, -3037000499LL, -9223372030926249001LL, 0))
+ return 1;
+ if (test__muloti4(-3037000499LL, -3037000499LL, 9223372030926249001LL, 0))
+ return 1;
+
+ if (test__muloti4(4398046511103LL, 2097152LL, 9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(-4398046511103LL, 2097152LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(4398046511103LL, -2097152LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(-4398046511103LL, -2097152LL, 9223372036852678656LL, 0))
+ return 1;
+
+ if (test__muloti4(2097152LL, 4398046511103LL, 9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(-2097152LL, 4398046511103LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(2097152LL, -4398046511103LL, -9223372036852678656LL, 0))
+ return 1;
+ if (test__muloti4(-2097152LL, -4398046511103LL, 9223372036852678656LL, 0))
+ return 1;
+
+ if (test__muloti4(make_ti(0x00000000000000B5LL, 0x04F333F9DE5BE000LL),
+ make_ti(0x0000000000000000LL, 0x00B504F333F9DE5BLL),
+ make_ti(0x7FFFFFFFFFFFF328LL, 0xDF915DA296E8A000LL), 0))
+ return 1;
+
+ if (test__muloti4(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ -2,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+ if (test__muloti4(-2,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+ if (test__muloti4(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ -1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 0))
+ return 1;
+ if (test__muloti4(-1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 0))
+ return 1;
+ if (test__muloti4(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 0,
+ 0, 0))
+ return 1;
+ if (test__muloti4(0,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 0, 0))
+ return 1;
+ if (test__muloti4(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0))
+ return 1;
+ if (test__muloti4(1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0))
+ return 1;
+ if (test__muloti4(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 2,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+ if (test__muloti4(2,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ -2,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(-2,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ -1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(-1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 0,
+ 0, 0))
+ return 1;
+ if (test__muloti4(0,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 0, 0))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 0))
+ return 1;
+ if (test__muloti4(1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 0))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 2,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(2,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ -2,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+ if (test__muloti4(-2,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 1))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ -1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0))
+ return 1;
+ if (test__muloti4(-1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 0,
+ 0, 0))
+ return 1;
+ if (test__muloti4(0,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 0, 0))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 0))
+ return 1;
+ if (test__muloti4(1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL), 0))
+ return 1;
+ if (test__muloti4(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 2,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+ if (test__muloti4(2,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL), 1))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/mulsc3_test.c b/test/builtins/Unit/mulsc3_test.c
new file mode 100644
index 000000000000..7a1b3ae0092d
--- /dev/null
+++ b/test/builtins/Unit/mulsc3_test.c
@@ -0,0 +1,370 @@
+//===-- mulsc3_test.c - Test __mulsc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulsc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the product of a + ib and c + id
+
+float _Complex __mulsc3(float __a, float __b, float __c, float __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(float _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(crealf(x)) || isinf(cimagf(x)))
+ return inf;
+ if (isnan(crealf(x)) && isnan(cimagf(x)))
+ return NaN;
+ if (isnan(crealf(x)))
+ {
+ if (cimagf(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagf(x)))
+ {
+ if (crealf(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__mulsc3(float a, float b, float c, float d)
+{
+ float _Complex r = __mulsc3(a, b, c, d);
+// printf("test__mulsc3(%f, %f, %f, %f) = %f + I%f\n",
+// a, b, c, d, crealf(r), cimagf(r));
+ float _Complex dividend;
+ float _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ {
+ float _Complex z = a * c - b * d + _Complex_I*(a * d + b * c);
+ // relaxed tolerance to arbitrary (1.e-6) amount.
+ if (cabsf((r-z)/r) > 1.e-6)
+ return 1;
+ }
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+float x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+int main()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__mulsc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/builtins/Unit/mulsf3vfp_test.c b/test/builtins/Unit/mulsf3vfp_test.c
new file mode 100644
index 000000000000..92cf1f128497
--- /dev/null
+++ b/test/builtins/Unit/mulsf3vfp_test.c
@@ -0,0 +1,50 @@
+//===-- mulsf3vfp_test.c - Test __mulsf3vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulsf3vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __mulsf3vfp(float a, float b);
+
+#if __arm__
+int test__mulsf3vfp(float a, float b)
+{
+ float actual = __mulsf3vfp(a, b);
+ float expected = a * b;
+ if (actual != expected)
+ printf("error in test__mulsf3vfp(%f, %f) = %f, expected %f\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__mulsf3vfp(0.5, 10.0))
+ return 1;
+ if (test__mulsf3vfp(-0.5, -2.0))
+ return 1;
+ if (test__mulsf3vfp(HUGE_VALF, 0.25))
+ return 1;
+ if (test__mulsf3vfp(-0.125, HUGE_VALF))
+ return 1;
+ if (test__mulsf3vfp(0.0, -0.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/multc3_test.c b/test/builtins/Unit/multc3_test.c
new file mode 100644
index 000000000000..f8c66c0e426f
--- /dev/null
+++ b/test/builtins/Unit/multc3_test.c
@@ -0,0 +1,374 @@
+//===-- multc3_test.c - Test __multc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __multc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#if _ARCH_PPC
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the product of a + ib and c + id
+
+long double _Complex
+__multc3(long double __a, long double __b, long double __c, long double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(long double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creall(x)) || isinf(cimagl(x)))
+ return inf;
+ if (isnan(creall(x)) && isnan(cimagl(x)))
+ return NaN;
+ if (isnan(creall(x)))
+ {
+ if (cimagl(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagl(x)))
+ {
+ if (creall(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__multc3(long double a, long double b, long double c, long double d)
+{
+ long double _Complex r = __multc3(a, b, c, d);
+// printf("test__multc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
+// a, b, c, d, creall(r), cimagl(r));
+ long double _Complex dividend;
+ long double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ if (r != a * c - b * d + _Complex_I*(a * d + b * c))
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+long double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+#endif
+
+int main()
+{
+#if _ARCH_PPC
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__multc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/multf3_test.c b/test/builtins/Unit/multf3_test.c
new file mode 100644
index 000000000000..89610056b27e
--- /dev/null
+++ b/test/builtins/Unit/multf3_test.c
@@ -0,0 +1,95 @@
+//===--------------- multf3_test.c - Test __multf3 ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __multf3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+// Returns: a * b
+long double __multf3(long double a, long double b);
+
+int test__multf3(long double a, long double b,
+ uint64_t expectedHi, uint64_t expectedLo)
+{
+ long double x = __multf3(a, b);
+ int ret = compareResultLD(x, expectedHi, expectedLo);
+
+ if (ret){
+ printf("error in test__multf3(%.20Lf, %.20Lf) = %.20Lf, "
+ "expected %.20Lf\n", a, b, x,
+ fromRep128(expectedHi, expectedLo));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LDBL_MANT_DIG__ == 113
+ // qNaN * any = qNaN
+ if (test__multf3(makeQNaN128(),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // NaN * any = NaN
+ if (test__multf3(makeNaN128(UINT64_C(0x800030000000)),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff800000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // inf * any = inf
+ if (test__multf3(makeInf128(),
+ 0x1.23456789abcdefp+5L,
+ UINT64_C(0x7fff000000000000),
+ UINT64_C(0x0)))
+ return 1;
+ // any * any
+ if (test__multf3(0x1.2eab345678439abcdefea56782346p+5L,
+ 0x1.edcb34a235253948765432134674fp-1L,
+ UINT64_C(0x400423e7f9e3c9fc),
+ UINT64_C(0xd906c2c2a85777c4)))
+ return 1;
+ if (test__multf3(0x1.353e45674d89abacc3a2ebf3ff4ffp-50L,
+ 0x1.ed8764648369535adf4be3214567fp-9L,
+ UINT64_C(0x3fc52a163c6223fc),
+ UINT64_C(0xc94c4bf0430768b4)))
+ return 1;
+ if (test__multf3(0x1.234425696abcad34a35eeffefdcbap+456L,
+ 0x451.ed98d76e5d46e5f24323dff21ffp+600L,
+ UINT64_C(0x44293a91de5e0e94),
+ UINT64_C(0xe8ed17cc2cdf64ac)))
+ return 1;
+ if (test__multf3(0x1.4356473c82a9fabf2d22ace345defp-234L,
+ 0x1.eda98765476743ab21da23d45678fp-455L,
+ UINT64_C(0x3d4f37c1a3137cae),
+ UINT64_C(0xfc6807048bc2836a)))
+ return 1;
+ // underflow
+ if (test__multf3(0x1.23456734245345p-10000L,
+ 0x1.edcba524498724p-6383L,
+ UINT64_C(0x0),
+ UINT64_C(0x0)))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/multi3_test.c b/test/builtins/Unit/multi3_test.c
new file mode 100644
index 000000000000..2ccbd06c3e7d
--- /dev/null
+++ b/test/builtins/Unit/multi3_test.c
@@ -0,0 +1,134 @@
+//===-- multi3_test.c - Test __multi3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __multi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+ti_int __multi3(ti_int a, ti_int b);
+
+int test__multi3(ti_int a, ti_int b, ti_int expected)
+{
+ ti_int x = __multi3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __multi3: 0x%.16llX%.16llX * 0x%.16llX%.16llX = "
+ "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__multi3(0, 0, 0))
+ return 1;
+ if (test__multi3(0, 1, 0))
+ return 1;
+ if (test__multi3(1, 0, 0))
+ return 1;
+ if (test__multi3(0, 10, 0))
+ return 1;
+ if (test__multi3(10, 0, 0))
+ return 1;
+ if (test__multi3(0, 81985529216486895LL, 0))
+ return 1;
+ if (test__multi3(81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__multi3(0, -1, 0))
+ return 1;
+ if (test__multi3(-1, 0, 0))
+ return 1;
+ if (test__multi3(0, -10, 0))
+ return 1;
+ if (test__multi3(-10, 0, 0))
+ return 1;
+ if (test__multi3(0, -81985529216486895LL, 0))
+ return 1;
+ if (test__multi3(-81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__multi3(1, 1, 1))
+ return 1;
+ if (test__multi3(1, 10, 10))
+ return 1;
+ if (test__multi3(10, 1, 10))
+ return 1;
+ if (test__multi3(1, 81985529216486895LL, 81985529216486895LL))
+ return 1;
+ if (test__multi3(81985529216486895LL, 1, 81985529216486895LL))
+ return 1;
+
+ if (test__multi3(1, -1, -1))
+ return 1;
+ if (test__multi3(1, -10, -10))
+ return 1;
+ if (test__multi3(-10, 1, -10))
+ return 1;
+ if (test__multi3(1, -81985529216486895LL, -81985529216486895LL))
+ return 1;
+ if (test__multi3(-81985529216486895LL, 1, -81985529216486895LL))
+ return 1;
+
+ if (test__multi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
+ return 1;
+ if (test__multi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__multi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__multi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
+ return 1;
+
+ if (test__multi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
+ return 1;
+ if (test__multi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__multi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__multi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__multi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
+ return 1;
+ if (test__multi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__multi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__multi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__multi3(make_ti(0x00000000000000B5LL, 0x04F333F9DE5BE000LL),
+ make_ti(0x0000000000000000LL, 0x00B504F333F9DE5BLL),
+ make_ti(0x7FFFFFFFFFFFF328LL, 0xDF915DA296E8A000LL)))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/mulvdi3_test.c b/test/builtins/Unit/mulvdi3_test.c
new file mode 100644
index 000000000000..a023bf611279
--- /dev/null
+++ b/test/builtins/Unit/mulvdi3_test.c
@@ -0,0 +1,175 @@
+//===-- mulvdi3_test.c - Test __mulvdi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulvdi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a * b
+
+// Effects: aborts if a * b overflows
+
+di_int __mulvdi3(di_int a, di_int b);
+
+int test__mulvdi3(di_int a, di_int b, di_int expected)
+{
+ di_int x = __mulvdi3(a, b);
+ if (x != expected)
+ printf("error in __mulvdi3: %lld * %lld = %lld, expected %lld\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+ if (test__mulvdi3(0, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 1, 0))
+ return 1;
+ if (test__mulvdi3(1, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 10, 0))
+ return 1;
+ if (test__mulvdi3(10, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 81985529216486895LL, 0))
+ return 1;
+ if (test__mulvdi3(81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__mulvdi3(0, -1, 0))
+ return 1;
+ if (test__mulvdi3(-1, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, -10, 0))
+ return 1;
+ if (test__mulvdi3(-10, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, -81985529216486895LL, 0))
+ return 1;
+ if (test__mulvdi3(-81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__mulvdi3(1, 1, 1))
+ return 1;
+ if (test__mulvdi3(1, 10, 10))
+ return 1;
+ if (test__mulvdi3(10, 1, 10))
+ return 1;
+ if (test__mulvdi3(1, 81985529216486895LL, 81985529216486895LL))
+ return 1;
+ if (test__mulvdi3(81985529216486895LL, 1, 81985529216486895LL))
+ return 1;
+
+ if (test__mulvdi3(1, -1, -1))
+ return 1;
+ if (test__mulvdi3(1, -10, -10))
+ return 1;
+ if (test__mulvdi3(-10, 1, -10))
+ return 1;
+ if (test__mulvdi3(1, -81985529216486895LL, -81985529216486895LL))
+ return 1;
+ if (test__mulvdi3(-81985529216486895LL, 1, -81985529216486895LL))
+ return 1;
+
+ if (test__mulvdi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
+ return 1;
+ if (test__mulvdi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__mulvdi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__mulvdi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
+ return 1;
+
+ if (test__mulvdi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__mulvdi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvdi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
+ return 1;
+
+// if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, -2, 0x8000000000000001LL)) // abort
+// return 1;
+// if (test__mulvdi3(-2, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL)) // abort
+// return 1;
+ if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, -1, 0x8000000000000001LL))
+ return 1;
+ if (test__mulvdi3(-1, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL))
+ return 1;
+ if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 0x7FFFFFFFFFFFFFFFLL, 0))
+ return 1;
+ if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 1, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__mulvdi3(1, 0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+// if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 2, 0x8000000000000001LL)) // abort
+// return 1;
+// if (test__mulvdi3(2, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL)) // abort
+// return 1;
+
+// if (test__mulvdi3(0x8000000000000000LL, -2, 0x8000000000000000LL)) // abort
+// return 1;
+// if (test__mulvdi3(-2, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
+// return 1;
+// if (test__mulvdi3(0x8000000000000000LL, -1, 0x8000000000000000LL)) // abort
+// return 1;
+// if (test__mulvdi3(-1, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
+// return 1;
+ if (test__mulvdi3(0x8000000000000000LL, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 0x8000000000000000LL, 0))
+ return 1;
+ if (test__mulvdi3(0x8000000000000000LL, 1, 0x8000000000000000LL))
+ return 1;
+ if (test__mulvdi3(1, 0x8000000000000000LL, 0x8000000000000000LL))
+ return 1;
+// if (test__mulvdi3(0x8000000000000000LL, 2, 0x8000000000000000LL)) // abort
+// return 1;
+// if (test__mulvdi3(2, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
+// return 1;
+
+// if (test__mulvdi3(0x8000000000000001LL, -2, 0x8000000000000001LL)) // abort
+// return 1;
+// if (test__mulvdi3(-2, 0x8000000000000001LL, 0x8000000000000001LL)) // abort
+// return 1;
+ if (test__mulvdi3(0x8000000000000001LL, -1, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__mulvdi3(-1, 0x8000000000000001LL, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__mulvdi3(0x8000000000000001LL, 0, 0))
+ return 1;
+ if (test__mulvdi3(0, 0x8000000000000001LL, 0))
+ return 1;
+ if (test__mulvdi3(0x8000000000000001LL, 1, 0x8000000000000001LL))
+ return 1;
+ if (test__mulvdi3(1, 0x8000000000000001LL, 0x8000000000000001LL))
+ return 1;
+// if (test__mulvdi3(0x8000000000000001LL, 2, 0x8000000000000000LL)) // abort
+// return 1;
+// if (test__mulvdi3(2, 0x8000000000000001LL, 0x8000000000000000LL)) // abort
+// return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/mulvsi3_test.c b/test/builtins/Unit/mulvsi3_test.c
new file mode 100644
index 000000000000..1eb53a5d5daa
--- /dev/null
+++ b/test/builtins/Unit/mulvsi3_test.c
@@ -0,0 +1,148 @@
+//===-- mulvsi3_test.c - Test __mulvsi3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulvsi3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: a * b
+
+// Effects: aborts if a * b overflows
+
+si_int __mulvsi3(si_int a, si_int b);
+
+int test__mulvsi3(si_int a, si_int b, si_int expected)
+{
+ si_int x = __mulvsi3(a, b);
+ if (x != expected)
+ printf("error in __mulvsi3: %d * %d = %d, expected %d\n",
+ a, b, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+ if (test__mulvsi3(0, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 1, 0))
+ return 1;
+ if (test__mulvsi3(1, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 10, 0))
+ return 1;
+ if (test__mulvsi3(10, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 0x1234567, 0))
+ return 1;
+ if (test__mulvsi3(0x1234567, 0, 0))
+ return 1;
+
+ if (test__mulvsi3(0, -1, 0))
+ return 1;
+ if (test__mulvsi3(-1, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, -10, 0))
+ return 1;
+ if (test__mulvsi3(-10, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, -0x1234567, 0))
+ return 1;
+ if (test__mulvsi3(-0x1234567, 0, 0))
+ return 1;
+
+ if (test__mulvsi3(1, 1, 1))
+ return 1;
+ if (test__mulvsi3(1, 10, 10))
+ return 1;
+ if (test__mulvsi3(10, 1, 10))
+ return 1;
+ if (test__mulvsi3(1, 0x1234567, 0x1234567))
+ return 1;
+ if (test__mulvsi3(0x1234567, 1, 0x1234567))
+ return 1;
+
+ if (test__mulvsi3(1, -1, -1))
+ return 1;
+ if (test__mulvsi3(1, -10, -10))
+ return 1;
+ if (test__mulvsi3(-10, 1, -10))
+ return 1;
+ if (test__mulvsi3(1, -0x1234567, -0x1234567))
+ return 1;
+ if (test__mulvsi3(-0x1234567, 1, -0x1234567))
+ return 1;
+
+// if (test__mulvsi3(0x7FFFFFFF, -2, 0x80000001)) // abort
+// return 1;
+// if (test__mulvsi3(-2, 0x7FFFFFFF, 0x80000001)) // abort
+// return 1;
+ if (test__mulvsi3(0x7FFFFFFF, -1, 0x80000001))
+ return 1;
+ if (test__mulvsi3(-1, 0x7FFFFFFF, 0x80000001))
+ return 1;
+ if (test__mulvsi3(0x7FFFFFFF, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 0x7FFFFFFF, 0))
+ return 1;
+ if (test__mulvsi3(0x7FFFFFFF, 1, 0x7FFFFFFF))
+ return 1;
+ if (test__mulvsi3(1, 0x7FFFFFFF, 0x7FFFFFFF))
+ return 1;
+// if (test__mulvsi3(0x7FFFFFFF, 2, 0x80000001)) // abort
+// return 1;
+// if (test__mulvsi3(2, 0x7FFFFFFF, 0x80000001)) // abort
+// return 1;
+
+// if (test__mulvsi3(0x80000000, -2, 0x80000000)) // abort
+// return 1;
+// if (test__mulvsi3(-2, 0x80000000, 0x80000000)) // abort
+// return 1;
+// if (test__mulvsi3(0x80000000, -1, 0x80000000)) // abort
+// return 1;
+// if (test__mulvsi3(-1, 0x80000000, 0x80000000)) // abort
+// return 1;
+ if (test__mulvsi3(0x80000000, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 0x80000000, 0))
+ return 1;
+ if (test__mulvsi3(0x80000000, 1, 0x80000000))
+ return 1;
+ if (test__mulvsi3(1, 0x80000000, 0x80000000))
+ return 1;
+// if (test__mulvsi3(0x80000000, 2, 0x80000000)) // abort
+// return 1;
+// if (test__mulvsi3(2, 0x80000000, 0x80000000)) // abort
+// return 1;
+
+// if (test__mulvsi3(0x80000001, -2, 0x80000001)) // abort
+// return 1;
+// if (test__mulvsi3(-2, 0x80000001, 0x80000001)) // abort
+// return 1;
+ if (test__mulvsi3(0x80000001, -1, 0x7FFFFFFF))
+ return 1;
+ if (test__mulvsi3(-1, 0x80000001, 0x7FFFFFFF))
+ return 1;
+ if (test__mulvsi3(0x80000001, 0, 0))
+ return 1;
+ if (test__mulvsi3(0, 0x80000001, 0))
+ return 1;
+ if (test__mulvsi3(0x80000001, 1, 0x80000001))
+ return 1;
+ if (test__mulvsi3(1, 0x80000001, 0x80000001))
+ return 1;
+// if (test__mulvsi3(0x80000001, 2, 0x80000000)) // abort
+// return 1;
+// if (test__mulvsi3(2, 0x80000001, 0x80000000)) // abort
+// return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/mulvti3_test.c b/test/builtins/Unit/mulvti3_test.c
new file mode 100644
index 000000000000..6336f4550e0d
--- /dev/null
+++ b/test/builtins/Unit/mulvti3_test.c
@@ -0,0 +1,260 @@
+//===-- mulvti3_test.c - Test __mulvti3 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulvti3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: a * b
+
+// Effects: aborts if a * b overflows
+
+ti_int __mulvti3(ti_int a, ti_int b);
+
+int test__mulvti3(ti_int a, ti_int b, ti_int expected)
+{
+ ti_int x = __mulvti3(a, b);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords bt;
+ bt.all = b;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __mulvti3: 0x%.16llX%.16llX * 0x%.16llX%.16llX = "
+ "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
+ expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__mulvti3(0, 0, 0))
+ return 1;
+ if (test__mulvti3(0, 1, 0))
+ return 1;
+ if (test__mulvti3(1, 0, 0))
+ return 1;
+ if (test__mulvti3(0, 10, 0))
+ return 1;
+ if (test__mulvti3(10, 0, 0))
+ return 1;
+ if (test__mulvti3(0, 81985529216486895LL, 0))
+ return 1;
+ if (test__mulvti3(81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__mulvti3(0, -1, 0))
+ return 1;
+ if (test__mulvti3(-1, 0, 0))
+ return 1;
+ if (test__mulvti3(0, -10, 0))
+ return 1;
+ if (test__mulvti3(-10, 0, 0))
+ return 1;
+ if (test__mulvti3(0, -81985529216486895LL, 0))
+ return 1;
+ if (test__mulvti3(-81985529216486895LL, 0, 0))
+ return 1;
+
+ if (test__mulvti3(1, 1, 1))
+ return 1;
+ if (test__mulvti3(1, 10, 10))
+ return 1;
+ if (test__mulvti3(10, 1, 10))
+ return 1;
+ if (test__mulvti3(1, 81985529216486895LL, 81985529216486895LL))
+ return 1;
+ if (test__mulvti3(81985529216486895LL, 1, 81985529216486895LL))
+ return 1;
+
+ if (test__mulvti3(1, -1, -1))
+ return 1;
+ if (test__mulvti3(1, -10, -10))
+ return 1;
+ if (test__mulvti3(-10, 1, -10))
+ return 1;
+ if (test__mulvti3(1, -81985529216486895LL, -81985529216486895LL))
+ return 1;
+ if (test__mulvti3(-81985529216486895LL, 1, -81985529216486895LL))
+ return 1;
+
+ if (test__mulvti3(3037000499LL, 3037000499LL, 9223372030926249001LL))
+ return 1;
+ if (test__mulvti3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__mulvti3(3037000499LL, -3037000499LL, -9223372030926249001LL))
+ return 1;
+ if (test__mulvti3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
+ return 1;
+
+ if (test__mulvti3(4398046511103LL, 2097152LL, 9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(4398046511103LL, -2097152LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__mulvti3(2097152LL, 4398046511103LL, 9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(2097152LL, -4398046511103LL, -9223372036852678656LL))
+ return 1;
+ if (test__mulvti3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
+ return 1;
+
+ if (test__mulvti3(make_ti(0x00000000000000B5LL, 0x04F333F9DE5BE000LL),
+ make_ti(0x0000000000000000LL, 0x00B504F333F9DE5BLL),
+ make_ti(0x7FFFFFFFFFFFF328LL, 0xDF915DA296E8A000LL)))
+ return 1;
+
+// if (test__mulvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// -2,
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+// if (test__mulvti3(-2,
+// make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+ if (test__mulvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ -1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__mulvti3(-1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__mulvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 0,
+ 0))
+ return 1;
+ if (test__mulvti3(0,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 0))
+ return 1;
+ if (test__mulvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ 1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__mulvti3(1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+// if (test__mulvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// 2,
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+// if (test__mulvti3(2,
+// make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+
+// if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// -2,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+// if (test__mulvti3(-2,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+// if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// -1,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+// if (test__mulvti3(-1,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+ if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 0,
+ 0))
+ return 1;
+ if (test__mulvti3(0,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 0))
+ return 1;
+ if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ 1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__mulvti3(1,
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+// if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// 2,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+// if (test__mulvti3(2,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+
+// if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+// -2,
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+// if (test__mulvti3(-2,
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL))) // abort
+// return 1;
+ if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ -1,
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__mulvti3(-1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 0,
+ 0))
+ return 1;
+ if (test__mulvti3(0,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 0))
+ return 1;
+ if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ 1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__mulvti3(1,
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+// if (test__mulvti3(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+// 2,
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+// if (test__mulvti3(2,
+// make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+// make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/mulxc3_test.c b/test/builtins/Unit/mulxc3_test.c
new file mode 100644
index 000000000000..4297c162bd8e
--- /dev/null
+++ b/test/builtins/Unit/mulxc3_test.c
@@ -0,0 +1,375 @@
+//===-- mulxc3_test.c - Test __mulxc3 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __mulxc3 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#if !_ARCH_PPC
+
+#include "int_lib.h"
+#include <math.h>
+#include <complex.h>
+#include <stdio.h>
+
+// Returns: the product of a + ib and c + id
+
+long double _Complex
+__mulxc3(long double __a, long double __b, long double __c, long double __d);
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+int
+classify(long double _Complex x)
+{
+ if (x == 0)
+ return zero;
+ if (isinf(creall(x)) || isinf(cimagl(x)))
+ return inf;
+ if (isnan(creall(x)) && isnan(cimagl(x)))
+ return NaN;
+ if (isnan(creall(x)))
+ {
+ if (cimagl(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagl(x)))
+ {
+ if (creall(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+int test__mulxc3(long double a, long double b, long double c, long double d)
+{
+ long double _Complex r = __mulxc3(a, b, c, d);
+// printf("test__mulxc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
+// a, b, c, d, creall(r), cimagl(r));
+ long double _Complex dividend;
+ long double _Complex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend))
+ {
+ case zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ if (r != a * c - b * d + _Complex_I*(a * d + b * c))
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor))
+ {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+long double x[][2] =
+{
+ { 1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ { 1.e-6, -1.e-6},
+
+ { 1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ { 1.e+6, -1.e-6},
+
+ { 1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ { 1.e-6, -1.e+6},
+
+ { 1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ { 1.e+6, -1.e+6},
+
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
+
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
+
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
+
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
+
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
+
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
+
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
+
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
+
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
+
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
+
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
+
+};
+
+#endif
+
+int main()
+{
+#if !_ARCH_PPC
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ unsigned i, j;
+ for (i = 0; i < N; ++i)
+ {
+ for (j = 0; j < N; ++j)
+ {
+ if (test__mulxc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+ return 1;
+ }
+ }
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/nedf2vfp_test.c b/test/builtins/Unit/nedf2vfp_test.c
new file mode 100644
index 000000000000..2c4404399633
--- /dev/null
+++ b/test/builtins/Unit/nedf2vfp_test.c
@@ -0,0 +1,51 @@
+//===-- nedf2vfp_test.c - Test __nedf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __nedf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __nedf2vfp(double a, double b);
+
+#if __arm__
+int test__nedf2vfp(double a, double b)
+{
+ int actual = __nedf2vfp(a, b);
+ int expected = (a != b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __nedf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__nedf2vfp(0.0, 0.0))
+ return 1;
+ if (test__nedf2vfp(1.0, 1.0))
+ return 1;
+ if (test__nedf2vfp(-1.0, -1.0))
+ return 1;
+ if (test__nedf2vfp(HUGE_VAL, 1.0))
+ return 1;
+ if (test__nedf2vfp(1.0, HUGE_VAL))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/negdf2vfp_test.c b/test/builtins/Unit/negdf2vfp_test.c
new file mode 100644
index 000000000000..dc55428d6780
--- /dev/null
+++ b/test/builtins/Unit/negdf2vfp_test.c
@@ -0,0 +1,48 @@
+//===-- negdf2vfp_test.c - Test __negdf2vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negdf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern double __negdf2vfp(double a);
+
+#if __arm__
+int test__negdf2vfp(double a)
+{
+ double actual = __negdf2vfp(a);
+ double expected = -a;
+ if (actual != expected)
+ printf("error in test__negdf2vfp(%f) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__negdf2vfp(1.0))
+ return 1;
+ if (test__negdf2vfp(HUGE_VALF))
+ return 1;
+ if (test__negdf2vfp(0.0))
+ return 1;
+ if (test__negdf2vfp(-1.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/negdi2_test.c b/test/builtins/Unit/negdi2_test.c
new file mode 100644
index 000000000000..510b3b046b56
--- /dev/null
+++ b/test/builtins/Unit/negdi2_test.c
@@ -0,0 +1,84 @@
+//===-- negdi2_test.c - Test __negdi2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: -a
+
+di_int __negdi2(di_int a);
+
+int test__negdi2(di_int a, di_int expected)
+{
+ di_int x = __negdi2(a);
+ if (x != expected)
+ printf("error in __negdi2: -0x%llX = 0x%llX, expected 0x%llX\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+
+int main()
+{
+ if (test__negdi2(0, 0))
+ return 1;
+ if (test__negdi2(1, -1))
+ return 1;
+ if (test__negdi2(-1, 1))
+ return 1;
+ if (test__negdi2(2, -2))
+ return 1;
+ if (test__negdi2(-2, 2))
+ return 1;
+ if (test__negdi2(3, -3))
+ return 1;
+ if (test__negdi2(-3, 3))
+ return 1;
+ if (test__negdi2(0x00000000FFFFFFFELL, 0xFFFFFFFF00000002LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFF00000002LL, 0x00000000FFFFFFFELL))
+ return 1;
+ if (test__negdi2(0x00000000FFFFFFFFLL, 0xFFFFFFFF00000001LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFF00000001LL, 0x00000000FFFFFFFFLL))
+ return 1;
+ if (test__negdi2(0x0000000100000000LL, 0xFFFFFFFF00000000LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFF00000000LL, 0x0000000100000000LL))
+ return 1;
+ if (test__negdi2(0x0000000200000000LL, 0xFFFFFFFE00000000LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFE00000000LL, 0x0000000200000000LL))
+ return 1;
+ if (test__negdi2(0x0000000300000000LL, 0xFFFFFFFD00000000LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFD00000000LL, 0x0000000300000000LL))
+ return 1;
+ if (test__negdi2(0x8000000000000000LL, 0x8000000000000000LL))
+ return 1;
+ if (test__negdi2(0x8000000000000001LL, 0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__negdi2(0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFE00000000LL, 0x0000000200000000LL))
+ return 1;
+ if (test__negdi2(0x0000000200000000LL, 0xFFFFFFFE00000000LL))
+ return 1;
+ if (test__negdi2(0xFFFFFFFF00000000LL, 0x0000000100000000LL))
+ return 1;
+ if (test__negdi2(0x0000000100000000LL, 0xFFFFFFFF00000000LL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/negsf2vfp_test.c b/test/builtins/Unit/negsf2vfp_test.c
new file mode 100644
index 000000000000..ef54cee1dbee
--- /dev/null
+++ b/test/builtins/Unit/negsf2vfp_test.c
@@ -0,0 +1,48 @@
+//===-- negsf2vfp_test.c - Test __negsf2vfp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negsf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __negsf2vfp(float a);
+
+#if __arm__
+int test__negsf2vfp(float a)
+{
+ float actual = __negsf2vfp(a);
+ float expected = -a;
+ if (actual != expected)
+ printf("error in test__negsf2vfp(%f) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__negsf2vfp(1.0))
+ return 1;
+ if (test__negsf2vfp(HUGE_VALF))
+ return 1;
+ if (test__negsf2vfp(0.0))
+ return 1;
+ if (test__negsf2vfp(-1.0))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/negti2_test.c b/test/builtins/Unit/negti2_test.c
new file mode 100644
index 000000000000..a40c0c324bb2
--- /dev/null
+++ b/test/builtins/Unit/negti2_test.c
@@ -0,0 +1,127 @@
+//===-- negti2_test.c - Test __negti2 -------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: -a
+
+ti_int __negti2(ti_int a);
+
+int test__negti2(ti_int a, ti_int expected)
+{
+ ti_int x = __negti2(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, "
+ "expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__negti2(0, 0))
+ return 1;
+ if (test__negti2(1, -1))
+ return 1;
+ if (test__negti2(-1, 1))
+ return 1;
+ if (test__negti2(2, -2))
+ return 1;
+ if (test__negti2(-2, 2))
+ return 1;
+ if (test__negti2(3, -3))
+ return 1;
+ if (test__negti2(-3, 3))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL),
+ make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL),
+ make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000300000000LL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000300000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL),
+ make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL),
+ make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL),
+ make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
+ make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
+ return 1;
+ if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
+ make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
+ make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/negvdi2_test.c b/test/builtins/Unit/negvdi2_test.c
new file mode 100644
index 000000000000..9617b95ff105
--- /dev/null
+++ b/test/builtins/Unit/negvdi2_test.c
@@ -0,0 +1,57 @@
+//===-- negvdi2_test.c - Test __negvdi2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negvdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: -a
+
+// Effects: aborts if -a overflows
+
+di_int __negvdi2(di_int a);
+
+int test__negvdi2(di_int a)
+{
+ di_int x = __negvdi2(a);
+ di_int expected = -a;
+ if (x != expected)
+ printf("error in __negvdi2(0x%llX) = %lld, expected %lld\n",
+ a, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// if (test__negvdi2(0x8000000000000000LL)) // should abort
+// return 1;
+ if (test__negvdi2(0x0000000000000000LL))
+ return 1;
+ if (test__negvdi2(0x0000000000000001LL))
+ return 1;
+ if (test__negvdi2(0x0000000000000002LL))
+ return 1;
+ if (test__negvdi2(0x7FFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__negvdi2(0x7FFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__negvdi2(0x8000000000000001LL))
+ return 1;
+ if (test__negvdi2(0x8000000000000002LL))
+ return 1;
+ if (test__negvdi2(0xFFFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__negvdi2(0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/negvsi2_test.c b/test/builtins/Unit/negvsi2_test.c
new file mode 100644
index 000000000000..5ea0e2e86c2a
--- /dev/null
+++ b/test/builtins/Unit/negvsi2_test.c
@@ -0,0 +1,56 @@
+//===-- negvsi2_test.c - Test __negvsi2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negvsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+// Returns: -a
+
+// Effects: aborts if -a overflows
+
+si_int __negvsi2(si_int a);
+
+int test__negvsi2(si_int a)
+{
+ si_int x = __negvsi2(a);
+ si_int expected = -a;
+ if (x != expected)
+ printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected);
+ return x != expected;
+}
+
+int main()
+{
+// if (test__negvsi2(0x80000000)) // should abort
+// return 1;
+ if (test__negvsi2(0x00000000))
+ return 1;
+ if (test__negvsi2(0x00000001))
+ return 1;
+ if (test__negvsi2(0x00000002))
+ return 1;
+ if (test__negvsi2(0x7FFFFFFE))
+ return 1;
+ if (test__negvsi2(0x7FFFFFFF))
+ return 1;
+ if (test__negvsi2(0x80000001))
+ return 1;
+ if (test__negvsi2(0x80000002))
+ return 1;
+ if (test__negvsi2(0xFFFFFFFE))
+ return 1;
+ if (test__negvsi2(0xFFFFFFFF))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/negvti2_test.c b/test/builtins/Unit/negvti2_test.c
new file mode 100644
index 000000000000..8126cdb5b668
--- /dev/null
+++ b/test/builtins/Unit/negvti2_test.c
@@ -0,0 +1,109 @@
+//===-- negvti2_test.c - Test __negvti2 -----------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __negvti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: -a
+
+// Effects: aborts if -a overflows
+
+ti_int __negvti2(ti_int a);
+ti_int __negti2(ti_int a);
+
+int test__negvti2(ti_int a)
+{
+ ti_int x = __negvti2(a);
+ ti_int expected = __negti2(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ twords xt;
+ xt.all = x;
+ twords expectedt;
+ expectedt.all = expected;
+ printf("error in __negvti2(0x%.16llX%.16llX) = 0x%.16llX%.16llX, "
+ "expected 0x%.16llX%.16llX\n",
+ at.s.high, at.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
+ }
+ return x != expected;
+}
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__negvti2(0))
+ return 1;
+ if (test__negvti2(1))
+ return 1;
+ if (test__negvti2(-1))
+ return 1;
+ if (test__negvti2(2))
+ return 1;
+ if (test__negvti2(-2))
+ return 1;
+ if (test__negvti2(3))
+ return 1;
+ if (test__negvti2(-3))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000300000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
+ return 1;
+// if (test__negvti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
+// return 1;
+ if (test__negvti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
+ return 1;
+ if (test__negvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/nesf2vfp_test.c b/test/builtins/Unit/nesf2vfp_test.c
new file mode 100644
index 000000000000..c085bf8b41fa
--- /dev/null
+++ b/test/builtins/Unit/nesf2vfp_test.c
@@ -0,0 +1,51 @@
+//===-- nesf2vfp_test.c - Test __nesf2vfp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __nesf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <math.h>
+
+
+extern int __nesf2vfp(float a, float b);
+
+#if __arm__
+int test__nesf2vfp(float a, float b)
+{
+ int actual = __nesf2vfp(a, b);
+ int expected = (a != b) ? 1 : 0;
+ if (actual != expected)
+ printf("error in __nesf2vfp(%f, %f) = %d, expected %d\n",
+ a, b, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__nesf2vfp(0.0, 0.0))
+ return 1;
+ if (test__nesf2vfp(1.0, 1.0))
+ return 1;
+ if (test__nesf2vfp(-1.0, -1.0))
+ return 1;
+ if (test__nesf2vfp(HUGE_VALF, 1.0))
+ return 1;
+ if (test__nesf2vfp(1.0, HUGE_VALF))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/netf2_test.c b/test/builtins/Unit/netf2_test.c
new file mode 100644
index 000000000000..bbd953ab59e2
--- /dev/null
+++ b/test/builtins/Unit/netf2_test.c
@@ -0,0 +1,89 @@
+//===------------ netf2_test.c - Test __netf2------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __netf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+
+#include "fp_test.h"
+
+int __netf2(long double a, long double b);
+
+int test__netf2(long double a, long double b, enum EXPECTED_RESULT expected)
+{
+ int x = __netf2(a, b);
+ int ret = compareResultCMP(x, expected);
+
+ if (ret){
+ printf("error in test__netf2(%.20Lf, %.20Lf) = %d, "
+ "expected %s\n", a, b, x, expectedStr(expected));
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if __LP64__ && __LDBL_MANT_DIG__ == 113
+ // NaN
+ if (test__netf2(makeQNaN128(),
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // <
+ // exp
+ if (test__netf2(0x1.234567890abcdef1234567890abcp-3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // mantissa
+ if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.334567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // sign
+ if (test__netf2(-0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // ==
+ if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ EQUAL_0))
+ return 1;
+ // >
+ // exp
+ if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp-3L,
+ NEQUAL_0))
+ return 1;
+ // mantissa
+ if (test__netf2(0x1.334567890abcdef1234567890abcp+3L,
+ 0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+ // sign
+ if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
+ -0x1.234567890abcdef1234567890abcp+3L,
+ NEQUAL_0))
+ return 1;
+
+#else
+ printf("skipped\n");
+
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/paritydi2_test.c b/test/builtins/Unit/paritydi2_test.c
new file mode 100644
index 000000000000..5360e374d439
--- /dev/null
+++ b/test/builtins/Unit/paritydi2_test.c
@@ -0,0 +1,51 @@
+//===-- paritydi2_test.c - Test __paritydi2 -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __paritydi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: 1 if number of bits is odd else returns 0
+
+si_int __paritydi2(di_int a);
+
+int naive_parity(di_int a)
+{
+ int r = 0;
+ for (; a; a = a & (a - 1))
+ r = ~r;
+ return r & 1;
+}
+
+int test__paritydi2(di_int a)
+{
+ si_int x = __paritydi2(a);
+ si_int expected = naive_parity(a);
+ if (x != expected)
+ printf("error in __paritydi2(0x%llX) = %d, expected %d\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__paritydi2(((di_int)rand() << 32) + rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/paritysi2_test.c b/test/builtins/Unit/paritysi2_test.c
new file mode 100644
index 000000000000..3ea8473aad5c
--- /dev/null
+++ b/test/builtins/Unit/paritysi2_test.c
@@ -0,0 +1,50 @@
+//===-- paritysi2_test.c - Test __paritysi2 -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __paritysi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: 1 if number of bits is odd else returns 0
+
+si_int __paritysi2(si_int a);
+
+int naive_parity(si_int a)
+{
+ int r = 0;
+ for (; a; a = a & (a - 1))
+ r = ~r;
+ return r & 1;
+}
+
+int test__paritysi2(si_int a)
+{
+ si_int x = __paritysi2(a);
+ si_int expected = naive_parity(a);
+ if (x != expected)
+ printf("error in __paritysi2(0x%X) = %d, expected %d\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__paritysi2(rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/parityti2_test.c b/test/builtins/Unit/parityti2_test.c
new file mode 100644
index 000000000000..8f065b953d22
--- /dev/null
+++ b/test/builtins/Unit/parityti2_test.c
@@ -0,0 +1,64 @@
+//===-- parityti2_test.c - Test __parityti2 -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __parityti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: 1 if number of bits is odd else returns 0
+
+si_int __parityti2(ti_int a);
+
+int naive_parity(ti_int a)
+{
+ int r = 0;
+ for (; a; a = a & (a - 1))
+ r = ~r;
+ return r & 1;
+}
+
+int test__parityti2(ti_int a)
+{
+ si_int x = __parityti2(a);
+ si_int expected = naive_parity(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __parityti2(0x%.16llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__parityti2(((ti_int)rand() << 96) + ((ti_int)rand() << 64) +
+ ((ti_int)rand() << 32) + rand()))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/popcountdi2_test.c b/test/builtins/Unit/popcountdi2_test.c
new file mode 100644
index 000000000000..4c5611796434
--- /dev/null
+++ b/test/builtins/Unit/popcountdi2_test.c
@@ -0,0 +1,63 @@
+//===-- popcountdi2_test.c - Test __popcountdi2 ----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __popcountdi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: count of 1 bits
+
+si_int __popcountdi2(di_int a);
+
+int naive_popcount(di_int a)
+{
+ int r = 0;
+ for (; a; a = (du_int)a >> 1)
+ r += a & 1;
+ return r;
+}
+
+int test__popcountdi2(di_int a)
+{
+ si_int x = __popcountdi2(a);
+ si_int expected = naive_popcount(a);
+ if (x != expected)
+ printf("error in __popcountdi2(0x%llX) = %d, expected %d\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__popcountdi2(0))
+ return 1;
+ if (test__popcountdi2(1))
+ return 1;
+ if (test__popcountdi2(2))
+ return 1;
+ if (test__popcountdi2(0xFFFFFFFFFFFFFFFDLL))
+ return 1;
+ if (test__popcountdi2(0xFFFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__popcountdi2(0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__popcountdi2(((di_int)rand() << 32) | rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/popcountsi2_test.c b/test/builtins/Unit/popcountsi2_test.c
new file mode 100644
index 000000000000..d0a05c45e544
--- /dev/null
+++ b/test/builtins/Unit/popcountsi2_test.c
@@ -0,0 +1,62 @@
+//===-- popcountsi2_test.c - Test __popcountsi2 ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __popcountsi2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+// Returns: count of 1 bits
+
+si_int __popcountsi2(si_int a);
+
+int naive_popcount(si_int a)
+{
+ int r = 0;
+ for (; a; a = (su_int)a >> 1)
+ r += a & 1;
+ return r;
+}
+
+int test__popcountsi2(si_int a)
+{
+ si_int x = __popcountsi2(a);
+ si_int expected = naive_popcount(a);
+ if (x != expected)
+ printf("error in __popcountsi2(0x%X) = %d, expected %d\n",
+ a, x, expected);
+ return x != expected;
+}
+
+char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
+
+int main()
+{
+ if (test__popcountsi2(0))
+ return 1;
+ if (test__popcountsi2(1))
+ return 1;
+ if (test__popcountsi2(2))
+ return 1;
+ if (test__popcountsi2(0xFFFFFFFD))
+ return 1;
+ if (test__popcountsi2(0xFFFFFFFE))
+ return 1;
+ if (test__popcountsi2(0xFFFFFFFF))
+ return 1;
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__popcountsi2(rand()))
+ return 1;
+
+ return 0;
+}
diff --git a/test/builtins/Unit/popcountti2_test.c b/test/builtins/Unit/popcountti2_test.c
new file mode 100644
index 000000000000..d17e03afd665
--- /dev/null
+++ b/test/builtins/Unit/popcountti2_test.c
@@ -0,0 +1,82 @@
+//===-- popcountti2_test.c - Test __popcountti2 ----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __popcountti2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CRT_HAS_128BIT
+
+// Returns: count of 1 bits
+
+si_int __popcountti2(ti_int a);
+
+int naive_popcount(ti_int a)
+{
+ int r = 0;
+ for (; a; a = (tu_int)a >> 1)
+ r += a & 1;
+ return r;
+}
+
+int test__popcountti2(ti_int a)
+{
+ si_int x = __popcountti2(a);
+ si_int expected = naive_popcount(a);
+ if (x != expected)
+ {
+ twords at;
+ at.all = a;
+ printf("error in __popcountti2(0x%.16llX%.16llX) = %d, expected %d\n",
+ at.s.high, at.s.low, x, expected);
+ }
+ return x != expected;
+}
+
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
+char assumption_2[sizeof(di_int)*CHAR_BIT == 64] = {0};
+
+#endif
+
+int main()
+{
+#ifdef CRT_HAS_128BIT
+ if (test__popcountti2(0))
+ return 1;
+ if (test__popcountti2(1))
+ return 1;
+ if (test__popcountti2(2))
+ return 1;
+ if (test__popcountti2(0xFFFFFFFFFFFFFFFDLL))
+ return 1;
+ if (test__popcountti2(0xFFFFFFFFFFFFFFFELL))
+ return 1;
+ if (test__popcountti2(0xFFFFFFFFFFFFFFFFLL))
+ return 1;
+ if (test__popcountti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFDLL)))
+ return 1;
+ if (test__popcountti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFELL)))
+ return 1;
+ if (test__popcountti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
+ return 1;
+ int i;
+ for (i = 0; i < 10000; ++i)
+ if (test__popcountti2(((ti_int)rand() << 96) | ((ti_int)rand() << 64) |
+ ((ti_int)rand() << 32) | rand()))
+ return 1;
+
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}
diff --git a/test/builtins/Unit/powidf2_test.c b/test/builtins/Unit/powidf2_test.c
new file mode 100644
index 000000000000..2abc84de7676
--- /dev/null
+++ b/test/builtins/Unit/powidf2_test.c
@@ -0,0 +1,224 @@
+//===-- powidf2_test.cpp - Test __powidf2 ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __powidf2 for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+#include <stdio.h>
+#include <math.h>
+
+// Returns: a ^ b
+
+double __powidf2(double a, si_int b);
+
+int test__powidf2(double a, si_int b, double expected)
+{
+ double x = __powidf2(a, b);
+ int correct = (x == expected) && (signbit(x) == signbit(expected));
+ if (!correct)
+ printf("error in __powidf2(%f, %d) = %f, expected %f\n",
+ a, b, x, expected);
+ return !correct;
+}
+
+int main()
+{
+ if (test__powidf2(0, 0, 1))
+ return 1;
+ if (test__powidf2(1, 0, 1))
+ return 1;
+ if (test__powidf2(1.5, 0, 1))
+ return 1;
+ if (test__powidf2(2, 0, 1))
+ return 1;
+ if (test__powidf2(INFINITY, 0, 1))
+ return 1;
+
+ if (test__powidf2(-0., 0, 1))
+ return 1;
+ if (test__powidf2(-1, 0, 1))
+ return 1;
+ if (test__powidf2(-1.5, 0, 1))
+ return 1;
+ if (test__powidf2(-2, 0, 1))
+ return 1;
+ if (test__powidf2(-INFINITY, 0, 1))
+ return 1;
+
+ if (test__powidf2(0, 1, 0))
+ return 1;
+ if (test__powidf2(0, 2, 0))
+ return 1;
+ if (test__powidf2(0, 3, 0))
+ return 1;
+ if (test__powidf2(0, 4, 0))
+ return 1;
+ if (test__powidf2(0, 0x7FFFFFFE, 0))
+ return 1;
+ if (test__powidf2(0, 0x7FFFFFFF, 0))
+ return 1;
+
+ if (test__powidf2(-0., 1, -0.))
+ return 1;
+ if (test__powidf2(-0., 2, 0))
+ return 1;
+ if (test__powidf2(-0., 3, -0.))
+ return 1;
+ if (test__powidf2(-0., 4, 0))
+ return 1;
+ if (test__powidf2(-0., 0x7FFFFFFE, 0))
+ return 1;
+ if (test__powidf2(-0., 0x7FFFFFFF, -0.))
+ return 1;
+
+ if (test__powidf2(1, 1, 1))
+ return 1;
+ if (test__powidf2(1, 2, 1))
+ return 1;
+ if (test__powidf2(1, 3, 1))
+ return 1;
+ if (test__powidf2(1, 4, 1))
+ return 1;
+ if (test__powidf2(1, 0x7FFFFFFE, 1))
+ return 1;
+ if (test__powidf2(1, 0x7FFFFFFF, 1))
+ return 1;
+
+ if (test__powidf2(INFINITY, 1, INFINITY))
+ return 1;
+ if (test__powidf2(INFINITY, 2, INFINITY))
+ return 1;