1 //===-- muldi3_test.c - Test __muldi3 -------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file tests __muldi3 for the compiler_rt library. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "int_lib.h" 15 #include <stdio.h> 16 17 di_int __muldi3(di_int a, di_int b); 18 19 int test__muldi3(di_int a, di_int b, di_int expected) 20 { 21 di_int x = __muldi3(a, b); 22 if (x != expected) 23 printf("error in __muldi3: %lld * %lld = %lld, expected %lld\n", 24 a, b, __muldi3(a, b), expected); 25 return x != expected; 26 } 27 28 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0}; 29 30 int main() 31 { 32 if (test__muldi3(0, 0, 0)) 33 return 1; 34 if (test__muldi3(0, 1, 0)) 35 return 1; 36 if (test__muldi3(1, 0, 0)) 37 return 1; 38 if (test__muldi3(0, 10, 0)) 39 return 1; 40 if (test__muldi3(10, 0, 0)) 41 return 1; 42 if (test__muldi3(0, 81985529216486895LL, 0)) 43 return 1; 44 if (test__muldi3(81985529216486895LL, 0, 0)) 45 return 1; 46 47 if (test__muldi3(0, -1, 0)) 48 return 1; 49 if (test__muldi3(-1, 0, 0)) 50 return 1; 51 if (test__muldi3(0, -10, 0)) 52 return 1; 53 if (test__muldi3(-10, 0, 0)) 54 return 1; 55 if (test__muldi3(0, -81985529216486895LL, 0)) 56 return 1; 57 if (test__muldi3(-81985529216486895LL, 0, 0)) 58 return 1; 59 60 if (test__muldi3(1, 1, 1)) 61 return 1; 62 if (test__muldi3(1, 10, 10)) 63 return 1; 64 if (test__muldi3(10, 1, 10)) 65 return 1; 66 if (test__muldi3(1, 81985529216486895LL, 81985529216486895LL)) 67 return 1; 68 if (test__muldi3(81985529216486895LL, 1, 81985529216486895LL)) 69 return 1; 70 71 if (test__muldi3(1, -1, -1)) 72 return 1; 73 if (test__muldi3(1, -10, -10)) 74 return 1; 75 if (test__muldi3(-10, 1, -10)) 76 return 1; 77 if (test__muldi3(1, -81985529216486895LL, -81985529216486895LL)) 78 return 1; 79 if (test__muldi3(-81985529216486895LL, 1, -81985529216486895LL)) 80 return 1; 81 82 if (test__muldi3(3037000499LL, 3037000499LL, 9223372030926249001LL)) 83 return 1; 84 if (test__muldi3(-3037000499LL, 3037000499LL, -9223372030926249001LL)) 85 return 1; 86 if (test__muldi3(3037000499LL, -3037000499LL, -9223372030926249001LL)) 87 return 1; 88 if (test__muldi3(-3037000499LL, -3037000499LL, 9223372030926249001LL)) 89 return 1; 90 91 if (test__muldi3(4398046511103LL, 2097152LL, 9223372036852678656LL)) 92 return 1; 93 if (test__muldi3(-4398046511103LL, 2097152LL, -9223372036852678656LL)) 94 return 1; 95 if (test__muldi3(4398046511103LL, -2097152LL, -9223372036852678656LL)) 96 return 1; 97 if (test__muldi3(-4398046511103LL, -2097152LL, 9223372036852678656LL)) 98 return 1; 99 100 if (test__muldi3(2097152LL, 4398046511103LL, 9223372036852678656LL)) 101 return 1; 102 if (test__muldi3(-2097152LL, 4398046511103LL, -9223372036852678656LL)) 103 return 1; 104 if (test__muldi3(2097152LL, -4398046511103LL, -9223372036852678656LL)) 105 return 1; 106 if (test__muldi3(-2097152LL, -4398046511103LL, 9223372036852678656LL)) 107 return 1; 108 109 return 0; 110 } 111