File: binops-multiuse.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (265 lines) | stat: -rw-r--r-- 10,317 bytes parent folder | download | duplicates (3)
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=bdce < %s | FileCheck %s

define void @or(i64 %a) {
; CHECK-LABEL: define void @or(
; CHECK-SAME: i64 [[A:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[A]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[A]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %or = or i64 %a, 3                              ; Mask:          0000 0011
  %ret1 = and i64 %or, 8                          ; Demanded bits: 0000 1000
  %ret2 = and i64 %or, 16                         ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @xor(i64 %a) {
; CHECK-LABEL: define void @xor(
; CHECK-SAME: i64 [[A:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[A]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[A]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %xor = xor i64 %a, 3                            ; Mask:          0000 0011
  %ret1 = and i64 %xor, 8                         ; Demanded bits: 0000 1000
  %ret2 = and i64 %xor, 16                        ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @and(i64 %a) {
; CHECK-LABEL: define void @and(
; CHECK-SAME: i64 [[A:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[A]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[A]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and = and i64 %a, 24                           ; Mask:          0001 1000
  %ret1 = and i64 %and, 8                         ; Demanded bits: 0000 1000
  %ret2 = and i64 %and, 16                        ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @or_of_and(i64 %a, i64 %b) {
; CHECK-LABEL: define void @or_of_and(
; CHECK-SAME: i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[OR:%.*]] = or i64 [[A]], [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[OR]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[OR]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 24                          ; Mask:          0001 1000
  %and2 = and i64 %b, 25                          ; Mask:          0001 1001
  %or = or i64 %and1, %and2
  %ret1 = and i64 %or, 8                          ; Demanded bits: 0000 1000
  %ret2 = and i64 %or, 16                         ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @or_disjoint_of_and(i64 %a, i64 %b) {
; CHECK-LABEL: define void @or_disjoint_of_and(
; CHECK-SAME: i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[OR:%.*]] = or i64 [[A]], [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[OR]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[OR]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 56                          ; Mask:          0011 1000
  %and2 = and i64 %b, 25                          ; Mask:          0001 1001
  %or = or disjoint i64 %and1, %and2
  %ret1 = and i64 %or, 8                          ; Demanded bits: 0000 1000
  %ret2 = and i64 %or, 16                         ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_of_and(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_and(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[A]], i64 [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 24                          ; Mask:          0001 1000
  %and2 = and i64 %b, 25                          ; Mask:          0001 1001
  %s = select i1 %c, i64 %and1, i64 %and2
  %ret1 = and i64 %s, 8                           ; Demanded bits: 0000 1000
  %ret2 = and i64 %s, 16                          ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_of_and_2(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_and_2(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[AND2:%.*]] = and i64 [[B]], 23
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[A]], i64 [[AND2]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 25                          ; Mask:          0001 1001
  %and2 = and i64 %b, 23                          ; Mask:          0001 0111
  %s = select i1 %c, i64 %and1, i64 %and2
  %ret1 = and i64 %s, 8                           ; Demanded bits: 0000 1000
  %ret2 = and i64 %s, 16                          ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_of_and_multiuse(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_and_multiuse(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[AND2:%.*]] = and i64 [[B]], 25
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[A]], i64 [[AND2]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use2(i64 [[RET2]], i64 [[AND2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 24                          ; Mask:          0001 1000
  %and2 = and i64 %b, 25                          ; Mask:          0001 1001
  %s = select i1 %c, i64 %and1, i64 %and2
  %ret1 = and i64 %s, 8                           ; Demanded bits: 0000 1000
  %ret2 = and i64 %s, 16                          ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use2(i64 %ret2, i64 %and2)
  ret void
}

define void @select_of_and_different_demanded(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_and_different_demanded(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[AND1:%.*]] = and i64 0, 24
; CHECK-NEXT:    [[AND2:%.*]] = and i64 [[B]], 25
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[AND1]], i64 [[AND2]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 3
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 7
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and i64 %a, 24                          ; Mask:          0001 1000
  %and2 = and i64 %b, 25                          ; Mask:          0001 1001
  %s = select i1 %c, i64 %and1, i64 %and2
  %ret1 = and i64 %s, 3                           ; Demanded bits: 0000 0011
  %ret2 = and i64 %s, 7                           ; Demanded bits: 0000 0111
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_of_or(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_or(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[A]], i64 [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %or1 = or i64 %a, 3                             ; Mask:          0000 0011
  %or2 = or i64 %b, 192                           ; Mask:          1100 0000
  %s = select i1 %c, i64 %or1, i64 %or2
  %ret1 = and i64 %s, 8                           ; Demanded bits: 0000 1000
  %ret2 = and i64 %s, 16                          ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_of_xor(i1 %c, i64 %a, i64 %b) {
; CHECK-LABEL: define void @select_of_xor(
; CHECK-SAME: i1 [[C:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], i64 [[A]], i64 [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and i64 [[S]], 8
; CHECK-NEXT:    [[RET2:%.*]] = and i64 [[S]], 16
; CHECK-NEXT:    call void @use(i64 [[RET1]])
; CHECK-NEXT:    call void @use(i64 [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %xor1 = xor i64 %a, 128                         ; Mask:          1000 0000
  %xor2 = xor i64 %b, 36                          ; Mask:          0010 0100
  %s = select i1 %c, i64 %xor1, i64 %xor2
  %ret1 = and i64 %s, 8                           ; Demanded bits: 0000 1000
  %ret2 = and i64 %s, 16                          ; Demanded bits: 0001 0000
  call void @use(i64 %ret1)
  call void @use(i64 %ret2)
  ret void
}

define void @select_vectorized(i1 %c, <2 x i8> %a, <2 x i8> %b) {
; CHECK-LABEL: define void @select_vectorized(
; CHECK-SAME: i1 [[C:%.*]], <2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C]], <2 x i8> [[A]], <2 x i8> [[B]]
; CHECK-NEXT:    [[RET1:%.*]] = and <2 x i8> [[S]], <i8 4, i8 4>
; CHECK-NEXT:    [[RET2:%.*]] = and <2 x i8> [[S]], <i8 12, i8 12>
; CHECK-NEXT:    call void @use3(<2 x i8> [[RET1]])
; CHECK-NEXT:    call void @use3(<2 x i8> [[RET2]])
; CHECK-NEXT:    ret void
;
entry:
  %and1 = and <2 x i8> %a, <i8 28, i8 28>
  %and2 = and <2 x i8> %b, <i8 29, i8 29>
  %s = select i1 %c, <2 x i8> %and1, <2 x i8> %and2
  %ret1 = and <2 x i8> %s, <i8 4, i8 4>
  %ret2 = and <2 x i8> %s, <i8 12, i8 12>
  call void @use3(<2 x i8> %ret1)
  call void @use3(<2 x i8> %ret2)
  ret void
}

declare void @use(i64)
declare void @use2(i64, i64)
declare void @use3(<2 x i8>)