• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-darwin-unknown < %s | FileCheck %s --check-prefix=SDAG --check-prefix=GENERIC
3; RUN: llc -mtriple=x86_64-darwin-unknown -fast-isel -fast-isel-abort=1 < %s | FileCheck %s --check-prefix=FAST
4; RUN: llc -mtriple=x86_64-darwin-unknown -mcpu=knl < %s | FileCheck %s --check-prefix=SDAG --check-prefix=KNL
5
6;
7; Get the actual value of the overflow bit.
8;
9; SADDO reg, reg
10define zeroext i1 @saddoi8(i8 signext %v1, i8 signext %v2, i8* %res) {
11; SDAG-LABEL: saddoi8:
12; SDAG:       ## %bb.0:
13; SDAG-NEXT:    addb %sil, %dil
14; SDAG-NEXT:    seto %al
15; SDAG-NEXT:    movb %dil, (%rdx)
16; SDAG-NEXT:    retq
17;
18; FAST-LABEL: saddoi8:
19; FAST:       ## %bb.0:
20; FAST-NEXT:    addb %sil, %dil
21; FAST-NEXT:    seto %al
22; FAST-NEXT:    movb %dil, (%rdx)
23; FAST-NEXT:    andb $1, %al
24; FAST-NEXT:    movzbl %al, %eax
25; FAST-NEXT:    retq
26  %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 %v1, i8 %v2)
27  %val = extractvalue {i8, i1} %t, 0
28  %obit = extractvalue {i8, i1} %t, 1
29  store i8 %val, i8* %res
30  ret i1 %obit
31}
32
33define zeroext i1 @saddoi16(i16 %v1, i16 %v2, i16* %res) {
34; SDAG-LABEL: saddoi16:
35; SDAG:       ## %bb.0:
36; SDAG-NEXT:    addw %si, %di
37; SDAG-NEXT:    seto %al
38; SDAG-NEXT:    movw %di, (%rdx)
39; SDAG-NEXT:    retq
40;
41; FAST-LABEL: saddoi16:
42; FAST:       ## %bb.0:
43; FAST-NEXT:    addw %si, %di
44; FAST-NEXT:    seto %al
45; FAST-NEXT:    movw %di, (%rdx)
46; FAST-NEXT:    andb $1, %al
47; FAST-NEXT:    movzbl %al, %eax
48; FAST-NEXT:    retq
49  %t = call {i16, i1} @llvm.sadd.with.overflow.i16(i16 %v1, i16 %v2)
50  %val = extractvalue {i16, i1} %t, 0
51  %obit = extractvalue {i16, i1} %t, 1
52  store i16 %val, i16* %res
53  ret i1 %obit
54}
55
56define zeroext i1 @saddoi32(i32 %v1, i32 %v2, i32* %res) {
57; SDAG-LABEL: saddoi32:
58; SDAG:       ## %bb.0:
59; SDAG-NEXT:    addl %esi, %edi
60; SDAG-NEXT:    seto %al
61; SDAG-NEXT:    movl %edi, (%rdx)
62; SDAG-NEXT:    retq
63;
64; FAST-LABEL: saddoi32:
65; FAST:       ## %bb.0:
66; FAST-NEXT:    addl %esi, %edi
67; FAST-NEXT:    seto %al
68; FAST-NEXT:    movl %edi, (%rdx)
69; FAST-NEXT:    andb $1, %al
70; FAST-NEXT:    movzbl %al, %eax
71; FAST-NEXT:    retq
72  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
73  %val = extractvalue {i32, i1} %t, 0
74  %obit = extractvalue {i32, i1} %t, 1
75  store i32 %val, i32* %res
76  ret i1 %obit
77}
78
79define zeroext i1 @saddoi64(i64 %v1, i64 %v2, i64* %res) {
80; SDAG-LABEL: saddoi64:
81; SDAG:       ## %bb.0:
82; SDAG-NEXT:    addq %rsi, %rdi
83; SDAG-NEXT:    seto %al
84; SDAG-NEXT:    movq %rdi, (%rdx)
85; SDAG-NEXT:    retq
86;
87; FAST-LABEL: saddoi64:
88; FAST:       ## %bb.0:
89; FAST-NEXT:    addq %rsi, %rdi
90; FAST-NEXT:    seto %al
91; FAST-NEXT:    movq %rdi, (%rdx)
92; FAST-NEXT:    andb $1, %al
93; FAST-NEXT:    movzbl %al, %eax
94; FAST-NEXT:    retq
95  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
96  %val = extractvalue {i64, i1} %t, 0
97  %obit = extractvalue {i64, i1} %t, 1
98  store i64 %val, i64* %res
99  ret i1 %obit
100}
101
102; SADDO reg, 1 | INC
103define zeroext i1 @saddoinci8(i8 %v1, i8* %res) {
104; SDAG-LABEL: saddoinci8:
105; SDAG:       ## %bb.0:
106; SDAG-NEXT:    incb %dil
107; SDAG-NEXT:    seto %al
108; SDAG-NEXT:    movb %dil, (%rsi)
109; SDAG-NEXT:    retq
110;
111; FAST-LABEL: saddoinci8:
112; FAST:       ## %bb.0:
113; FAST-NEXT:    incb %dil
114; FAST-NEXT:    seto %al
115; FAST-NEXT:    movb %dil, (%rsi)
116; FAST-NEXT:    andb $1, %al
117; FAST-NEXT:    movzbl %al, %eax
118; FAST-NEXT:    retq
119  %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 %v1, i8 1)
120  %val = extractvalue {i8, i1} %t, 0
121  %obit = extractvalue {i8, i1} %t, 1
122  store i8 %val, i8* %res
123  ret i1 %obit
124}
125
126define zeroext i1 @saddoinci16(i16 %v1, i16* %res) {
127; SDAG-LABEL: saddoinci16:
128; SDAG:       ## %bb.0:
129; SDAG-NEXT:    incw %di
130; SDAG-NEXT:    seto %al
131; SDAG-NEXT:    movw %di, (%rsi)
132; SDAG-NEXT:    retq
133;
134; FAST-LABEL: saddoinci16:
135; FAST:       ## %bb.0:
136; FAST-NEXT:    incw %di
137; FAST-NEXT:    seto %al
138; FAST-NEXT:    movw %di, (%rsi)
139; FAST-NEXT:    andb $1, %al
140; FAST-NEXT:    movzbl %al, %eax
141; FAST-NEXT:    retq
142  %t = call {i16, i1} @llvm.sadd.with.overflow.i16(i16 %v1, i16 1)
143  %val = extractvalue {i16, i1} %t, 0
144  %obit = extractvalue {i16, i1} %t, 1
145  store i16 %val, i16* %res
146  ret i1 %obit
147}
148
149define zeroext i1 @saddoinci32(i32 %v1, i32* %res) {
150; SDAG-LABEL: saddoinci32:
151; SDAG:       ## %bb.0:
152; SDAG-NEXT:    incl %edi
153; SDAG-NEXT:    seto %al
154; SDAG-NEXT:    movl %edi, (%rsi)
155; SDAG-NEXT:    retq
156;
157; FAST-LABEL: saddoinci32:
158; FAST:       ## %bb.0:
159; FAST-NEXT:    incl %edi
160; FAST-NEXT:    seto %al
161; FAST-NEXT:    movl %edi, (%rsi)
162; FAST-NEXT:    andb $1, %al
163; FAST-NEXT:    movzbl %al, %eax
164; FAST-NEXT:    retq
165  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 1)
166  %val = extractvalue {i32, i1} %t, 0
167  %obit = extractvalue {i32, i1} %t, 1
168  store i32 %val, i32* %res
169  ret i1 %obit
170}
171
172define zeroext i1 @saddoinci64(i64 %v1, i64* %res) {
173; SDAG-LABEL: saddoinci64:
174; SDAG:       ## %bb.0:
175; SDAG-NEXT:    incq %rdi
176; SDAG-NEXT:    seto %al
177; SDAG-NEXT:    movq %rdi, (%rsi)
178; SDAG-NEXT:    retq
179;
180; FAST-LABEL: saddoinci64:
181; FAST:       ## %bb.0:
182; FAST-NEXT:    incq %rdi
183; FAST-NEXT:    seto %al
184; FAST-NEXT:    movq %rdi, (%rsi)
185; FAST-NEXT:    andb $1, %al
186; FAST-NEXT:    movzbl %al, %eax
187; FAST-NEXT:    retq
188  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 1)
189  %val = extractvalue {i64, i1} %t, 0
190  %obit = extractvalue {i64, i1} %t, 1
191  store i64 %val, i64* %res
192  ret i1 %obit
193}
194
195; SADDO reg, imm | imm, reg
196define zeroext i1 @saddoi64imm1(i64 %v1, i64* %res) {
197; SDAG-LABEL: saddoi64imm1:
198; SDAG:       ## %bb.0:
199; SDAG-NEXT:    addq $2, %rdi
200; SDAG-NEXT:    seto %al
201; SDAG-NEXT:    movq %rdi, (%rsi)
202; SDAG-NEXT:    retq
203;
204; FAST-LABEL: saddoi64imm1:
205; FAST:       ## %bb.0:
206; FAST-NEXT:    addq $2, %rdi
207; FAST-NEXT:    seto %al
208; FAST-NEXT:    movq %rdi, (%rsi)
209; FAST-NEXT:    andb $1, %al
210; FAST-NEXT:    movzbl %al, %eax
211; FAST-NEXT:    retq
212  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 2, i64 %v1)
213  %val = extractvalue {i64, i1} %t, 0
214  %obit = extractvalue {i64, i1} %t, 1
215  store i64 %val, i64* %res
216  ret i1 %obit
217}
218
219; Check boundary conditions for large immediates.
220define zeroext i1 @saddoi64imm2(i64 %v1, i64* %res) {
221; SDAG-LABEL: saddoi64imm2:
222; SDAG:       ## %bb.0:
223; SDAG-NEXT:    addq $-2147483648, %rdi ## imm = 0x80000000
224; SDAG-NEXT:    seto %al
225; SDAG-NEXT:    movq %rdi, (%rsi)
226; SDAG-NEXT:    retq
227;
228; FAST-LABEL: saddoi64imm2:
229; FAST:       ## %bb.0:
230; FAST-NEXT:    addq $-2147483648, %rdi ## imm = 0x80000000
231; FAST-NEXT:    seto %al
232; FAST-NEXT:    movq %rdi, (%rsi)
233; FAST-NEXT:    andb $1, %al
234; FAST-NEXT:    movzbl %al, %eax
235; FAST-NEXT:    retq
236  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 -2147483648)
237  %val = extractvalue {i64, i1} %t, 0
238  %obit = extractvalue {i64, i1} %t, 1
239  store i64 %val, i64* %res
240  ret i1 %obit
241}
242
243define zeroext i1 @saddoi64imm3(i64 %v1, i64* %res) {
244; SDAG-LABEL: saddoi64imm3:
245; SDAG:       ## %bb.0:
246; SDAG-NEXT:    movabsq $-21474836489, %rcx ## imm = 0xFFFFFFFAFFFFFFF7
247; SDAG-NEXT:    addq %rdi, %rcx
248; SDAG-NEXT:    seto %al
249; SDAG-NEXT:    movq %rcx, (%rsi)
250; SDAG-NEXT:    retq
251;
252; FAST-LABEL: saddoi64imm3:
253; FAST:       ## %bb.0:
254; FAST-NEXT:    movabsq $-21474836489, %rax ## imm = 0xFFFFFFFAFFFFFFF7
255; FAST-NEXT:    addq %rdi, %rax
256; FAST-NEXT:    seto %cl
257; FAST-NEXT:    movq %rax, (%rsi)
258; FAST-NEXT:    andb $1, %cl
259; FAST-NEXT:    movzbl %cl, %eax
260; FAST-NEXT:    retq
261  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 -21474836489)
262  %val = extractvalue {i64, i1} %t, 0
263  %obit = extractvalue {i64, i1} %t, 1
264  store i64 %val, i64* %res
265  ret i1 %obit
266}
267
268define zeroext i1 @saddoi64imm4(i64 %v1, i64* %res) {
269; SDAG-LABEL: saddoi64imm4:
270; SDAG:       ## %bb.0:
271; SDAG-NEXT:    addq $2147483647, %rdi ## imm = 0x7FFFFFFF
272; SDAG-NEXT:    seto %al
273; SDAG-NEXT:    movq %rdi, (%rsi)
274; SDAG-NEXT:    retq
275;
276; FAST-LABEL: saddoi64imm4:
277; FAST:       ## %bb.0:
278; FAST-NEXT:    addq $2147483647, %rdi ## imm = 0x7FFFFFFF
279; FAST-NEXT:    seto %al
280; FAST-NEXT:    movq %rdi, (%rsi)
281; FAST-NEXT:    andb $1, %al
282; FAST-NEXT:    movzbl %al, %eax
283; FAST-NEXT:    retq
284  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 2147483647)
285  %val = extractvalue {i64, i1} %t, 0
286  %obit = extractvalue {i64, i1} %t, 1
287  store i64 %val, i64* %res
288  ret i1 %obit
289}
290
291define zeroext i1 @saddoi64imm5(i64 %v1, i64* %res) {
292; SDAG-LABEL: saddoi64imm5:
293; SDAG:       ## %bb.0:
294; SDAG-NEXT:    subq $-2147483648, %rdi ## imm = 0x80000000
295; SDAG-NEXT:    seto %al
296; SDAG-NEXT:    movq %rdi, (%rsi)
297; SDAG-NEXT:    retq
298;
299; FAST-LABEL: saddoi64imm5:
300; FAST:       ## %bb.0:
301; FAST-NEXT:    movl $2147483648, %eax ## imm = 0x80000000
302; FAST-NEXT:    addq %rdi, %rax
303; FAST-NEXT:    seto %cl
304; FAST-NEXT:    movq %rax, (%rsi)
305; FAST-NEXT:    andb $1, %cl
306; FAST-NEXT:    movzbl %cl, %eax
307; FAST-NEXT:    retq
308  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 2147483648)
309  %val = extractvalue {i64, i1} %t, 0
310  %obit = extractvalue {i64, i1} %t, 1
311  store i64 %val, i64* %res
312  ret i1 %obit
313}
314
315; UADDO
316define zeroext i1 @uaddoi32(i32 %v1, i32 %v2, i32* %res) {
317; SDAG-LABEL: uaddoi32:
318; SDAG:       ## %bb.0:
319; SDAG-NEXT:    addl %esi, %edi
320; SDAG-NEXT:    setb %al
321; SDAG-NEXT:    movl %edi, (%rdx)
322; SDAG-NEXT:    retq
323;
324; FAST-LABEL: uaddoi32:
325; FAST:       ## %bb.0:
326; FAST-NEXT:    addl %esi, %edi
327; FAST-NEXT:    setb %al
328; FAST-NEXT:    movl %edi, (%rdx)
329; FAST-NEXT:    andb $1, %al
330; FAST-NEXT:    movzbl %al, %eax
331; FAST-NEXT:    retq
332  %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
333  %val = extractvalue {i32, i1} %t, 0
334  %obit = extractvalue {i32, i1} %t, 1
335  store i32 %val, i32* %res
336  ret i1 %obit
337}
338
339define zeroext i1 @uaddoi64(i64 %v1, i64 %v2, i64* %res) {
340; SDAG-LABEL: uaddoi64:
341; SDAG:       ## %bb.0:
342; SDAG-NEXT:    addq %rsi, %rdi
343; SDAG-NEXT:    setb %al
344; SDAG-NEXT:    movq %rdi, (%rdx)
345; SDAG-NEXT:    retq
346;
347; FAST-LABEL: uaddoi64:
348; FAST:       ## %bb.0:
349; FAST-NEXT:    addq %rsi, %rdi
350; FAST-NEXT:    setb %al
351; FAST-NEXT:    movq %rdi, (%rdx)
352; FAST-NEXT:    andb $1, %al
353; FAST-NEXT:    movzbl %al, %eax
354; FAST-NEXT:    retq
355  %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
356  %val = extractvalue {i64, i1} %t, 0
357  %obit = extractvalue {i64, i1} %t, 1
358  store i64 %val, i64* %res
359  ret i1 %obit
360}
361
362; UADDO reg, 1 | NOT INC
363define zeroext i1 @uaddoinci8(i8 %v1, i8* %res) {
364; SDAG-LABEL: uaddoinci8:
365; SDAG:       ## %bb.0:
366; SDAG-NEXT:    incb %dil
367; SDAG-NEXT:    sete %al
368; SDAG-NEXT:    movb %dil, (%rsi)
369; SDAG-NEXT:    retq
370;
371; FAST-LABEL: uaddoinci8:
372; FAST:       ## %bb.0:
373; FAST-NEXT:    addb $1, %dil
374; FAST-NEXT:    setb %al
375; FAST-NEXT:    movb %dil, (%rsi)
376; FAST-NEXT:    andb $1, %al
377; FAST-NEXT:    movzbl %al, %eax
378; FAST-NEXT:    retq
379  %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %v1, i8 1)
380  %val = extractvalue {i8, i1} %t, 0
381  %obit = extractvalue {i8, i1} %t, 1
382  store i8 %val, i8* %res
383  ret i1 %obit
384}
385
386define zeroext i1 @uaddoinci16(i16 %v1, i16* %res) {
387; SDAG-LABEL: uaddoinci16:
388; SDAG:       ## %bb.0:
389; SDAG-NEXT:    incw %di
390; SDAG-NEXT:    sete %al
391; SDAG-NEXT:    movw %di, (%rsi)
392; SDAG-NEXT:    retq
393;
394; FAST-LABEL: uaddoinci16:
395; FAST:       ## %bb.0:
396; FAST-NEXT:    addw $1, %di
397; FAST-NEXT:    setb %al
398; FAST-NEXT:    movw %di, (%rsi)
399; FAST-NEXT:    andb $1, %al
400; FAST-NEXT:    movzbl %al, %eax
401; FAST-NEXT:    retq
402  %t = call {i16, i1} @llvm.uadd.with.overflow.i16(i16 %v1, i16 1)
403  %val = extractvalue {i16, i1} %t, 0
404  %obit = extractvalue {i16, i1} %t, 1
405  store i16 %val, i16* %res
406  ret i1 %obit
407}
408
409define zeroext i1 @uaddoinci32(i32 %v1, i32* %res) {
410; SDAG-LABEL: uaddoinci32:
411; SDAG:       ## %bb.0:
412; SDAG-NEXT:    incl %edi
413; SDAG-NEXT:    sete %al
414; SDAG-NEXT:    movl %edi, (%rsi)
415; SDAG-NEXT:    retq
416;
417; FAST-LABEL: uaddoinci32:
418; FAST:       ## %bb.0:
419; FAST-NEXT:    addl $1, %edi
420; FAST-NEXT:    setb %al
421; FAST-NEXT:    movl %edi, (%rsi)
422; FAST-NEXT:    andb $1, %al
423; FAST-NEXT:    movzbl %al, %eax
424; FAST-NEXT:    retq
425  %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 1)
426  %val = extractvalue {i32, i1} %t, 0
427  %obit = extractvalue {i32, i1} %t, 1
428  store i32 %val, i32* %res
429  ret i1 %obit
430}
431
432define zeroext i1 @uaddoinci64(i64 %v1, i64* %res) {
433; SDAG-LABEL: uaddoinci64:
434; SDAG:       ## %bb.0:
435; SDAG-NEXT:    incq %rdi
436; SDAG-NEXT:    sete %al
437; SDAG-NEXT:    movq %rdi, (%rsi)
438; SDAG-NEXT:    retq
439;
440; FAST-LABEL: uaddoinci64:
441; FAST:       ## %bb.0:
442; FAST-NEXT:    addq $1, %rdi
443; FAST-NEXT:    setb %al
444; FAST-NEXT:    movq %rdi, (%rsi)
445; FAST-NEXT:    andb $1, %al
446; FAST-NEXT:    movzbl %al, %eax
447; FAST-NEXT:    retq
448  %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 1)
449  %val = extractvalue {i64, i1} %t, 0
450  %obit = extractvalue {i64, i1} %t, 1
451  store i64 %val, i64* %res
452  ret i1 %obit
453}
454
455; SSUBO
456define zeroext i1 @ssuboi32(i32 %v1, i32 %v2, i32* %res) {
457; SDAG-LABEL: ssuboi32:
458; SDAG:       ## %bb.0:
459; SDAG-NEXT:    subl %esi, %edi
460; SDAG-NEXT:    seto %al
461; SDAG-NEXT:    movl %edi, (%rdx)
462; SDAG-NEXT:    retq
463;
464; FAST-LABEL: ssuboi32:
465; FAST:       ## %bb.0:
466; FAST-NEXT:    subl %esi, %edi
467; FAST-NEXT:    seto %al
468; FAST-NEXT:    movl %edi, (%rdx)
469; FAST-NEXT:    andb $1, %al
470; FAST-NEXT:    movzbl %al, %eax
471; FAST-NEXT:    retq
472  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
473  %val = extractvalue {i32, i1} %t, 0
474  %obit = extractvalue {i32, i1} %t, 1
475  store i32 %val, i32* %res
476  ret i1 %obit
477}
478
479define zeroext i1 @ssuboi64(i64 %v1, i64 %v2, i64* %res) {
480; SDAG-LABEL: ssuboi64:
481; SDAG:       ## %bb.0:
482; SDAG-NEXT:    subq %rsi, %rdi
483; SDAG-NEXT:    seto %al
484; SDAG-NEXT:    movq %rdi, (%rdx)
485; SDAG-NEXT:    retq
486;
487; FAST-LABEL: ssuboi64:
488; FAST:       ## %bb.0:
489; FAST-NEXT:    subq %rsi, %rdi
490; FAST-NEXT:    seto %al
491; FAST-NEXT:    movq %rdi, (%rdx)
492; FAST-NEXT:    andb $1, %al
493; FAST-NEXT:    movzbl %al, %eax
494; FAST-NEXT:    retq
495  %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
496  %val = extractvalue {i64, i1} %t, 0
497  %obit = extractvalue {i64, i1} %t, 1
498  store i64 %val, i64* %res
499  ret i1 %obit
500}
501
502; USUBO
503define zeroext i1 @usuboi32(i32 %v1, i32 %v2, i32* %res) {
504; SDAG-LABEL: usuboi32:
505; SDAG:       ## %bb.0:
506; SDAG-NEXT:    subl %esi, %edi
507; SDAG-NEXT:    setb %al
508; SDAG-NEXT:    movl %edi, (%rdx)
509; SDAG-NEXT:    retq
510;
511; FAST-LABEL: usuboi32:
512; FAST:       ## %bb.0:
513; FAST-NEXT:    subl %esi, %edi
514; FAST-NEXT:    setb %al
515; FAST-NEXT:    movl %edi, (%rdx)
516; FAST-NEXT:    andb $1, %al
517; FAST-NEXT:    movzbl %al, %eax
518; FAST-NEXT:    retq
519  %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
520  %val = extractvalue {i32, i1} %t, 0
521  %obit = extractvalue {i32, i1} %t, 1
522  store i32 %val, i32* %res
523  ret i1 %obit
524}
525
526define zeroext i1 @usuboi64(i64 %v1, i64 %v2, i64* %res) {
527; SDAG-LABEL: usuboi64:
528; SDAG:       ## %bb.0:
529; SDAG-NEXT:    subq %rsi, %rdi
530; SDAG-NEXT:    setb %al
531; SDAG-NEXT:    movq %rdi, (%rdx)
532; SDAG-NEXT:    retq
533;
534; FAST-LABEL: usuboi64:
535; FAST:       ## %bb.0:
536; FAST-NEXT:    subq %rsi, %rdi
537; FAST-NEXT:    setb %al
538; FAST-NEXT:    movq %rdi, (%rdx)
539; FAST-NEXT:    andb $1, %al
540; FAST-NEXT:    movzbl %al, %eax
541; FAST-NEXT:    retq
542  %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
543  %val = extractvalue {i64, i1} %t, 0
544  %obit = extractvalue {i64, i1} %t, 1
545  store i64 %val, i64* %res
546  ret i1 %obit
547}
548
549;
550; Check the use of the overflow bit in combination with a select instruction.
551;
552define i32 @saddoselecti32(i32 %v1, i32 %v2) {
553; SDAG-LABEL: saddoselecti32:
554; SDAG:       ## %bb.0:
555; SDAG-NEXT:    movl %esi, %eax
556; SDAG-NEXT:    movl %edi, %ecx
557; SDAG-NEXT:    addl %esi, %ecx
558; SDAG-NEXT:    cmovol %edi, %eax
559; SDAG-NEXT:    retq
560;
561; FAST-LABEL: saddoselecti32:
562; FAST:       ## %bb.0:
563; FAST-NEXT:    movl %esi, %eax
564; FAST-NEXT:    movl %edi, %ecx
565; FAST-NEXT:    addl %esi, %ecx
566; FAST-NEXT:    cmovol %edi, %eax
567; FAST-NEXT:    retq
568  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
569  %obit = extractvalue {i32, i1} %t, 1
570  %ret = select i1 %obit, i32 %v1, i32 %v2
571  ret i32 %ret
572}
573
574define i64 @saddoselecti64(i64 %v1, i64 %v2) {
575; SDAG-LABEL: saddoselecti64:
576; SDAG:       ## %bb.0:
577; SDAG-NEXT:    movq %rsi, %rax
578; SDAG-NEXT:    movq %rdi, %rcx
579; SDAG-NEXT:    addq %rsi, %rcx
580; SDAG-NEXT:    cmovoq %rdi, %rax
581; SDAG-NEXT:    retq
582;
583; FAST-LABEL: saddoselecti64:
584; FAST:       ## %bb.0:
585; FAST-NEXT:    movq %rsi, %rax
586; FAST-NEXT:    movq %rdi, %rcx
587; FAST-NEXT:    addq %rsi, %rcx
588; FAST-NEXT:    cmovoq %rdi, %rax
589; FAST-NEXT:    retq
590  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
591  %obit = extractvalue {i64, i1} %t, 1
592  %ret = select i1 %obit, i64 %v1, i64 %v2
593  ret i64 %ret
594}
595
596define i32 @uaddoselecti32(i32 %v1, i32 %v2) {
597; SDAG-LABEL: uaddoselecti32:
598; SDAG:       ## %bb.0:
599; SDAG-NEXT:    movl %esi, %eax
600; SDAG-NEXT:    movl %edi, %ecx
601; SDAG-NEXT:    addl %esi, %ecx
602; SDAG-NEXT:    cmovbl %edi, %eax
603; SDAG-NEXT:    retq
604;
605; FAST-LABEL: uaddoselecti32:
606; FAST:       ## %bb.0:
607; FAST-NEXT:    movl %esi, %eax
608; FAST-NEXT:    movl %edi, %ecx
609; FAST-NEXT:    addl %esi, %ecx
610; FAST-NEXT:    cmovbl %edi, %eax
611; FAST-NEXT:    retq
612  %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
613  %obit = extractvalue {i32, i1} %t, 1
614  %ret = select i1 %obit, i32 %v1, i32 %v2
615  ret i32 %ret
616}
617
618define i64 @uaddoselecti64(i64 %v1, i64 %v2) {
619; SDAG-LABEL: uaddoselecti64:
620; SDAG:       ## %bb.0:
621; SDAG-NEXT:    movq %rsi, %rax
622; SDAG-NEXT:    movq %rdi, %rcx
623; SDAG-NEXT:    addq %rsi, %rcx
624; SDAG-NEXT:    cmovbq %rdi, %rax
625; SDAG-NEXT:    retq
626;
627; FAST-LABEL: uaddoselecti64:
628; FAST:       ## %bb.0:
629; FAST-NEXT:    movq %rsi, %rax
630; FAST-NEXT:    movq %rdi, %rcx
631; FAST-NEXT:    addq %rsi, %rcx
632; FAST-NEXT:    cmovbq %rdi, %rax
633; FAST-NEXT:    retq
634  %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
635  %obit = extractvalue {i64, i1} %t, 1
636  %ret = select i1 %obit, i64 %v1, i64 %v2
637  ret i64 %ret
638}
639
640define i32 @ssuboselecti32(i32 %v1, i32 %v2) {
641; SDAG-LABEL: ssuboselecti32:
642; SDAG:       ## %bb.0:
643; SDAG-NEXT:    movl %esi, %eax
644; SDAG-NEXT:    cmpl %esi, %edi
645; SDAG-NEXT:    cmovol %edi, %eax
646; SDAG-NEXT:    retq
647;
648; FAST-LABEL: ssuboselecti32:
649; FAST:       ## %bb.0:
650; FAST-NEXT:    movl %esi, %eax
651; FAST-NEXT:    cmpl %esi, %edi
652; FAST-NEXT:    cmovol %edi, %eax
653; FAST-NEXT:    retq
654  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
655  %obit = extractvalue {i32, i1} %t, 1
656  %ret = select i1 %obit, i32 %v1, i32 %v2
657  ret i32 %ret
658}
659
660define i64 @ssuboselecti64(i64 %v1, i64 %v2) {
661; SDAG-LABEL: ssuboselecti64:
662; SDAG:       ## %bb.0:
663; SDAG-NEXT:    movq %rsi, %rax
664; SDAG-NEXT:    cmpq %rsi, %rdi
665; SDAG-NEXT:    cmovoq %rdi, %rax
666; SDAG-NEXT:    retq
667;
668; FAST-LABEL: ssuboselecti64:
669; FAST:       ## %bb.0:
670; FAST-NEXT:    movq %rsi, %rax
671; FAST-NEXT:    cmpq %rsi, %rdi
672; FAST-NEXT:    cmovoq %rdi, %rax
673; FAST-NEXT:    retq
674  %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
675  %obit = extractvalue {i64, i1} %t, 1
676  %ret = select i1 %obit, i64 %v1, i64 %v2
677  ret i64 %ret
678}
679
680define i32 @usuboselecti32(i32 %v1, i32 %v2) {
681; SDAG-LABEL: usuboselecti32:
682; SDAG:       ## %bb.0:
683; SDAG-NEXT:    movl %esi, %eax
684; SDAG-NEXT:    cmpl %esi, %edi
685; SDAG-NEXT:    cmovbl %edi, %eax
686; SDAG-NEXT:    retq
687;
688; FAST-LABEL: usuboselecti32:
689; FAST:       ## %bb.0:
690; FAST-NEXT:    movl %esi, %eax
691; FAST-NEXT:    cmpl %esi, %edi
692; FAST-NEXT:    cmovbl %edi, %eax
693; FAST-NEXT:    retq
694  %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
695  %obit = extractvalue {i32, i1} %t, 1
696  %ret = select i1 %obit, i32 %v1, i32 %v2
697  ret i32 %ret
698}
699
700define i64 @usuboselecti64(i64 %v1, i64 %v2) {
701; SDAG-LABEL: usuboselecti64:
702; SDAG:       ## %bb.0:
703; SDAG-NEXT:    movq %rsi, %rax
704; SDAG-NEXT:    cmpq %rsi, %rdi
705; SDAG-NEXT:    cmovbq %rdi, %rax
706; SDAG-NEXT:    retq
707;
708; FAST-LABEL: usuboselecti64:
709; FAST:       ## %bb.0:
710; FAST-NEXT:    movq %rsi, %rax
711; FAST-NEXT:    cmpq %rsi, %rdi
712; FAST-NEXT:    cmovbq %rdi, %rax
713; FAST-NEXT:    retq
714  %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
715  %obit = extractvalue {i64, i1} %t, 1
716  %ret = select i1 %obit, i64 %v1, i64 %v2
717  ret i64 %ret
718}
719
720;
721; Check the use of the overflow bit in combination with a branch instruction.
722;
723define zeroext i1 @saddobri32(i32 %v1, i32 %v2) {
724; SDAG-LABEL: saddobri32:
725; SDAG:       ## %bb.0:
726; SDAG-NEXT:    addl %esi, %edi
727; SDAG-NEXT:    jo LBB31_1
728; SDAG-NEXT:  ## %bb.2: ## %continue
729; SDAG-NEXT:    movb $1, %al
730; SDAG-NEXT:    retq
731; SDAG-NEXT:  LBB31_1: ## %overflow
732; SDAG-NEXT:    xorl %eax, %eax
733; SDAG-NEXT:    retq
734;
735; FAST-LABEL: saddobri32:
736; FAST:       ## %bb.0:
737; FAST-NEXT:    addl %esi, %edi
738; FAST-NEXT:    jo LBB31_1
739; FAST-NEXT:  ## %bb.2: ## %continue
740; FAST-NEXT:    movb $1, %al
741; FAST-NEXT:    andb $1, %al
742; FAST-NEXT:    movzbl %al, %eax
743; FAST-NEXT:    retq
744; FAST-NEXT:  LBB31_1: ## %overflow
745; FAST-NEXT:    xorl %eax, %eax
746; FAST-NEXT:    andb $1, %al
747; FAST-NEXT:    movzbl %al, %eax
748; FAST-NEXT:    retq
749  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
750  %val = extractvalue {i32, i1} %t, 0
751  %obit = extractvalue {i32, i1} %t, 1
752  br i1 %obit, label %overflow, label %continue, !prof !0
753
754overflow:
755  ret i1 false
756
757continue:
758  ret i1 true
759}
760
761define zeroext i1 @saddobri64(i64 %v1, i64 %v2) {
762; SDAG-LABEL: saddobri64:
763; SDAG:       ## %bb.0:
764; SDAG-NEXT:    addq %rsi, %rdi
765; SDAG-NEXT:    jo LBB32_1
766; SDAG-NEXT:  ## %bb.2: ## %continue
767; SDAG-NEXT:    movb $1, %al
768; SDAG-NEXT:    retq
769; SDAG-NEXT:  LBB32_1: ## %overflow
770; SDAG-NEXT:    xorl %eax, %eax
771; SDAG-NEXT:    retq
772;
773; FAST-LABEL: saddobri64:
774; FAST:       ## %bb.0:
775; FAST-NEXT:    addq %rsi, %rdi
776; FAST-NEXT:    jo LBB32_1
777; FAST-NEXT:  ## %bb.2: ## %continue
778; FAST-NEXT:    movb $1, %al
779; FAST-NEXT:    andb $1, %al
780; FAST-NEXT:    movzbl %al, %eax
781; FAST-NEXT:    retq
782; FAST-NEXT:  LBB32_1: ## %overflow
783; FAST-NEXT:    xorl %eax, %eax
784; FAST-NEXT:    andb $1, %al
785; FAST-NEXT:    movzbl %al, %eax
786; FAST-NEXT:    retq
787  %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
788  %val = extractvalue {i64, i1} %t, 0
789  %obit = extractvalue {i64, i1} %t, 1
790  br i1 %obit, label %overflow, label %continue, !prof !0
791
792overflow:
793  ret i1 false
794
795continue:
796  ret i1 true
797}
798
799define zeroext i1 @uaddobri32(i32 %v1, i32 %v2) {
800; SDAG-LABEL: uaddobri32:
801; SDAG:       ## %bb.0:
802; SDAG-NEXT:    addl %esi, %edi
803; SDAG-NEXT:    jb LBB33_1
804; SDAG-NEXT:  ## %bb.2: ## %continue
805; SDAG-NEXT:    movb $1, %al
806; SDAG-NEXT:    retq
807; SDAG-NEXT:  LBB33_1: ## %overflow
808; SDAG-NEXT:    xorl %eax, %eax
809; SDAG-NEXT:    retq
810;
811; FAST-LABEL: uaddobri32:
812; FAST:       ## %bb.0:
813; FAST-NEXT:    addl %esi, %edi
814; FAST-NEXT:    jb LBB33_1
815; FAST-NEXT:  ## %bb.2: ## %continue
816; FAST-NEXT:    movb $1, %al
817; FAST-NEXT:    andb $1, %al
818; FAST-NEXT:    movzbl %al, %eax
819; FAST-NEXT:    retq
820; FAST-NEXT:  LBB33_1: ## %overflow
821; FAST-NEXT:    xorl %eax, %eax
822; FAST-NEXT:    andb $1, %al
823; FAST-NEXT:    movzbl %al, %eax
824; FAST-NEXT:    retq
825  %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
826  %val = extractvalue {i32, i1} %t, 0
827  %obit = extractvalue {i32, i1} %t, 1
828  br i1 %obit, label %overflow, label %continue, !prof !0
829
830overflow:
831  ret i1 false
832
833continue:
834  ret i1 true
835}
836
837define zeroext i1 @uaddobri64(i64 %v1, i64 %v2) {
838; SDAG-LABEL: uaddobri64:
839; SDAG:       ## %bb.0:
840; SDAG-NEXT:    addq %rsi, %rdi
841; SDAG-NEXT:    jb LBB34_1
842; SDAG-NEXT:  ## %bb.2: ## %continue
843; SDAG-NEXT:    movb $1, %al
844; SDAG-NEXT:    retq
845; SDAG-NEXT:  LBB34_1: ## %overflow
846; SDAG-NEXT:    xorl %eax, %eax
847; SDAG-NEXT:    retq
848;
849; FAST-LABEL: uaddobri64:
850; FAST:       ## %bb.0:
851; FAST-NEXT:    addq %rsi, %rdi
852; FAST-NEXT:    jb LBB34_1
853; FAST-NEXT:  ## %bb.2: ## %continue
854; FAST-NEXT:    movb $1, %al
855; FAST-NEXT:    andb $1, %al
856; FAST-NEXT:    movzbl %al, %eax
857; FAST-NEXT:    retq
858; FAST-NEXT:  LBB34_1: ## %overflow
859; FAST-NEXT:    xorl %eax, %eax
860; FAST-NEXT:    andb $1, %al
861; FAST-NEXT:    movzbl %al, %eax
862; FAST-NEXT:    retq
863  %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
864  %val = extractvalue {i64, i1} %t, 0
865  %obit = extractvalue {i64, i1} %t, 1
866  br i1 %obit, label %overflow, label %continue, !prof !0
867
868overflow:
869  ret i1 false
870
871continue:
872  ret i1 true
873}
874
875define zeroext i1 @ssubobri32(i32 %v1, i32 %v2) {
876; SDAG-LABEL: ssubobri32:
877; SDAG:       ## %bb.0:
878; SDAG-NEXT:    cmpl %esi, %edi
879; SDAG-NEXT:    jo LBB35_1
880; SDAG-NEXT:  ## %bb.2: ## %continue
881; SDAG-NEXT:    movb $1, %al
882; SDAG-NEXT:    retq
883; SDAG-NEXT:  LBB35_1: ## %overflow
884; SDAG-NEXT:    xorl %eax, %eax
885; SDAG-NEXT:    retq
886;
887; FAST-LABEL: ssubobri32:
888; FAST:       ## %bb.0:
889; FAST-NEXT:    cmpl %esi, %edi
890; FAST-NEXT:    jo LBB35_1
891; FAST-NEXT:  ## %bb.2: ## %continue
892; FAST-NEXT:    movb $1, %al
893; FAST-NEXT:    andb $1, %al
894; FAST-NEXT:    movzbl %al, %eax
895; FAST-NEXT:    retq
896; FAST-NEXT:  LBB35_1: ## %overflow
897; FAST-NEXT:    xorl %eax, %eax
898; FAST-NEXT:    andb $1, %al
899; FAST-NEXT:    movzbl %al, %eax
900; FAST-NEXT:    retq
901  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
902  %val = extractvalue {i32, i1} %t, 0
903  %obit = extractvalue {i32, i1} %t, 1
904  br i1 %obit, label %overflow, label %continue, !prof !0
905
906overflow:
907  ret i1 false
908
909continue:
910  ret i1 true
911}
912
913define zeroext i1 @ssubobri64(i64 %v1, i64 %v2) {
914; SDAG-LABEL: ssubobri64:
915; SDAG:       ## %bb.0:
916; SDAG-NEXT:    cmpq %rsi, %rdi
917; SDAG-NEXT:    jo LBB36_1
918; SDAG-NEXT:  ## %bb.2: ## %continue
919; SDAG-NEXT:    movb $1, %al
920; SDAG-NEXT:    retq
921; SDAG-NEXT:  LBB36_1: ## %overflow
922; SDAG-NEXT:    xorl %eax, %eax
923; SDAG-NEXT:    retq
924;
925; FAST-LABEL: ssubobri64:
926; FAST:       ## %bb.0:
927; FAST-NEXT:    cmpq %rsi, %rdi
928; FAST-NEXT:    jo LBB36_1
929; FAST-NEXT:  ## %bb.2: ## %continue
930; FAST-NEXT:    movb $1, %al
931; FAST-NEXT:    andb $1, %al
932; FAST-NEXT:    movzbl %al, %eax
933; FAST-NEXT:    retq
934; FAST-NEXT:  LBB36_1: ## %overflow
935; FAST-NEXT:    xorl %eax, %eax
936; FAST-NEXT:    andb $1, %al
937; FAST-NEXT:    movzbl %al, %eax
938; FAST-NEXT:    retq
939  %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
940  %val = extractvalue {i64, i1} %t, 0
941  %obit = extractvalue {i64, i1} %t, 1
942  br i1 %obit, label %overflow, label %continue, !prof !0
943
944overflow:
945  ret i1 false
946
947continue:
948  ret i1 true
949}
950
951define zeroext i1 @usubobri32(i32 %v1, i32 %v2) {
952; SDAG-LABEL: usubobri32:
953; SDAG:       ## %bb.0:
954; SDAG-NEXT:    cmpl %esi, %edi
955; SDAG-NEXT:    jb LBB37_1
956; SDAG-NEXT:  ## %bb.2: ## %continue
957; SDAG-NEXT:    movb $1, %al
958; SDAG-NEXT:    retq
959; SDAG-NEXT:  LBB37_1: ## %overflow
960; SDAG-NEXT:    xorl %eax, %eax
961; SDAG-NEXT:    retq
962;
963; FAST-LABEL: usubobri32:
964; FAST:       ## %bb.0:
965; FAST-NEXT:    cmpl %esi, %edi
966; FAST-NEXT:    jb LBB37_1
967; FAST-NEXT:  ## %bb.2: ## %continue
968; FAST-NEXT:    movb $1, %al
969; FAST-NEXT:    andb $1, %al
970; FAST-NEXT:    movzbl %al, %eax
971; FAST-NEXT:    retq
972; FAST-NEXT:  LBB37_1: ## %overflow
973; FAST-NEXT:    xorl %eax, %eax
974; FAST-NEXT:    andb $1, %al
975; FAST-NEXT:    movzbl %al, %eax
976; FAST-NEXT:    retq
977  %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
978  %val = extractvalue {i32, i1} %t, 0
979  %obit = extractvalue {i32, i1} %t, 1
980  br i1 %obit, label %overflow, label %continue, !prof !0
981
982overflow:
983  ret i1 false
984
985continue:
986  ret i1 true
987}
988
989define zeroext i1 @usubobri64(i64 %v1, i64 %v2) {
990; SDAG-LABEL: usubobri64:
991; SDAG:       ## %bb.0:
992; SDAG-NEXT:    cmpq %rsi, %rdi
993; SDAG-NEXT:    jb LBB38_1
994; SDAG-NEXT:  ## %bb.2: ## %continue
995; SDAG-NEXT:    movb $1, %al
996; SDAG-NEXT:    retq
997; SDAG-NEXT:  LBB38_1: ## %overflow
998; SDAG-NEXT:    xorl %eax, %eax
999; SDAG-NEXT:    retq
1000;
1001; FAST-LABEL: usubobri64:
1002; FAST:       ## %bb.0:
1003; FAST-NEXT:    cmpq %rsi, %rdi
1004; FAST-NEXT:    jb LBB38_1
1005; FAST-NEXT:  ## %bb.2: ## %continue
1006; FAST-NEXT:    movb $1, %al
1007; FAST-NEXT:    andb $1, %al
1008; FAST-NEXT:    movzbl %al, %eax
1009; FAST-NEXT:    retq
1010; FAST-NEXT:  LBB38_1: ## %overflow
1011; FAST-NEXT:    xorl %eax, %eax
1012; FAST-NEXT:    andb $1, %al
1013; FAST-NEXT:    movzbl %al, %eax
1014; FAST-NEXT:    retq
1015  %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
1016  %val = extractvalue {i64, i1} %t, 0
1017  %obit = extractvalue {i64, i1} %t, 1
1018  br i1 %obit, label %overflow, label %continue, !prof !0
1019
1020overflow:
1021  ret i1 false
1022
1023continue:
1024  ret i1 true
1025}
1026
1027define {i64, i1} @uaddoovf(i64 %a, i64 %b) {
1028; SDAG-LABEL: uaddoovf:
1029; SDAG:       ## %bb.0:
1030; SDAG-NEXT:    movzbl %dil, %ecx
1031; SDAG-NEXT:    movzbl %sil, %eax
1032; SDAG-NEXT:    addq %rcx, %rax
1033; SDAG-NEXT:    xorl %edx, %edx
1034; SDAG-NEXT:    retq
1035;
1036; FAST-LABEL: uaddoovf:
1037; FAST:       ## %bb.0:
1038; FAST-NEXT:    movzbl %dil, %ecx
1039; FAST-NEXT:    movzbl %sil, %eax
1040; FAST-NEXT:    addq %rcx, %rax
1041; FAST-NEXT:    xorl %edx, %edx
1042; FAST-NEXT:    retq
1043  %1 = and i64 %a, 255
1044  %2 = and i64 %b, 255
1045  %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %1, i64 %2)
1046  ret {i64, i1} %t
1047}
1048
1049define {i64, i1} @usuboovf(i64 %a, i64 %b) {
1050; SDAG-LABEL: usuboovf:
1051; SDAG:       ## %bb.0:
1052; SDAG-NEXT:    movq %rsi, %rax
1053; SDAG-NEXT:    notq %rax
1054; SDAG-NEXT:    xorl %edx, %edx
1055; SDAG-NEXT:    retq
1056;
1057; FAST-LABEL: usuboovf:
1058; FAST:       ## %bb.0:
1059; FAST-NEXT:    movq %rsi, %rax
1060; FAST-NEXT:    notq %rax
1061; FAST-NEXT:    xorl %edx, %edx
1062; FAST-NEXT:    retq
1063  %t0 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %a)
1064  %v0 = extractvalue {i64, i1} %t0, 0
1065  %o0 = extractvalue {i64, i1} %t0, 1
1066  %t1 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 -1, i64 %b)
1067  %v1 = extractvalue {i64, i1} %t1, 0
1068  %o1 = extractvalue {i64, i1} %t1, 1
1069  %oo = or i1 %o0, %o1
1070  %t2 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v0)
1071  %v2 = extractvalue {i64, i1} %t2, 0
1072  %o2 = extractvalue {i64, i1} %t2, 1
1073  %ooo = or i1 %oo, %o2
1074  %t = insertvalue {i64, i1} %t2, i1 %ooo, 1
1075  ret {i64, i1} %t
1076}
1077
1078; Make sure we select an INC for both the data use and the flag use.
1079define i32 @incovfselectstore(i32 %v1, i32 %v2, i32* %x) {
1080; SDAG-LABEL: incovfselectstore:
1081; SDAG:       ## %bb.0:
1082; SDAG-NEXT:    movl %esi, %eax
1083; SDAG-NEXT:    movl %edi, %ecx
1084; SDAG-NEXT:    incl %ecx
1085; SDAG-NEXT:    cmovol %edi, %eax
1086; SDAG-NEXT:    movl %ecx, (%rdx)
1087; SDAG-NEXT:    retq
1088;
1089; FAST-LABEL: incovfselectstore:
1090; FAST:       ## %bb.0:
1091; FAST-NEXT:    movl %esi, %eax
1092; FAST-NEXT:    movl %edi, %ecx
1093; FAST-NEXT:    incl %ecx
1094; FAST-NEXT:    cmovol %edi, %eax
1095; FAST-NEXT:    movl %ecx, (%rdx)
1096; FAST-NEXT:    retq
1097  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 1)
1098  %obit = extractvalue {i32, i1} %t, 1
1099  %ret = select i1 %obit, i32 %v1, i32 %v2
1100  %val = extractvalue {i32, i1} %t, 0
1101  store i32 %val, i32* %x
1102  ret i32 %ret
1103}
1104
1105; Make sure we select a DEC for both the data use and the flag use.
1106define i32 @decovfselectstore(i32 %v1, i32 %v2, i32* %x) {
1107; GENERIC-LABEL: decovfselectstore:
1108; GENERIC:       ## %bb.0:
1109; GENERIC-NEXT:    movl %esi, %eax
1110; GENERIC-NEXT:    movl %edi, %ecx
1111; GENERIC-NEXT:    decl %ecx
1112; GENERIC-NEXT:    cmovol %edi, %eax
1113; GENERIC-NEXT:    movl %ecx, (%rdx)
1114; GENERIC-NEXT:    retq
1115;
1116; FAST-LABEL: decovfselectstore:
1117; FAST:       ## %bb.0:
1118; FAST-NEXT:    movl %esi, %eax
1119; FAST-NEXT:    movl %edi, %ecx
1120; FAST-NEXT:    decl %ecx
1121; FAST-NEXT:    cmovol %edi, %eax
1122; FAST-NEXT:    movl %ecx, (%rdx)
1123; FAST-NEXT:    retq
1124;
1125; KNL-LABEL: decovfselectstore:
1126; KNL:       ## %bb.0:
1127; KNL-NEXT:    movl %esi, %eax
1128; KNL-NEXT:    movl %edi, %ecx
1129; KNL-NEXT:    addl $-1, %ecx
1130; KNL-NEXT:    cmovol %edi, %eax
1131; KNL-NEXT:    movl %ecx, (%rdx)
1132; KNL-NEXT:    retq
1133  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 1)
1134  %obit = extractvalue {i32, i1} %t, 1
1135  %ret = select i1 %obit, i32 %v1, i32 %v2
1136  %val = extractvalue {i32, i1} %t, 0
1137  store i32 %val, i32* %x
1138  ret i32 %ret
1139}
1140
1141declare {i8,  i1} @llvm.sadd.with.overflow.i8 (i8,  i8 ) nounwind readnone
1142declare {i16, i1} @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
1143declare {i32, i1} @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
1144declare {i64, i1} @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
1145declare {i8,  i1} @llvm.uadd.with.overflow.i8 (i8,  i8 ) nounwind readnone
1146declare {i16, i1} @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
1147declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
1148declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
1149declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone
1150declare {i64, i1} @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone
1151declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
1152declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
1153
1154!0 = !{!"branch_weights", i32 0, i32 2147483647}
1155