1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f | FileCheck %s --check-prefix=ALL --check-prefix=KNL
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512vl,+avx512dq | FileCheck %s --check-prefix=ALL --check-prefix=SKX
5 define double @test1(double %a, double %b) nounwind {
8 ; ALL-NEXT: vucomisd %xmm1, %xmm0
10 ; ALL-NEXT: jnp LBB0_2
11 ; ALL-NEXT: LBB0_1: ## %l1
12 ; ALL-NEXT: vsubsd %xmm1, %xmm0, %xmm0
14 ; ALL-NEXT: LBB0_2: ## %l2
15 ; ALL-NEXT: vaddsd %xmm1, %xmm0, %xmm0
17 %tobool = fcmp une double %a, %b
18 br i1 %tobool, label %l1, label %l2
21 %c = fsub double %a, %b
24 %c1 = fadd double %a, %b
28 define float @test2(float %a, float %b) nounwind {
31 ; ALL-NEXT: vucomiss %xmm0, %xmm1
32 ; ALL-NEXT: jbe LBB1_2
33 ; ALL-NEXT: ## %bb.1: ## %l1
34 ; ALL-NEXT: vsubss %xmm1, %xmm0, %xmm0
36 ; ALL-NEXT: LBB1_2: ## %l2
37 ; ALL-NEXT: vaddss %xmm1, %xmm0, %xmm0
39 %tobool = fcmp olt float %a, %b
40 br i1 %tobool, label %l1, label %l2
43 %c = fsub float %a, %b
46 %c1 = fadd float %a, %b
50 define i32 @test3(float %a, float %b) {
53 ; ALL-NEXT: vcmpeqss %xmm1, %xmm0, %k0
54 ; ALL-NEXT: kmovw %k0, %eax
57 %cmp10.i = fcmp oeq float %a, %b
58 %conv11.i = zext i1 %cmp10.i to i32
62 define float @test5(float %p) #0 {
64 ; ALL: ## %bb.0: ## %entry
65 ; ALL-NEXT: vxorps %xmm1, %xmm1, %xmm1
66 ; ALL-NEXT: vucomiss %xmm1, %xmm0
67 ; ALL-NEXT: jne LBB3_1
69 ; ALL-NEXT: ## %bb.2: ## %return
71 ; ALL-NEXT: LBB3_1: ## %if.end
72 ; ALL-NEXT: vcmpltss %xmm0, %xmm1, %k1
73 ; ALL-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
74 ; ALL-NEXT: vmovss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 {%k1}
77 %cmp = fcmp oeq float %p, 0.000000e+00
78 br i1 %cmp, label %return, label %if.end
80 if.end: ; preds = %entry
81 %cmp1 = fcmp ogt float %p, 0.000000e+00
82 %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
85 return: ; preds = %if.end, %entry
86 %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
90 define i32 @test6(i32 %a, i32 %b) {
93 ; ALL-NEXT: xorl %eax, %eax
94 ; ALL-NEXT: cmpl %esi, %edi
97 %cmp = icmp eq i32 %a, %b
98 %res = zext i1 %cmp to i32
102 define i32 @test7(double %x, double %y) #2 {
104 ; ALL: ## %bb.0: ## %entry
105 ; ALL-NEXT: xorl %eax, %eax
106 ; ALL-NEXT: vucomisd %xmm1, %xmm0
107 ; ALL-NEXT: setne %al
110 %0 = fcmp one double %x, %y
111 %or = zext i1 %0 to i32
115 define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
118 ; ALL-NEXT: notl %edi
119 ; ALL-NEXT: addl $-2147483648, %esi ## imm = 0x80000000
120 ; ALL-NEXT: testl %edx, %edx
121 ; ALL-NEXT: movl $1, %eax
122 ; ALL-NEXT: cmovel %eax, %edx
123 ; ALL-NEXT: orl %edi, %esi
124 ; ALL-NEXT: cmovnel %edx, %eax
126 %tmp1 = icmp eq i32 %a1, -1
127 %tmp2 = icmp eq i32 %a2, -2147483648
128 %tmp3 = and i1 %tmp1, %tmp2
129 %tmp4 = icmp eq i32 %a3, 0
130 %tmp5 = or i1 %tmp3, %tmp4
131 %res = select i1 %tmp5, i32 1, i32 %a3
135 define i32 @test9(i64 %a) {
138 ; ALL-NEXT: testb $1, %dil
139 ; ALL-NEXT: jne LBB7_2
140 ; ALL-NEXT: ## %bb.1: ## %A
141 ; ALL-NEXT: movl $6, %eax
143 ; ALL-NEXT: LBB7_2: ## %B
144 ; ALL-NEXT: movl $7, %eax
147 %cmp10.i = icmp eq i64 %b, 0
148 br i1 %cmp10.i, label %A, label %B
155 define i32 @test10(i64 %b, i64 %c, i1 %d) {
158 ; ALL-NEXT: cmpq %rsi, %rdi
161 ; ALL-NEXT: testb %al, %dl
162 ; ALL-NEXT: je LBB8_1
163 ; ALL-NEXT: ## %bb.2: ## %if.end.i
164 ; ALL-NEXT: movl $6, %eax
166 ; ALL-NEXT: LBB8_1: ## %if.then.i
167 ; ALL-NEXT: movl $5, %eax
170 %cmp8.i = icmp eq i64 %b, %c
171 %or1 = or i1 %d, %cmp8.i
172 %xor1 = xor i1 %d, %or1
173 br i1 %xor1, label %if.end.i, label %if.then.i
182 ; This test previously caused an infinite loop in legalize vector ops. Due to
183 ; CSE triggering on the call to UpdateNodeOperands and the resulting node not
184 ; being passed to LowerOperation. The add is needed to force the zext into a
185 ; sext on that path. The shuffle keeps the zext alive. The xor somehow
186 ; influences the zext to be visited before the sext exposing the CSE opportunity
187 ; for the sext since zext of setcc is custom legalized to a sext and shift.
188 define <8 x i32> @legalize_loop(<8 x double> %arg) {
189 ; KNL-LABEL: legalize_loop:
191 ; KNL-NEXT: vxorpd %xmm1, %xmm1, %xmm1
192 ; KNL-NEXT: vcmpnltpd %zmm0, %zmm1, %k1
193 ; KNL-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
194 ; KNL-NEXT: vpshufd {{.*#+}} ymm1 = ymm0[3,2,1,0,7,6,5,4]
195 ; KNL-NEXT: vpsrld $31, %ymm1, %ymm1
196 ; KNL-NEXT: vpermq {{.*#+}} ymm1 = ymm1[2,3,0,1]
197 ; KNL-NEXT: vpsubd %ymm0, %ymm1, %ymm0
200 ; SKX-LABEL: legalize_loop:
202 ; SKX-NEXT: vxorpd %xmm1, %xmm1, %xmm1
203 ; SKX-NEXT: vcmpnltpd %zmm0, %zmm1, %k0
204 ; SKX-NEXT: vpmovm2d %k0, %ymm0
205 ; SKX-NEXT: vpshufd {{.*#+}} ymm1 = ymm0[3,2,1,0,7,6,5,4]
206 ; SKX-NEXT: vpsrld $31, %ymm1, %ymm1
207 ; SKX-NEXT: vpermq {{.*#+}} ymm1 = ymm1[2,3,0,1]
208 ; SKX-NEXT: vpsubd %ymm0, %ymm1, %ymm0
210 %tmp = fcmp ogt <8 x double> %arg, zeroinitializer
211 %tmp1 = xor <8 x i1> %tmp, <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>
212 %tmp2 = zext <8 x i1> %tmp1 to <8 x i32>
213 %tmp3 = shufflevector <8 x i32> %tmp2, <8 x i32> undef, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
214 %tmp4 = add <8 x i32> %tmp2, %tmp3