predicateinfo-cond.ll
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -ipsccp < %s | FileCheck %s
; Test that information about the true/false value of conditions themselves
; is also used, not information implied by comparisions.
define i32 @switch(i32 %x) {
; CHECK-LABEL: @switch(
; CHECK-NEXT: switch i32 [[X:%.*]], label [[CASE_DEFAULT:%.*]] [
; CHECK-NEXT: i32 0, label [[CASE_0:%.*]]
; CHECK-NEXT: i32 2, label [[CASE_2:%.*]]
; CHECK-NEXT: ]
; CHECK: case.0:
; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X]], 1
; CHECK-NEXT: br label [[END:%.*]]
; CHECK: case.2:
; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[X]], 1
; CHECK-NEXT: br label [[END]]
; CHECK: case.default:
; CHECK-NEXT: br label [[END]]
; CHECK: end:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[ADD]], [[CASE_0]] ], [ [[SUB]], [[CASE_2]] ], [ 1, [[CASE_DEFAULT]] ]
; CHECK-NEXT: ret i32 [[PHI]]
;
switch i32 %x, label %case.default [
i32 0, label %case.0
i32 2, label %case.2
]
case.0:
%add = add i32 %x, 1
br label %end
case.2:
%sub = sub i32 %x, 1
br label %end
case.default:
br label %end
end:
%phi = phi i32 [ %add, %case.0 ], [ %sub, %case.2 ], [ 1, %case.default]
ret i32 %phi
}
define i1 @assume(i32 %x) {
; CHECK-LABEL: @assume(
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: ret i1 [[CMP]]
;
%cmp = icmp sge i32 %x, 0
call void @llvm.assume(i1 %cmp)
ret i1 %cmp
}
define i32 @branch(i32 %x) {
; CHECK-LABEL: @branch(
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_THEN2:%.*]]
; CHECK: if.then1:
; CHECK-NEXT: br i1 [[CMP]], label [[IF2_THEN1:%.*]], label [[IF2_THEN2:%.*]]
; CHECK: if2.then1:
; CHECK-NEXT: br label [[IF2_END:%.*]]
; CHECK: if2.then2:
; CHECK-NEXT: br label [[IF2_END]]
; CHECK: if2.end:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 0, [[IF2_THEN1]] ], [ 1, [[IF2_THEN2]] ]
; CHECK-NEXT: ret i32 [[PHI]]
; CHECK: if.then2:
; CHECK-NEXT: br i1 [[CMP]], label [[IF3_THEN1:%.*]], label [[IF3_THEN2:%.*]]
; CHECK: if3.then1:
; CHECK-NEXT: br label [[IF3_END:%.*]]
; CHECK: if3.then2:
; CHECK-NEXT: br label [[IF3_END]]
; CHECK: if3.end:
; CHECK-NEXT: [[PHI2:%.*]] = phi i32 [ 0, [[IF3_THEN1]] ], [ 1, [[IF3_THEN2]] ]
; CHECK-NEXT: ret i32 [[PHI2]]
;
%cmp = icmp sge i32 %x, 0
br i1 %cmp, label %if.then1, label %if.then2
if.then1:
br i1 %cmp, label %if2.then1, label %if2.then2
if2.then1:
br label %if2.end
if2.then2:
br label %if2.end
if2.end:
%phi = phi i32 [ 0, %if2.then1 ], [ 1, %if2.then2 ]
ret i32 %phi
if.then2:
br i1 %cmp, label %if3.then1, label %if3.then2
if3.then1:
br label %if3.end
if3.then2:
br label %if3.end
if3.end:
%phi2 = phi i32 [ 0, %if3.then1 ], [ 1, %if3.then2 ]
ret i32 %phi2
}
declare void @llvm.assume(i1)