1 //===-- mulvsi3_test.c - Test __mulvsi3 -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __mulvsi3 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
19 // Effects: aborts if a * b overflows
21 si_int
__mulvsi3(si_int a
, si_int b
);
23 int test__mulvsi3(si_int a
, si_int b
, si_int expected
)
25 si_int x
= __mulvsi3(a
, b
);
27 printf("error in __mulvsi3: %d * %d = %d, expected %d\n",
34 if (test__mulvsi3(0, 0, 0))
36 if (test__mulvsi3(0, 1, 0))
38 if (test__mulvsi3(1, 0, 0))
40 if (test__mulvsi3(0, 10, 0))
42 if (test__mulvsi3(10, 0, 0))
44 if (test__mulvsi3(0, 0x1234567, 0))
46 if (test__mulvsi3(0x1234567, 0, 0))
49 if (test__mulvsi3(0, -1, 0))
51 if (test__mulvsi3(-1, 0, 0))
53 if (test__mulvsi3(0, -10, 0))
55 if (test__mulvsi3(-10, 0, 0))
57 if (test__mulvsi3(0, -0x1234567, 0))
59 if (test__mulvsi3(-0x1234567, 0, 0))
62 if (test__mulvsi3(1, 1, 1))
64 if (test__mulvsi3(1, 10, 10))
66 if (test__mulvsi3(10, 1, 10))
68 if (test__mulvsi3(1, 0x1234567, 0x1234567))
70 if (test__mulvsi3(0x1234567, 1, 0x1234567))
73 if (test__mulvsi3(1, -1, -1))
75 if (test__mulvsi3(1, -10, -10))
77 if (test__mulvsi3(-10, 1, -10))
79 if (test__mulvsi3(1, -0x1234567, -0x1234567))
81 if (test__mulvsi3(-0x1234567, 1, -0x1234567))
84 // if (test__mulvsi3(0x7FFFFFFF, -2, 0x80000001)) // abort
86 // if (test__mulvsi3(-2, 0x7FFFFFFF, 0x80000001)) // abort
88 if (test__mulvsi3(0x7FFFFFFF, -1, 0x80000001))
90 if (test__mulvsi3(-1, 0x7FFFFFFF, 0x80000001))
92 if (test__mulvsi3(0x7FFFFFFF, 0, 0))
94 if (test__mulvsi3(0, 0x7FFFFFFF, 0))
96 if (test__mulvsi3(0x7FFFFFFF, 1, 0x7FFFFFFF))
98 if (test__mulvsi3(1, 0x7FFFFFFF, 0x7FFFFFFF))
100 // if (test__mulvsi3(0x7FFFFFFF, 2, 0x80000001)) // abort
102 // if (test__mulvsi3(2, 0x7FFFFFFF, 0x80000001)) // abort
105 // if (test__mulvsi3(0x80000000, -2, 0x80000000)) // abort
107 // if (test__mulvsi3(-2, 0x80000000, 0x80000000)) // abort
109 // if (test__mulvsi3(0x80000000, -1, 0x80000000)) // abort
111 // if (test__mulvsi3(-1, 0x80000000, 0x80000000)) // abort
113 if (test__mulvsi3(0x80000000, 0, 0))
115 if (test__mulvsi3(0, 0x80000000, 0))
117 if (test__mulvsi3(0x80000000, 1, 0x80000000))
119 if (test__mulvsi3(1, 0x80000000, 0x80000000))
121 // if (test__mulvsi3(0x80000000, 2, 0x80000000)) // abort
123 // if (test__mulvsi3(2, 0x80000000, 0x80000000)) // abort
126 // if (test__mulvsi3(0x80000001, -2, 0x80000001)) // abort
128 // if (test__mulvsi3(-2, 0x80000001, 0x80000001)) // abort
130 if (test__mulvsi3(0x80000001, -1, 0x7FFFFFFF))
132 if (test__mulvsi3(-1, 0x80000001, 0x7FFFFFFF))
134 if (test__mulvsi3(0x80000001, 0, 0))
136 if (test__mulvsi3(0, 0x80000001, 0))
138 if (test__mulvsi3(0x80000001, 1, 0x80000001))
140 if (test__mulvsi3(1, 0x80000001, 0x80000001))
142 // if (test__mulvsi3(0x80000001, 2, 0x80000000)) // abort
144 // if (test__mulvsi3(2, 0x80000001, 0x80000000)) // abort