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
266
267
268
269
270
271
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefixes=X64
; Test for https://github.com/llvm/llvm-project/issues/123239
define i1 @test_ult_trunc_add(i64 %x) {
; X64-LABEL: test_ult_trunc_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: addl $14, %edi
; X64-NEXT: movzwl %di, %eax
; X64-NEXT: cmpl $3, %eax
; X64-NEXT: setb %al
; X64-NEXT: retq
%add = add i64 %x, 3940649673949184
%shr = lshr i64 %add, 48
%conv = trunc i64 %shr to i32
%res = icmp ult i32 %conv, 3
ret i1 %res
}
define i1 @test_ult_add(i64 %x) {
; X64-LABEL: test_ult_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: addl $14, %edi
; X64-NEXT: movzwl %di, %eax
; X64-NEXT: cmpl $3, %eax
; X64-NEXT: setb %al
; X64-NEXT: retq
%add = add i64 3940649673949184, %x
%cmp = icmp ult i64 %add, 844424930131968
ret i1 %cmp
}
define i1 @test_ugt_trunc_add(i64 %x) {
; X64-LABEL: test_ugt_trunc_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: addl $14, %edi
; X64-NEXT: movzwl %di, %eax
; X64-NEXT: cmpl $4, %eax
; X64-NEXT: setae %al
; X64-NEXT: retq
%add = add i64 %x, 3940649673949184
%shr = lshr i64 %add, 48
%conv = trunc i64 %shr to i32
%res = icmp ugt i32 %conv, 3
ret i1 %res
}
define i1 @test_ugt_add(i64 %x) {
; X64-LABEL: test_ugt_add:
; X64: # %bb.0:
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
; X64-NEXT: addq %rdi, %rax
; X64-NEXT: movabsq $844424930131968, %rcx # imm = 0x3000000000000
; X64-NEXT: cmpq %rcx, %rax
; X64-NEXT: seta %al
; X64-NEXT: retq
%add = add i64 3940649673949184, %x
%cmp = icmp ugt i64 %add, 844424930131968
ret i1 %cmp
}
define i1 @test_eq_trunc_add(i64 %x) {
; X64-LABEL: test_eq_trunc_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: cmpl $65525, %edi # imm = 0xFFF5
; X64-NEXT: sete %al
; X64-NEXT: retq
%add = add i64 %x, 3940649673949184
%shr = lshr i64 %add, 48
%conv = trunc i64 %shr to i32
%res = icmp eq i32 %conv, 3
ret i1 %res
}
define i1 @test_eq_add(i64 %x) {
; X64-LABEL: test_eq_add:
; X64: # %bb.0:
; X64-NEXT: movabsq $-3096224743817216, %rax # imm = 0xFFF5000000000000
; X64-NEXT: cmpq %rax, %rdi
; X64-NEXT: sete %al
; X64-NEXT: retq
%add = add i64 3940649673949184, %x
%cmp = icmp eq i64 %add, 844424930131968
ret i1 %cmp
}
define i1 @test_ne_trunc_add(i64 %x) {
; X64-LABEL: test_ne_trunc_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: cmpl $65525, %edi # imm = 0xFFF5
; X64-NEXT: setne %al
; X64-NEXT: retq
%add = add i64 %x, 3940649673949184
%shr = lshr i64 %add, 48
%conv = trunc i64 %shr to i32
%res = icmp ne i32 %conv, 3
ret i1 %res
}
define i1 @test_ne_add(i64 %x) {
; X64-LABEL: test_ne_add:
; X64: # %bb.0:
; X64-NEXT: movabsq $-3096224743817216, %rax # imm = 0xFFF5000000000000
; X64-NEXT: cmpq %rax, %rdi
; X64-NEXT: setne %al
; X64-NEXT: retq
%add = add i64 3940649673949184, %x
%cmp = icmp ne i64 %add, 844424930131968
ret i1 %cmp
}
define i32 @test_trunc_add(i64 %x) {
; X64-LABEL: test_trunc_add:
; X64: # %bb.0:
; X64-NEXT: shrq $48, %rdi
; X64-NEXT: addl $14, %edi
; X64-NEXT: movzwl %di, %eax
; X64-NEXT: retq
%add = add i64 %x, 3940649673949184
%shr = lshr i64 %add, 48
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_sub(i64 %x) {
; X64-LABEL: test_trunc_sub:
; X64: # %bb.0:
; X64-NEXT: shrq $49, %rdi
; X64-NEXT: leal 32762(%rdi), %eax
; X64-NEXT: andl $32767, %eax # imm = 0x7FFF
; X64-NEXT: retq
%sub = sub i64 %x, 3377699720527872
%shr = lshr i64 %sub, 49
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_and_1(i64 %x) {
; X64-LABEL: test_trunc_and_1:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $50, %rax
; X64-NEXT: andl $3, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%and = and i64 %x, 3940649673949184
%shr = lshr i64 %and, 50
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_or_1(i64 %x) {
; X64-LABEL: test_trunc_or_1:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $50, %rax
; X64-NEXT: orl $3, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%or = or i64 %x, 3940649673949184
%shr = lshr i64 %or, 50
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_xor_1(i64 %x) {
; X64-LABEL: test_trunc_xor_1:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $50, %rax
; X64-NEXT: xorl $3, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%xor = xor i64 %x, 3940649673949184
%shr = lshr i64 %xor, 50
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_and_2(i64 %x) {
; X64-LABEL: test_trunc_and_2:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $45, %rax
; X64-NEXT: andl $111, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%and = and i64 %x, 3940649673949183
%shr = lshr i64 %and, 45
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_or_2(i64 %x) {
; X64-LABEL: test_trunc_or_2:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $45, %rax
; X64-NEXT: orl $111, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%or = or i64 %x, 3940649673949183
%shr = lshr i64 %or, 45
%conv = trunc i64 %shr to i32
ret i32 %conv
}
define i32 @test_trunc_xor_2(i64 %x) {
; X64-LABEL: test_trunc_xor_2:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: shrq $45, %rax
; X64-NEXT: xorl $111, %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%xor = xor i64 %x, 3940649673949183
%shr = lshr i64 %xor, 45
%conv = trunc i64 %shr to i32
ret i32 %conv
}
; Make sure we don't crash on this test case.
define i32 @pr128158(i64 %x) {
; X64-LABEL: pr128158:
; X64: # %bb.0: # %entry
; X64-NEXT: movabsq $-4294967296, %rax # imm = 0xFFFFFFFF00000000
; X64-NEXT: addq %rdi, %rax
; X64-NEXT: shrq $32, %rax
; X64-NEXT: .p2align 4
; X64-NEXT: .LBB16_1: # %for.body
; X64-NEXT: # =>This Inner Loop Header: Depth=1
; X64-NEXT: cmpl $9, %eax
; X64-NEXT: jb .LBB16_1
; X64-NEXT: # %bb.2: # %exit
; X64-NEXT: xorl %eax, %eax
; X64-NEXT: retq
entry:
br label %for.body
for.body:
%add = add i64 %x, -4294967296
%cmp = icmp ult i64 %add, 38654705664
br i1 %cmp, label %for.body, label %exit
exit:
ret i32 0
}
define i64 @pr128309(i64 %x) {
; X64-LABEL: pr128309:
; X64: # %bb.0: # %entry
; X64-NEXT: movl %edi, %eax
; X64-NEXT: andl $18114, %eax # imm = 0x46C2
; X64-NEXT: addl $6, %eax
; X64-NEXT: andl %edi, %eax
; X64-NEXT: retq
entry:
%shl = shl i64 %x, 48
%and = and i64 %shl, 5098637728136822784
%add = add i64 %and, 1688849860263936
%lshr = lshr i64 %add, 48
%res = and i64 %lshr, %x
ret i64 %res
}
|