File: icmp-monotonic.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (218 lines) | stat: -rw-r--r-- 7,023 bytes parent folder | download | duplicates (2)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=instsimplify < %s | FileCheck %s

define i1 @lshr_or_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_uge_swapped(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_uge_swapped(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp uge i32 %op2, %op1
  ret i1 %cmp
}

define i1 @lshr_or_ugt(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_ugt(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 false
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp ugt i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_ult_wrong_pred(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_ult_wrong_pred(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[X]], [[Y]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp ult i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_sle_wrong_pred(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_sle_wrong_pred(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[X]], [[Y]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp sle i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp sle i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_swapped_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_swapped_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %z, %x
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_ule_invalid_swapped(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_or_ule_invalid_swapped(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[Y]], [[X]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %y, %x
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @and_uadd_sat_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @and_uadd_sat_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = and i32 %x, %y
  %op2 = call i32 @llvm.uadd.sat(i32 %x, i32 %z)
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @urem_or_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @urem_or_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = urem i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @urem_or_ule_invalid_swapped(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @urem_or_ule_invalid_swapped(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = urem i32 [[Y]], [[X]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = urem i32 %y, %x
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @udiv_or_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @udiv_or_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = udiv i32 %x, %y
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @udiv_or_ule_invalid_swapped(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @udiv_or_ule_invalid_swapped(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = udiv i32 [[Y]], [[X]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = udiv i32 %y, %x
  %op2 = or i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @usub_sat_uadd_sat_ule(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @usub_sat_uadd_sat_ule(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    ret i1 true
;
  %op1 = call i32 @llvm.usub.sat(i32 %x, i32 %y)
  %op2 = call i32 @llvm.uadd.sat(i32 %x, i32 %z)
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @usub_sat_uadd_sat_ule_invalid_swapped(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @usub_sat_uadd_sat_ule_invalid_swapped(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = call i32 @llvm.usub.sat.i32(i32 [[Y]], i32 [[X]])
; CHECK-NEXT:    [[OP2:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[X]], i32 [[Z]])
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = call i32 @llvm.usub.sat(i32 %y, i32 %x)
  %op2 = call i32 @llvm.uadd.sat(i32 %x, i32 %z)
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_ule_no_common_op(i32 %x, i32 %y, i32 %z, i32 %w) {
; CHECK-LABEL: define i1 @lshr_or_ule_no_common_op(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]], i32 [[W:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[X]], [[Y]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[W]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %w, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}

define i1 @lshr_or_ule_nested(i32 %x, i32 %y, i32 %z, i32 %w) {
; CHECK-LABEL: define i1 @lshr_or_ule_nested(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]], i32 [[W:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[X]], [[Y]]
; CHECK-NEXT:    [[OP2:%.*]] = or i32 [[X]], [[Z]]
; CHECK-NEXT:    [[OP3:%.*]] = or i32 [[OP2]], [[W]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP3]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %x, %y
  %op2 = or i32 %x, %z
  %op3 = or i32 %op2, %w
  %cmp = icmp ule i32 %op1, %op3
  ret i1 %cmp
}

define i1 @lshr_add_ule_non_monotonic(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @lshr_add_ule_non_monotonic(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
; CHECK-NEXT:    [[OP1:%.*]] = lshr i32 [[X]], [[Y]]
; CHECK-NEXT:    [[OP2:%.*]] = add i32 [[X]], [[Z]]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[OP1]], [[OP2]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %op1 = lshr i32 %x, %y
  %op2 = add i32 %x, %z
  %cmp = icmp ule i32 %op1, %op2
  ret i1 %cmp
}