constant-range-struct.ll
4.74 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt %s -ipsccp -S | FileCheck %s
declare i1 @cond()
declare void @use(i1)
define internal {i64, i64} @struct1() {
; CHECK-LABEL: @struct1(
; CHECK-NEXT: [[C:%.*]] = call i1 @cond()
; CHECK-NEXT: br i1 [[C]], label [[TRUE:%.*]], label [[FALSE:%.*]]
; CHECK: true:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: false:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[R:%.*]] = phi { i64, i64 } [ { i64 20, i64 200 }, [[TRUE]] ], [ { i64 30, i64 300 }, [[FALSE]] ]
; CHECK-NEXT: ret { i64, i64 } [[R]]
;
%c = call i1 @cond()
br i1 %c, label %true, label %false
true:
%s.1 = insertvalue {i64, i64} undef, i64 20, 0
%s.2 = insertvalue {i64, i64} %s.1, i64 200, 1
br label %exit
false:
%s.3 = insertvalue {i64, i64} undef, i64 30, 0
%s.4 = insertvalue {i64, i64} %s.3, i64 300, 1
br label %exit
exit:
%r = phi {i64, i64} [ %s.2, %true], [ %s.4, %false ]
ret {i64, i64} %r
}
define void @struct1_caller() {
; CHECK-LABEL: @struct1_caller(
; CHECK-NEXT: [[S:%.*]] = call { i64, i64 } @struct1()
; CHECK-NEXT: [[V1:%.*]] = extractvalue { i64, i64 } [[S]], 0
; CHECK-NEXT: [[V2:%.*]] = extractvalue { i64, i64 } [[S]], 1
; CHECK-NEXT: [[T_1:%.*]] = icmp ne i64 [[V1]], 10
; CHECK-NEXT: call void @use(i1 [[T_1]])
; CHECK-NEXT: [[T_2:%.*]] = icmp ult i64 [[V1]], 100
; CHECK-NEXT: call void @use(i1 [[T_2]])
; CHECK-NEXT: [[T_3:%.*]] = icmp ne i64 [[V2]], 0
; CHECK-NEXT: call void @use(i1 [[T_3]])
; CHECK-NEXT: [[T_4:%.*]] = icmp ult i64 [[V2]], 301
; CHECK-NEXT: call void @use(i1 [[T_4]])
; CHECK-NEXT: ret void
;
%s = call {i64, i64} @struct1()
%v1 = extractvalue {i64, i64} %s, 0
%v2 = extractvalue {i64, i64} %s, 1
%t.1 = icmp ne i64 %v1, 10
call void @use(i1 %t.1)
%t.2 = icmp ult i64 %v1, 100
call void @use(i1 %t.2)
%t.3 = icmp ne i64 %v2, 0
call void @use(i1 %t.3)
%t.4 = icmp ult i64 %v2, 301
call void @use(i1 %t.4)
ret void
}
define internal {i64, i64} @struct2() {
; CHECK-LABEL: @struct2(
; CHECK-NEXT: [[C:%.*]] = call i1 @cond()
; CHECK-NEXT: br i1 [[C]], label [[TRUE:%.*]], label [[FALSE:%.*]]
; CHECK: true:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: false:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[V1:%.*]] = phi i64 [ 20, [[TRUE]] ], [ 30, [[FALSE]] ]
; CHECK-NEXT: [[V2:%.*]] = phi i64 [ 200, [[TRUE]] ], [ 300, [[FALSE]] ]
; CHECK-NEXT: [[S_1:%.*]] = insertvalue { i64, i64 } undef, i64 [[V1]], 0
; CHECK-NEXT: [[S_2:%.*]] = insertvalue { i64, i64 } [[S_1]], i64 [[V2]], 1
; CHECK-NEXT: ret { i64, i64 } [[S_2]]
;
%c = call i1 @cond()
br i1 %c, label %true, label %false
true:
br label %exit
false:
br label %exit
exit:
%v1 = phi i64 [ 20, %true ], [ 30, %false ]
%v2 = phi i64 [ 200, %true ], [ 300, %false ]
%s.1 = insertvalue {i64, i64} undef, i64 %v1, 0
%s.2 = insertvalue {i64, i64} %s.1, i64 %v2, 1
ret {i64, i64} %s.2
}
define void @struct2_caller() {
; CHECK-LABEL: @struct2_caller(
; CHECK-NEXT: [[S:%.*]] = call { i64, i64 } @struct2()
; CHECK-NEXT: [[V1:%.*]] = extractvalue { i64, i64 } [[S]], 0
; CHECK-NEXT: [[V2:%.*]] = extractvalue { i64, i64 } [[S]], 1
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i64 [[V1]], 25
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: [[C_2:%.*]] = icmp ult i64 [[V1]], 25
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: [[C_3:%.*]] = icmp eq i64 [[V2]], 250
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp ugt i64 [[V2]], 250
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: ret void
;
%s = call {i64, i64} @struct2()
%v1 = extractvalue {i64, i64} %s, 0
%v2 = extractvalue {i64, i64} %s, 1
%t.1 = icmp ne i64 %v1, 10
call void @use(i1 %t.1)
%t.2 = icmp ult i64 %v1, 100
call void @use(i1 %t.2)
%t.3 = icmp ne i64 %v2, 0
call void @use(i1 %t.3)
%t.4 = icmp ult i64 %v2, 301
call void @use(i1 %t.4)
%f.1 = icmp eq i64 %v1, 10
call void @use(i1 %f.1)
%f.2 = icmp ult i64 %v1, 19
call void @use(i1 %f.2)
%f.3 = icmp eq i64 %v2, 50
call void @use(i1 %f.3)
%f.4 = icmp ugt i64 %v2, 301
call void @use(i1 %f.4)
%c.1 = icmp eq i64 %v1, 25
call void @use(i1 %c.1)
%c.2 = icmp ult i64 %v1, 25
call void @use(i1 %c.2)
%c.3 = icmp eq i64 %v2, 250
call void @use(i1 %c.3)
%c.4 = icmp ugt i64 %v2, 250
call void @use(i1 %c.4)
ret void
}