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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
declare void @foo()
define i1 @test1(i32 %a, i32 %b) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = icmp slt i32 %a, 0
%2 = icmp slt i32 %b, 0
%or.cond = or i1 %1, %2
ret i1 %or.cond
}
define i1 @test2(i32 %a, i32 %b) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = icmp sgt i32 %a, -1
%2 = icmp sgt i32 %b, -1
%or.cond = or i1 %1, %2
ret i1 %or.cond
}
define i1 @test3(i32 %a, i32 %b) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = icmp slt i32 %a, 0
%2 = icmp slt i32 %b, 0
%or.cond = and i1 %1, %2
ret i1 %or.cond
}
define i1 @test4(i32 %a, i32 %b) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = icmp sgt i32 %a, -1
%2 = icmp sgt i32 %b, -1
%or.cond = and i1 %1, %2
ret i1 %or.cond
}
define void @test5(i32 %a) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end
;
%and = and i32 %a, 134217728
%1 = icmp eq i32 %and, 0
%2 = icmp sgt i32 %a, -1
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
if.then:
tail call void @foo() nounwind
ret void
if.end:
ret void
}
define void @test6(i32 %a) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end
;
%1 = icmp sgt i32 %a, -1
%and = and i32 %a, 134217728
%2 = icmp eq i32 %and, 0
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
if.then:
tail call void @foo() nounwind
ret void
if.end:
ret void
}
define void @test7(i32 %a) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then
;
%and = and i32 %a, 134217728
%1 = icmp ne i32 %and, 0
%2 = icmp slt i32 %a, 0
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
if.then:
tail call void @foo() nounwind
ret void
if.end:
ret void
}
define void @test8(i32 %a) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then
;
%1 = icmp slt i32 %a, 0
%and = and i32 %a, 134217728
%2 = icmp ne i32 %and, 0
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
if.then:
tail call void @foo()
ret void
if.end:
ret void
}
define i1 @test9(i32 %a) {
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -1073741824
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 1073741824
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = and i32 %a, 1073741824
%2 = icmp ne i32 %1, 0
%3 = icmp sgt i32 %a, -1
%or.cond = and i1 %2, %3
ret i1 %or.cond
}
define i1 @test10(i32 %a) {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 %a, 2
; CHECK-NEXT: ret i1 [[TMP1]]
;
%1 = and i32 %a, 2
%2 = icmp eq i32 %1, 0
%3 = icmp ult i32 %a, 4
%or.cond = and i1 %2, %3
ret i1 %or.cond
}
define i1 @test11(i32 %a) {
; CHECK-LABEL: @test11(
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %a, 1
; CHECK-NEXT: ret i1 [[TMP1]]
;
%1 = and i32 %a, 2
%2 = icmp ne i32 %1, 0
%3 = icmp ugt i32 %a, 3
%or.cond = or i1 %2, %3
ret i1 %or.cond
}
|