1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,X64
5 define void @knownbits_zext_in_reg(ptr) nounwind {
6 ; X86-LABEL: knownbits_zext_in_reg:
9 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
10 ; X86-NEXT: movzbl (%eax), %ecx
11 ; X86-NEXT: imull $101, %ecx, %eax
12 ; X86-NEXT: shrl $14, %eax
13 ; X86-NEXT: imull $177, %ecx, %edx
14 ; X86-NEXT: shrl $14, %edx
15 ; X86-NEXT: movzbl %al, %ecx
16 ; X86-NEXT: xorl %ebx, %ebx
17 ; X86-NEXT: .p2align 4, 0x90
18 ; X86-NEXT: .LBB0_1: # %CF
19 ; X86-NEXT: # =>This Loop Header: Depth=1
20 ; X86-NEXT: # Child Loop BB0_2 Depth 2
21 ; X86-NEXT: movl %ecx, %eax
23 ; X86-NEXT: .p2align 4, 0x90
24 ; X86-NEXT: .LBB0_2: # %CF237
25 ; X86-NEXT: # Parent Loop BB0_1 Depth=1
26 ; X86-NEXT: # => This Inner Loop Header: Depth=2
27 ; X86-NEXT: testb %bl, %bl
28 ; X86-NEXT: jne .LBB0_2
29 ; X86-NEXT: jmp .LBB0_1
31 ; X64-LABEL: knownbits_zext_in_reg:
33 ; X64-NEXT: movzbl (%rdi), %eax
34 ; X64-NEXT: imull $101, %eax, %ecx
35 ; X64-NEXT: shrl $14, %ecx
36 ; X64-NEXT: imull $177, %eax, %edx
37 ; X64-NEXT: shrl $14, %edx
38 ; X64-NEXT: movzbl %cl, %ecx
39 ; X64-NEXT: xorl %esi, %esi
40 ; X64-NEXT: .p2align 4, 0x90
41 ; X64-NEXT: .LBB0_1: # %CF
42 ; X64-NEXT: # =>This Loop Header: Depth=1
43 ; X64-NEXT: # Child Loop BB0_2 Depth 2
44 ; X64-NEXT: movl %ecx, %eax
46 ; X64-NEXT: .p2align 4, 0x90
47 ; X64-NEXT: .LBB0_2: # %CF237
48 ; X64-NEXT: # Parent Loop BB0_1 Depth=1
49 ; X64-NEXT: # => This Inner Loop Header: Depth=2
50 ; X64-NEXT: testb %sil, %sil
51 ; X64-NEXT: jne .LBB0_2
52 ; X64-NEXT: jmp .LBB0_1
55 %Sl9 = select i1 true, i8 %L5, i8 undef
56 %B21 = udiv i8 %Sl9, -93
57 %B22 = udiv i8 %Sl9, 93
60 CF: ; preds = %CF246, %BB
61 %I40 = insertelement <4 x i8> zeroinitializer, i8 %B21, i32 1
62 %I41 = insertelement <4 x i8> zeroinitializer, i8 %B22, i32 1
63 %B41 = srem <4 x i8> %I40, %I41
66 CF237: ; preds = %CF237, %CF
67 %Cmp73 = icmp ne i1 undef, undef
68 br i1 %Cmp73, label %CF237, label %CF246
70 CF246: ; preds = %CF237
71 %Cmp117 = icmp ult <4 x i8> %B41, undef
72 %E156 = extractelement <4 x i1> %Cmp117, i32 2
76 define i32 @knownbits_mask_add_lshr(i32 %a0, i32 %a1) nounwind {
77 ; CHECK-LABEL: knownbits_mask_add_lshr:
79 ; CHECK-NEXT: xorl %eax, %eax
80 ; CHECK-NEXT: ret{{[l|q]}}
81 %1 = and i32 %a0, 32767
82 %2 = and i32 %a1, 32766
88 define i128 @knownbits_mask_addc_shl(i64 %a0, i64 %a1, i64 %a2) nounwind {
89 ; X86-LABEL: knownbits_mask_addc_shl:
91 ; X86-NEXT: pushl %edi
92 ; X86-NEXT: pushl %esi
93 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
94 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
95 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
96 ; X86-NEXT: movl $-1024, %esi # imm = 0xFC00
97 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
98 ; X86-NEXT: andl %esi, %edi
99 ; X86-NEXT: andl {{[0-9]+}}(%esp), %esi
100 ; X86-NEXT: addl %edi, %esi
101 ; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx
102 ; X86-NEXT: adcl $0, %ecx
103 ; X86-NEXT: shldl $22, %edx, %ecx
104 ; X86-NEXT: shldl $22, %esi, %edx
105 ; X86-NEXT: movl %edx, 8(%eax)
106 ; X86-NEXT: movl %ecx, 12(%eax)
107 ; X86-NEXT: movl $0, 4(%eax)
108 ; X86-NEXT: movl $0, (%eax)
109 ; X86-NEXT: popl %esi
110 ; X86-NEXT: popl %edi
113 ; X64-LABEL: knownbits_mask_addc_shl:
115 ; X64-NEXT: andq $-1024, %rdi # imm = 0xFC00
116 ; X64-NEXT: andq $-1024, %rsi # imm = 0xFC00
117 ; X64-NEXT: addq %rdi, %rsi
118 ; X64-NEXT: adcq $0, %rdx
119 ; X64-NEXT: shldq $54, %rsi, %rdx
120 ; X64-NEXT: xorl %eax, %eax
122 %1 = and i64 %a0, -1024
123 %2 = zext i64 %1 to i128
124 %3 = and i64 %a1, -1024
125 %4 = zext i64 %3 to i128
127 %6 = zext i64 %a2 to i128
134 define {i32, i1} @knownbits_uaddo_saddo(i64 %a0, i64 %a1) nounwind {
135 ; X86-LABEL: knownbits_uaddo_saddo:
137 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
138 ; X86-NEXT: addl {{[0-9]+}}(%esp), %eax
141 ; X86-NEXT: orb %al, %dl
142 ; X86-NEXT: xorl %eax, %eax
145 ; X64-LABEL: knownbits_uaddo_saddo:
147 ; X64-NEXT: shlq $32, %rdi
148 ; X64-NEXT: shlq $32, %rsi
149 ; X64-NEXT: addq %rdi, %rsi
152 ; X64-NEXT: orb %al, %dl
153 ; X64-NEXT: xorl %eax, %eax
157 %u = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %1, i64 %2)
158 %uval = extractvalue {i64, i1} %u, 0
159 %uovf = extractvalue {i64, i1} %u, 1
160 %s = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %1, i64 %2)
161 %sval = extractvalue {i64, i1} %s, 0
162 %sovf = extractvalue {i64, i1} %s, 1
163 %sum = add i64 %uval, %sval
164 %3 = trunc i64 %sum to i32
165 %4 = or i1 %uovf, %sovf
166 %ret0 = insertvalue {i32, i1} undef, i32 %3, 0
167 %ret1 = insertvalue {i32, i1} %ret0, i1 %4, 1
171 define {i32, i1} @knownbits_usubo_ssubo(i64 %a0, i64 %a1) nounwind {
172 ; X86-LABEL: knownbits_usubo_ssubo:
174 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
175 ; X86-NEXT: cmpl {{[0-9]+}}(%esp), %eax
178 ; X86-NEXT: orb %al, %dl
179 ; X86-NEXT: xorl %eax, %eax
182 ; X64-LABEL: knownbits_usubo_ssubo:
184 ; X64-NEXT: shlq $32, %rdi
185 ; X64-NEXT: shlq $32, %rsi
186 ; X64-NEXT: cmpq %rsi, %rdi
189 ; X64-NEXT: orb %al, %dl
190 ; X64-NEXT: xorl %eax, %eax
194 %u = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %1, i64 %2)
195 %uval = extractvalue {i64, i1} %u, 0
196 %uovf = extractvalue {i64, i1} %u, 1
197 %s = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %1, i64 %2)
198 %sval = extractvalue {i64, i1} %s, 0
199 %sovf = extractvalue {i64, i1} %s, 1
200 %sum = add i64 %uval, %sval
201 %3 = trunc i64 %sum to i32
202 %4 = or i1 %uovf, %sovf
203 %ret0 = insertvalue {i32, i1} undef, i32 %3, 0
204 %ret1 = insertvalue {i32, i1} %ret0, i1 %4, 1
208 declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
209 declare {i64, i1} @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
210 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
211 declare {i64, i1} @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone
213 define i32 @knownbits_fshl(i32 %a0) nounwind {
214 ; CHECK-LABEL: knownbits_fshl:
216 ; CHECK-NEXT: movl $3, %eax
217 ; CHECK-NEXT: ret{{[l|q]}}
218 %1 = tail call i32 @llvm.fshl.i32(i32 %a0, i32 -1, i32 5)
223 define i32 @knownbits_fshr(i32 %a0) nounwind {
224 ; CHECK-LABEL: knownbits_fshr:
226 ; CHECK-NEXT: movl $3, %eax
227 ; CHECK-NEXT: ret{{[l|q]}}
228 %1 = tail call i32 @llvm.fshr.i32(i32 %a0, i32 -1, i32 5)
233 declare i32 @llvm.fshl.i32(i32, i32, i32) nounwind readnone
234 declare i32 @llvm.fshr.i32(i32, i32, i32) nounwind readnone