• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=i686-linux | FileCheck %s
2
3@ok = internal constant [4 x i8] c"%d\0A\00"
4@no = internal constant [4 x i8] c"no\0A\00"
5
6define i1 @func1(i32 %v1, i32 %v2) nounwind {
7entry:
8  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
9  %sum = extractvalue {i32, i1} %t, 0
10  %obit = extractvalue {i32, i1} %t, 1
11  br i1 %obit, label %overflow, label %normal
12
13normal:
14  %t1 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind
15  ret i1 true
16
17overflow:
18  %t2 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @no, i32 0, i32 0) ) nounwind
19  ret i1 false
20
21; CHECK-LABEL: func1:
22; CHECK: subl 20(%esp)
23; CHECK-NEXT: jno
24}
25
26define i1 @func2(i32 %v1, i32 %v2) nounwind {
27entry:
28  %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
29  %sum = extractvalue {i32, i1} %t, 0
30  %obit = extractvalue {i32, i1} %t, 1
31  br i1 %obit, label %carry, label %normal
32
33normal:
34  %t1 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind
35  ret i1 true
36
37carry:
38  %t2 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @no, i32 0, i32 0) ) nounwind
39  ret i1 false
40
41; CHECK-LABEL: func2:
42; CHECK: subl 20(%esp)
43; CHECK-NEXT: jae
44}
45
46declare i32 @printf(i8*, ...) nounwind
47declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32)
48declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32)
49
50define i1 @func3(i32 %x) nounwind {
51entry:
52  %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %x, i32 1)
53  %obit = extractvalue {i32, i1} %t, 1
54  ret i1 %obit
55
56; CHECK-LABEL: func3:
57; CHECK: decl
58; CHECK-NEXT: seto
59}
60