blob: bcbfb18d65a9a2ea7961469301c7333fca65a04b [file] [log] [blame]
Dan Gohman1224c382009-07-20 21:19:07 +00001; RUN: llvm-as < %s | llvm-dis | FileCheck %s
Duncan P. N. Exon Smith13f5c582014-08-19 21:08:27 +00002; RUN: verify-uselistorder %s
Dan Gohman1224c382009-07-20 21:19:07 +00003
4@addr = external global i64
5
Dan Gohman1224c382009-07-20 21:19:07 +00006define i64 @add_unsigned(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +00007; CHECK: %z = add nuw i64 %x, %y
8 %z = add nuw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +00009 ret i64 %z
10}
11
12define i64 @sub_unsigned(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000013; CHECK: %z = sub nuw i64 %x, %y
14 %z = sub nuw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000015 ret i64 %z
16}
17
18define i64 @mul_unsigned(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000019; CHECK: %z = mul nuw i64 %x, %y
20 %z = mul nuw i64 %x, %y
Dan Gohman08d012e2009-07-22 22:44:56 +000021 ret i64 %z
22}
23
24define i64 @add_signed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000025; CHECK: %z = add nsw i64 %x, %y
26 %z = add nsw i64 %x, %y
Dan Gohman08d012e2009-07-22 22:44:56 +000027 ret i64 %z
28}
29
30define i64 @sub_signed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000031; CHECK: %z = sub nsw i64 %x, %y
32 %z = sub nsw i64 %x, %y
Dan Gohman08d012e2009-07-22 22:44:56 +000033 ret i64 %z
34}
35
36define i64 @mul_signed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000037; CHECK: %z = mul nsw i64 %x, %y
38 %z = mul nsw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000039 ret i64 %z
40}
41
42define i64 @add_plain(i64 %x, i64 %y) {
43; CHECK: %z = add i64 %x, %y
44 %z = add i64 %x, %y
45 ret i64 %z
46}
47
48define i64 @sub_plain(i64 %x, i64 %y) {
49; CHECK: %z = sub i64 %x, %y
50 %z = sub i64 %x, %y
51 ret i64 %z
52}
53
54define i64 @mul_plain(i64 %x, i64 %y) {
55; CHECK: %z = mul i64 %x, %y
56 %z = mul i64 %x, %y
57 ret i64 %z
58}
59
60define i64 @add_both(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000061; CHECK: %z = add nuw nsw i64 %x, %y
62 %z = add nuw nsw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000063 ret i64 %z
64}
65
66define i64 @sub_both(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000067; CHECK: %z = sub nuw nsw i64 %x, %y
68 %z = sub nuw nsw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000069 ret i64 %z
70}
71
72define i64 @mul_both(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000073; CHECK: %z = mul nuw nsw i64 %x, %y
74 %z = mul nuw nsw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000075 ret i64 %z
76}
77
78define i64 @add_both_reversed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000079; CHECK: %z = add nuw nsw i64 %x, %y
80 %z = add nsw nuw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000081 ret i64 %z
82}
83
84define i64 @sub_both_reversed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000085; CHECK: %z = sub nuw nsw i64 %x, %y
86 %z = sub nsw nuw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000087 ret i64 %z
88}
89
90define i64 @mul_both_reversed(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +000091; CHECK: %z = mul nuw nsw i64 %x, %y
92 %z = mul nsw nuw i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +000093 ret i64 %z
94}
95
Chris Lattnerf067d582011-02-07 16:40:21 +000096define i64 @shl_both(i64 %x, i64 %y) {
97; CHECK: %z = shl nuw nsw i64 %x, %y
98 %z = shl nuw nsw i64 %x, %y
99 ret i64 %z
100}
101
Dan Gohman1224c382009-07-20 21:19:07 +0000102define i64 @sdiv_exact(i64 %x, i64 %y) {
Dan Gohman59858cf2009-07-27 16:11:46 +0000103; CHECK: %z = sdiv exact i64 %x, %y
104 %z = sdiv exact i64 %x, %y
Dan Gohman1224c382009-07-20 21:19:07 +0000105 ret i64 %z
106}
107
108define i64 @sdiv_plain(i64 %x, i64 %y) {
109; CHECK: %z = sdiv i64 %x, %y
110 %z = sdiv i64 %x, %y
111 ret i64 %z
112}
113
Chris Lattner35bda892011-02-06 21:44:57 +0000114define i64 @udiv_exact(i64 %x, i64 %y) {
115; CHECK: %z = udiv exact i64 %x, %y
116 %z = udiv exact i64 %x, %y
117 ret i64 %z
118}
119
120define i64 @udiv_plain(i64 %x, i64 %y) {
121; CHECK: %z = udiv i64 %x, %y
122 %z = udiv i64 %x, %y
123 ret i64 %z
124}
125
Chris Lattnerf067d582011-02-07 16:40:21 +0000126define i64 @ashr_plain(i64 %x, i64 %y) {
127; CHECK: %z = ashr i64 %x, %y
128 %z = ashr i64 %x, %y
129 ret i64 %z
130}
131
132define i64 @ashr_exact(i64 %x, i64 %y) {
133; CHECK: %z = ashr exact i64 %x, %y
134 %z = ashr exact i64 %x, %y
135 ret i64 %z
136}
137
138define i64 @lshr_plain(i64 %x, i64 %y) {
139; CHECK: %z = lshr i64 %x, %y
140 %z = lshr i64 %x, %y
141 ret i64 %z
142}
143
144define i64 @lshr_exact(i64 %x, i64 %y) {
145; CHECK: %z = lshr exact i64 %x, %y
146 %z = lshr exact i64 %x, %y
147 ret i64 %z
148}
Chris Lattner35bda892011-02-06 21:44:57 +0000149
Dan Gohmandd8004d2009-07-27 21:53:46 +0000150define i64* @gep_nw(i64* %p, i64 %x) {
David Blaikie198d8ba2015-02-27 19:29:02 +0000151; CHECK: %z = getelementptr inbounds i64, i64* %p, i64 %x
152 %z = getelementptr inbounds i64, i64* %p, i64 %x
Dan Gohmandd8004d2009-07-27 21:53:46 +0000153 ret i64* %z
154}
155
156define i64* @gep_plain(i64* %p, i64 %x) {
David Blaikie198d8ba2015-02-27 19:29:02 +0000157; CHECK: %z = getelementptr i64, i64* %p, i64 %x
158 %z = getelementptr i64, i64* %p, i64 %x
Dan Gohmandd8004d2009-07-27 21:53:46 +0000159 ret i64* %z
160}
161
Dan Gohman1224c382009-07-20 21:19:07 +0000162define i64 @add_both_ce() {
Dan Gohman59858cf2009-07-27 16:11:46 +0000163; CHECK: ret i64 add nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
164 ret i64 add nsw nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
Dan Gohman1224c382009-07-20 21:19:07 +0000165}
166
167define i64 @sub_both_ce() {
Dan Gohman59858cf2009-07-27 16:11:46 +0000168; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
169 ret i64 sub nsw nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
Dan Gohman1224c382009-07-20 21:19:07 +0000170}
171
172define i64 @mul_both_ce() {
Dan Gohman59858cf2009-07-27 16:11:46 +0000173; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
174 ret i64 mul nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
Dan Gohman1224c382009-07-20 21:19:07 +0000175}
176
177define i64 @sdiv_exact_ce() {
Dan Gohman59858cf2009-07-27 16:11:46 +0000178; CHECK: ret i64 sdiv exact (i64 ptrtoint (i64* @addr to i64), i64 91)
179 ret i64 sdiv exact (i64 ptrtoint (i64* @addr to i64), i64 91)
Dan Gohman1224c382009-07-20 21:19:07 +0000180}
Dan Gohmandd8004d2009-07-27 21:53:46 +0000181
Chris Lattner35bda892011-02-06 21:44:57 +0000182define i64 @udiv_exact_ce() {
183; CHECK: ret i64 udiv exact (i64 ptrtoint (i64* @addr to i64), i64 91)
184 ret i64 udiv exact (i64 ptrtoint (i64* @addr to i64), i64 91)
185}
186
Chris Lattnerf067d582011-02-07 16:40:21 +0000187define i64 @ashr_exact_ce() {
188; CHECK: ret i64 ashr exact (i64 ptrtoint (i64* @addr to i64), i64 9)
189 ret i64 ashr exact (i64 ptrtoint (i64* @addr to i64), i64 9)
190}
191
192define i64 @lshr_exact_ce() {
193; CHECK: ret i64 lshr exact (i64 ptrtoint (i64* @addr to i64), i64 9)
194 ret i64 lshr exact (i64 ptrtoint (i64* @addr to i64), i64 9)
195}
196
Dan Gohmandd8004d2009-07-27 21:53:46 +0000197define i64* @gep_nw_ce() {
David Blaikie5a70dd12015-03-13 18:20:45 +0000198; CHECK: ret i64* getelementptr inbounds (i64, i64* @addr, i64 171)
199 ret i64* getelementptr inbounds (i64, i64* @addr, i64 171)
Dan Gohmandd8004d2009-07-27 21:53:46 +0000200}
201
Dan Gohmanf8dbee72009-09-07 23:54:19 +0000202define i64 @add_plain_ce() {
203; CHECK: ret i64 add (i64 ptrtoint (i64* @addr to i64), i64 91)
204 ret i64 add (i64 ptrtoint (i64* @addr to i64), i64 91)
205}
Dan Gohmandd8004d2009-07-27 21:53:46 +0000206
Dan Gohmanf8dbee72009-09-07 23:54:19 +0000207define i64 @sub_plain_ce() {
208; CHECK: ret i64 sub (i64 ptrtoint (i64* @addr to i64), i64 91)
209 ret i64 sub (i64 ptrtoint (i64* @addr to i64), i64 91)
210}
211
212define i64 @mul_plain_ce() {
213; CHECK: ret i64 mul (i64 ptrtoint (i64* @addr to i64), i64 91)
214 ret i64 mul (i64 ptrtoint (i64* @addr to i64), i64 91)
215}
216
217define i64 @sdiv_plain_ce() {
218; CHECK: ret i64 sdiv (i64 ptrtoint (i64* @addr to i64), i64 91)
219 ret i64 sdiv (i64 ptrtoint (i64* @addr to i64), i64 91)
220}
221
222define i64* @gep_plain_ce() {
David Blaikie5a70dd12015-03-13 18:20:45 +0000223; CHECK: ret i64* getelementptr (i64, i64* @addr, i64 171)
224 ret i64* getelementptr (i64, i64* @addr, i64 171)
Dan Gohmanf8dbee72009-09-07 23:54:19 +0000225}
226
227define i64 @add_both_reversed_ce() {
228; CHECK: ret i64 add nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
229 ret i64 add nsw nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
230}
231
232define i64 @sub_both_reversed_ce() {
233; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
234 ret i64 sub nsw nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
235}
236
237define i64 @mul_both_reversed_ce() {
238; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
239 ret i64 mul nsw nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
240}
241
242define i64 @add_signed_ce() {
243; CHECK: ret i64 add nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
244 ret i64 add nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
245}
246
247define i64 @sub_signed_ce() {
248; CHECK: ret i64 sub nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
249 ret i64 sub nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
250}
251
252define i64 @mul_signed_ce() {
253; CHECK: ret i64 mul nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
254 ret i64 mul nsw (i64 ptrtoint (i64* @addr to i64), i64 91)
255}
256
Chris Lattnerf067d582011-02-07 16:40:21 +0000257define i64 @shl_signed_ce() {
258; CHECK: ret i64 shl nsw (i64 ptrtoint (i64* @addr to i64), i64 17)
259 ret i64 shl nsw (i64 ptrtoint (i64* @addr to i64), i64 17)
260}
261
262
Dan Gohmanf8dbee72009-09-07 23:54:19 +0000263define i64 @add_unsigned_ce() {
264; CHECK: ret i64 add nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
265 ret i64 add nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
266}
267
268define i64 @sub_unsigned_ce() {
269; CHECK: ret i64 sub nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
270 ret i64 sub nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
271}
272
273define i64 @mul_unsigned_ce() {
274; CHECK: ret i64 mul nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
275 ret i64 mul nuw (i64 ptrtoint (i64* @addr to i64), i64 91)
276}
Chris Lattner35bda892011-02-06 21:44:57 +0000277