Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / ashlti3_test.c
blob3dfa4118b119fb1e000d8f1dfe0660295478aa70
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ashlti3
3 // REQUIRES: int128
5 #include "int_lib.h"
6 #include <stdio.h>
8 #ifdef CRT_HAS_128BIT
10 // Returns: a << b
12 // Precondition: 0 <= b < bits_in_tword
14 COMPILER_RT_ABI ti_int __ashlti3(ti_int a, int b);
16 int test__ashlti3(ti_int a, int b, ti_int expected) {
17 ti_int x = __ashlti3(a, b);
18 if (x != expected) {
19 twords at;
20 at.all = a;
21 twords bt;
22 bt.all = b;
23 twords xt;
24 xt.all = x;
25 twords expectedt;
26 expectedt.all = expected;
27 printf("error in __ashlti3: 0x%llX%.16llX << %d = 0x%llX%.16llX,"
28 " expected 0x%llX%.16llX\n",
29 at.s.high, at.s.low, b, xt.s.high, xt.s.low, expectedt.s.high,
30 expectedt.s.low);
32 return x != expected;
35 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
37 #endif
39 int main()
41 #ifdef CRT_HAS_128BIT
42 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0,
43 make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL)))
44 return 1;
45 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1,
46 make_ti(0xFDB97530ECA8642BLL, 0xFDB97530ECA8642ALL)))
47 return 1;
48 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2,
49 make_ti(0xFB72EA61D950C857LL, 0XFB72EA61D950C854LL)))
50 return 1;
51 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3,
52 make_ti(0xF6E5D4C3B2A190AFLL, 0xF6E5D4C3B2A190A8LL)))
53 return 1;
54 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4,
55 make_ti(0xEDCBA9876543215FLL, 0xEDCBA98765432150LL)))
56 return 1;
58 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28,
59 make_ti(0x876543215FEDCBA9LL, 0x8765432150000000LL)))
60 return 1;
61 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29,
62 make_ti(0x0ECA8642BFDB9753LL, 0x0ECA8642A0000000LL)))
63 return 1;
64 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30,
65 make_ti(0x1D950C857FB72EA6LL, 0x1D950C8540000000LL)))
66 return 1;
67 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31,
68 make_ti(0x3B2A190AFF6E5D4CLL, 0x3B2A190A80000000LL)))
69 return 1;
71 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32,
72 make_ti(0x76543215FEDCBA98LL, 0x7654321500000000LL)))
73 return 1;
75 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33,
76 make_ti(0xECA8642BFDB97530LL, 0xECA8642A00000000LL)))
77 return 1;
78 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34,
79 make_ti(0xD950C857FB72EA61LL, 0xD950C85400000000LL)))
80 return 1;
81 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35,
82 make_ti(0xB2A190AFF6E5D4C3LL, 0xB2A190A800000000LL)))
83 return 1;
84 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36,
85 make_ti(0x6543215FEDCBA987LL, 0x6543215000000000LL)))
86 return 1;
88 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60,
89 make_ti(0x5FEDCBA987654321LL, 0x5000000000000000LL)))
90 return 1;
91 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61,
92 make_ti(0xBFDB97530ECA8642LL, 0xA000000000000000LL)))
93 return 1;
94 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62,
95 make_ti(0x7FB72EA61D950C85LL, 0x4000000000000000LL)))
96 return 1;
97 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63,
98 make_ti(0xFF6E5D4C3B2A190ALL, 0x8000000000000000LL)))
99 return 1;
101 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64,
102 make_ti(0xFEDCBA9876543215LL, 0x0000000000000000LL)))
103 return 1;
105 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65,
106 make_ti(0xFDB97530ECA8642ALL, 0x0000000000000000LL)))
107 return 1;
108 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66,
109 make_ti(0xFB72EA61D950C854LL, 0x0000000000000000LL)))
110 return 1;
111 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67,
112 make_ti(0xF6E5D4C3B2A190A8LL, 0x0000000000000000LL)))
113 return 1;
114 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68,
115 make_ti(0xEDCBA98765432150LL, 0x0000000000000000LL)))
116 return 1;
118 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92,
119 make_ti(0x8765432150000000LL, 0x0000000000000000LL)))
120 return 1;
121 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93,
122 make_ti(0x0ECA8642A0000000LL, 0x0000000000000000LL)))
123 return 1;
124 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94,
125 make_ti(0x1D950C8540000000LL, 0x0000000000000000LL)))
126 return 1;
127 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95,
128 make_ti(0x3B2A190A80000000LL, 0x0000000000000000LL)))
129 return 1;
131 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96,
132 make_ti(0x7654321500000000LL, 0x0000000000000000LL)))
133 return 1;
135 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97,
136 make_ti(0xECA8642A00000000LL, 0x0000000000000000LL)))
137 return 1;
138 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98,
139 make_ti(0xD950C85400000000LL, 0x0000000000000000LL)))
140 return 1;
141 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99,
142 make_ti(0xB2A190A800000000LL, 0x0000000000000000LL)))
143 return 1;
144 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100,
145 make_ti(0x6543215000000000LL, 0x0000000000000000LL)))
146 return 1;
148 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124,
149 make_ti(0x5000000000000000LL, 0x0000000000000000LL)))
150 return 1;
151 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125,
152 make_ti(0xA000000000000000LL, 0x0000000000000000LL)))
153 return 1;
154 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126,
155 make_ti(0x4000000000000000LL, 0x0000000000000000LL)))
156 return 1;
157 if (test__ashlti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127,
158 make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
159 return 1;
160 #else
161 printf("skipped\n");
162 #endif
163 return 0;