Index: lib/builtins/fp_lib.h =================================================================== --- lib/builtins/fp_lib.h +++ lib/builtins/fp_lib.h @@ -67,7 +67,7 @@ #define significandBits 52 static __inline int rep_clz(rep_t a) { -#if defined __LP64__ +#if defined(__LP64__) || defined(_WIN64) return __builtin_clzl(a); #else if (a & REP_C(0xffffffff00000000)) Index: lib/builtins/int_lib.h =================================================================== --- lib/builtins/int_lib.h +++ lib/builtins/int_lib.h @@ -88,6 +88,7 @@ COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem); #ifdef CRT_HAS_128BIT COMPILER_RT_ABI si_int __clzti2(ti_int a); +COMPILER_RT_ABI ti_int __divti3(ti_int a, ti_int b); COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); #endif Index: lib/builtins/int_types.h =================================================================== --- lib/builtins/int_types.h +++ lib/builtins/int_types.h @@ -60,7 +60,8 @@ }s; } udwords; -#if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) +#if (defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \ + (defined(_MSC_VER) && defined(_WIN64))) #define CRT_HAS_128BIT #endif Index: lib/builtins/muloti4.c =================================================================== --- lib/builtins/muloti4.c +++ lib/builtins/muloti4.c @@ -48,12 +48,12 @@ return result; if (sa == sb) { - if (abs_a > MAX / abs_b) + if (abs_a > __divti3(MAX, abs_b)) *overflow = 1; } else { - if (abs_a > MIN / -abs_b) + if (abs_a > __divti3(MIN, -abs_b)) *overflow = 1; } return result; Index: lib/builtins/mulvti3.c =================================================================== --- lib/builtins/mulvti3.c +++ lib/builtins/mulvti3.c @@ -46,12 +46,12 @@ return a * b; if (sa == sb) { - if (abs_a > MAX / abs_b) + if (abs_a > __divti3(MAX, abs_b)) compilerrt_abort(); } else { - if (abs_a > MIN / -abs_b) + if (abs_a > __divti3(MIN, -abs_b)) compilerrt_abort(); } return a * b; Index: test/builtins/Unit/fixunsdfti_test.c =================================================================== --- test/builtins/Unit/fixunsdfti_test.c +++ test/builtins/Unit/fixunsdfti_test.c @@ -99,13 +99,13 @@ return 1; #endif - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800ULL)) return 1; - if (test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000LL)) + if (test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000ULL)) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00ULL)) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800ULL)) return 1; if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, make_ti(0xFFFFFFFFFFFFF800LL, 0))) Index: test/builtins/Unit/fixunssfti_test.c =================================================================== --- test/builtins/Unit/fixunssfti_test.c +++ test/builtins/Unit/fixunssfti_test.c @@ -87,13 +87,13 @@ return 1; #endif - if (test__fixunssfti(0x1.FFFFFEp+63F, 0xFFFFFF0000000000LL)) + if (test__fixunssfti(0x1.FFFFFEp+63F, 0xFFFFFF0000000000ULL)) return 1; - if (test__fixunssfti(0x1.000000p+63F, 0x8000000000000000LL)) + if (test__fixunssfti(0x1.000000p+63F, 0x8000000000000000ULL)) return 1; - if (test__fixunssfti(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL)) + if (test__fixunssfti(0x1.FFFFFEp+62F, 0x7FFFFF8000000000ULL)) return 1; - if (test__fixunssfti(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL)) + if (test__fixunssfti(0x1.FFFFFCp+62F, 0x7FFFFF0000000000ULL)) return 1; if (test__fixunssfti(0x1.FFFFFEp+127F, make_ti(0xFFFFFF0000000000LL, 0))) Index: test/builtins/Unit/fixunsxfti_test.c =================================================================== --- test/builtins/Unit/fixunsxfti_test.c +++ test/builtins/Unit/fixunsxfti_test.c @@ -55,7 +55,7 @@ int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && !defined(_MSC_VER) if (test__fixunsxfti(0.0, 0)) return 1; Index: test/builtins/Unit/fixxfti_test.c =================================================================== --- test/builtins/Unit/fixxfti_test.c +++ test/builtins/Unit/fixxfti_test.c @@ -53,7 +53,7 @@ int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && !defined(_MSC_VER) if (test__fixxfti(0.0, 0)) return 1; Index: test/builtins/Unit/floattixf_test.c =================================================================== --- test/builtins/Unit/floattixf_test.c +++ test/builtins/Unit/floattixf_test.c @@ -51,7 +51,7 @@ int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && !defined(_MSC_VER) if (test__floattixf(0, 0.0)) return 1; Index: test/builtins/Unit/floatuntisf_test.c =================================================================== --- test/builtins/Unit/floatuntisf_test.c +++ test/builtins/Unit/floatuntisf_test.c @@ -92,9 +92,9 @@ if (test__floatuntisf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50F)) return 1; - if (test__floatuntisf(0xFFFFFFFFFFFFFFFELL, 0x1p+64F)) + if (test__floatuntisf(0xFFFFFFFFFFFFFFFEULL, 0x1p+64F)) return 1; - if (test__floatuntisf(0xFFFFFFFFFFFFFFFFLL, 0x1p+64F)) + if (test__floatuntisf(0xFFFFFFFFFFFFFFFFULL, 0x1p+64F)) return 1; if (test__floatuntisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F)) Index: test/builtins/Unit/floatuntixf_test.c =================================================================== --- test/builtins/Unit/floatuntixf_test.c +++ test/builtins/Unit/floatuntixf_test.c @@ -51,7 +51,7 @@ int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && !defined(_MSC_VER) if (test__floatuntixf(0, 0.0)) return 1; Index: test/builtins/Unit/modti3_test.c =================================================================== --- test/builtins/Unit/modti3_test.c +++ test/builtins/Unit/modti3_test.c @@ -63,17 +63,17 @@ if (test__modti3(-5, -3, -2)) return 1; - if (test__modti3(0x8000000000000000LL, 1, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, 1, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, -1, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, -1, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, 2, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, 2, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, -2, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, -2, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, 3, 2)) + if (test__modti3(0x8000000000000000ULL, 3, 2)) return 1; - if (test__modti3(0x8000000000000000LL, -3, 2)) + if (test__modti3(0x8000000000000000ULL, -3, 2)) return 1; if (test__modti3(make_ti(0x8000000000000000LL, 0), 1, 0x0LL))