annotate clang/test/CodeGen/builtins-multiprecision.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple "i686-unknown-unknown" -emit-llvm -x c %s -o - -O3 | FileCheck %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - -O3 | FileCheck %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - -O3 | FileCheck %s
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 unsigned char test_addcb(unsigned char x, unsigned char y,
anatofuz
parents:
diff changeset
6 unsigned char carryin, unsigned char *z) {
anatofuz
parents:
diff changeset
7 // CHECK: @test_addcb
anatofuz
parents:
diff changeset
8 // CHECK: %{{.+}} = {{.*}} call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %x, i8 %y)
anatofuz
parents:
diff changeset
9 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
10 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
11 // CHECK: %{{.+}} = {{.*}} call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %{{.+}}, i8 %carryin)
anatofuz
parents:
diff changeset
12 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
13 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
14 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
15 // CHECK: %{{.+}} = zext i1 %{{.+}} to i8
anatofuz
parents:
diff changeset
16 // CHECK: store i8 %{{.+}}, i8* %z, align 1
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 unsigned char carryout;
anatofuz
parents:
diff changeset
19 *z = __builtin_addcb(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 return carryout;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 unsigned short test_addcs(unsigned short x, unsigned short y,
anatofuz
parents:
diff changeset
25 unsigned short carryin, unsigned short *z) {
anatofuz
parents:
diff changeset
26 // CHECK: @test_addcs
anatofuz
parents:
diff changeset
27 // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %x, i16 %y)
anatofuz
parents:
diff changeset
28 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
29 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
30 // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %{{.+}}, i16 %carryin)
anatofuz
parents:
diff changeset
31 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
32 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
33 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
34 // CHECK: %{{.+}} = zext i1 %{{.+}} to i16
anatofuz
parents:
diff changeset
35 // CHECK: store i16 %{{.+}}, i16* %z, align 2
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 unsigned short carryout;
anatofuz
parents:
diff changeset
38 *z = __builtin_addcs(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 return carryout;
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 unsigned test_addc(unsigned x, unsigned y, unsigned carryin, unsigned *z) {
anatofuz
parents:
diff changeset
44 // CHECK: @test_addc
anatofuz
parents:
diff changeset
45 // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %y)
anatofuz
parents:
diff changeset
46 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
47 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
48 // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %{{.+}}, i32 %carryin)
anatofuz
parents:
diff changeset
49 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
50 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
51 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
52 // CHECK: %{{.+}} = zext i1 %{{.+}} to i32
anatofuz
parents:
diff changeset
53 // CHECK: store i32 %{{.+}}, i32* %z, align 4
anatofuz
parents:
diff changeset
54 unsigned carryout;
anatofuz
parents:
diff changeset
55 *z = __builtin_addc(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 return carryout;
anatofuz
parents:
diff changeset
58 }
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 unsigned long test_addcl(unsigned long x, unsigned long y,
anatofuz
parents:
diff changeset
61 unsigned long carryin, unsigned long *z) {
anatofuz
parents:
diff changeset
62 // long is i32 on i686, i64 on x86_64.
anatofuz
parents:
diff changeset
63 // CHECK: @test_addcl([[UL:i32|i64]] %x
anatofuz
parents:
diff changeset
64 // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.uadd.with.overflow.[[UL]]([[UL]] %x, [[UL]] %y)
anatofuz
parents:
diff changeset
65 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
66 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
67 // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.uadd.with.overflow.[[UL]]([[UL]] %{{.+}}, [[UL]] %carryin)
anatofuz
parents:
diff changeset
68 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
69 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
70 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
71 // CHECK: %{{.+}} = zext i1 %{{.+}} to [[UL]]
anatofuz
parents:
diff changeset
72 // CHECK: store [[UL]] %{{.+}}, [[UL]]* %z
anatofuz
parents:
diff changeset
73 unsigned long carryout;
anatofuz
parents:
diff changeset
74 *z = __builtin_addcl(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 return carryout;
anatofuz
parents:
diff changeset
77 }
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 unsigned long long test_addcll(unsigned long long x, unsigned long long y,
anatofuz
parents:
diff changeset
80 unsigned long long carryin,
anatofuz
parents:
diff changeset
81 unsigned long long *z) {
anatofuz
parents:
diff changeset
82 // CHECK: @test_addcll
anatofuz
parents:
diff changeset
83 // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %x, i64 %y)
anatofuz
parents:
diff changeset
84 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
85 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
86 // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %{{.+}}, i64 %carryin)
anatofuz
parents:
diff changeset
87 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
88 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
89 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
90 // CHECK: %{{.+}} = zext i1 %{{.+}} to i64
anatofuz
parents:
diff changeset
91 // CHECK: store i64 %{{.+}}, i64* %z
anatofuz
parents:
diff changeset
92 unsigned long long carryout;
anatofuz
parents:
diff changeset
93 *z = __builtin_addcll(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
94
anatofuz
parents:
diff changeset
95 return carryout;
anatofuz
parents:
diff changeset
96 }
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 unsigned char test_subcb(unsigned char x, unsigned char y,
anatofuz
parents:
diff changeset
99 unsigned char carryin, unsigned char *z) {
anatofuz
parents:
diff changeset
100 // CHECK: @test_subcb
anatofuz
parents:
diff changeset
101 // CHECK: %{{.+}} = {{.*}} call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %x, i8 %y)
anatofuz
parents:
diff changeset
102 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
103 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
104 // CHECK: %{{.+}} = {{.*}} call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %{{.+}}, i8 %carryin)
anatofuz
parents:
diff changeset
105 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
106 // CHECK: %{{.+}} = extractvalue { i8, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
107 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
108 // CHECK: %{{.+}} = zext i1 %{{.+}} to i8
anatofuz
parents:
diff changeset
109 // CHECK: store i8 %{{.+}}, i8* %z, align 1
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 unsigned char carryout;
anatofuz
parents:
diff changeset
112 *z = __builtin_subcb(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 return carryout;
anatofuz
parents:
diff changeset
115 }
anatofuz
parents:
diff changeset
116
anatofuz
parents:
diff changeset
117 unsigned short test_subcs(unsigned short x, unsigned short y,
anatofuz
parents:
diff changeset
118 unsigned short carryin, unsigned short *z) {
anatofuz
parents:
diff changeset
119 // CHECK: @test_subcs
anatofuz
parents:
diff changeset
120 // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %x, i16 %y)
anatofuz
parents:
diff changeset
121 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
122 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
123 // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %{{.+}}, i16 %carryin)
anatofuz
parents:
diff changeset
124 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
125 // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
126 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
127 // CHECK: %{{.+}} = zext i1 %{{.+}} to i16
anatofuz
parents:
diff changeset
128 // CHECK: store i16 %{{.+}}, i16* %z, align 2
anatofuz
parents:
diff changeset
129
anatofuz
parents:
diff changeset
130 unsigned short carryout;
anatofuz
parents:
diff changeset
131 *z = __builtin_subcs(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
132
anatofuz
parents:
diff changeset
133 return carryout;
anatofuz
parents:
diff changeset
134 }
anatofuz
parents:
diff changeset
135
anatofuz
parents:
diff changeset
136 unsigned test_subc(unsigned x, unsigned y, unsigned carryin, unsigned *z) {
anatofuz
parents:
diff changeset
137 // CHECK: @test_subc
anatofuz
parents:
diff changeset
138 // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %x, i32 %y)
anatofuz
parents:
diff changeset
139 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
140 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
141 // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %{{.+}}, i32 %carryin)
anatofuz
parents:
diff changeset
142 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
143 // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
144 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
145 // CHECK: %{{.+}} = zext i1 %{{.+}} to i32
anatofuz
parents:
diff changeset
146 // CHECK: store i32 %{{.+}}, i32* %z, align 4
anatofuz
parents:
diff changeset
147 unsigned carryout;
anatofuz
parents:
diff changeset
148 *z = __builtin_subc(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
149
anatofuz
parents:
diff changeset
150 return carryout;
anatofuz
parents:
diff changeset
151 }
anatofuz
parents:
diff changeset
152
anatofuz
parents:
diff changeset
153 unsigned long test_subcl(unsigned long x, unsigned long y,
anatofuz
parents:
diff changeset
154 unsigned long carryin, unsigned long *z) {
anatofuz
parents:
diff changeset
155 // CHECK: @test_subcl([[UL:i32|i64]] %x
anatofuz
parents:
diff changeset
156 // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.usub.with.overflow.[[UL]]([[UL]] %x, [[UL]] %y)
anatofuz
parents:
diff changeset
157 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
158 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
159 // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.usub.with.overflow.[[UL]]([[UL]] %{{.+}}, [[UL]] %carryin)
anatofuz
parents:
diff changeset
160 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
161 // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
162 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
163 // CHECK: %{{.+}} = zext i1 %{{.+}} to [[UL]]
anatofuz
parents:
diff changeset
164 // CHECK: store [[UL]] %{{.+}}, [[UL]]* %z
anatofuz
parents:
diff changeset
165 unsigned long carryout;
anatofuz
parents:
diff changeset
166 *z = __builtin_subcl(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
167
anatofuz
parents:
diff changeset
168 return carryout;
anatofuz
parents:
diff changeset
169 }
anatofuz
parents:
diff changeset
170
anatofuz
parents:
diff changeset
171 unsigned long long test_subcll(unsigned long long x, unsigned long long y,
anatofuz
parents:
diff changeset
172 unsigned long long carryin,
anatofuz
parents:
diff changeset
173 unsigned long long *z) {
anatofuz
parents:
diff changeset
174 // CHECK: @test_subcll
anatofuz
parents:
diff changeset
175 // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %x, i64 %y)
anatofuz
parents:
diff changeset
176 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
177 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
178 // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %{{.+}}, i64 %carryin)
anatofuz
parents:
diff changeset
179 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1
anatofuz
parents:
diff changeset
180 // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0
anatofuz
parents:
diff changeset
181 // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}}
anatofuz
parents:
diff changeset
182 // CHECK: %{{.+}} = zext i1 %{{.+}} to i64
anatofuz
parents:
diff changeset
183 // CHECK: store i64 %{{.+}}, i64* %z
anatofuz
parents:
diff changeset
184 unsigned long long carryout;
anatofuz
parents:
diff changeset
185 *z = __builtin_subcll(x, y, carryin, &carryout);
anatofuz
parents:
diff changeset
186
anatofuz
parents:
diff changeset
187 return carryout;
anatofuz
parents:
diff changeset
188 }