1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+avx | FileCheck %s --check-prefix=CHECK --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx | FileCheck %s --check-prefix=CHECK --check-prefix=X64
4 ; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=X32-AVX2
5 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=X64-AVX2
7 define void @and_masks(<8 x float>* %a, <8 x float>* %b, <8 x float>* %c) nounwind uwtable noinline ssp {
8 ; X32-LABEL: and_masks:
10 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
11 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
12 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
13 ; X32-NEXT: vmovups (%edx), %ymm0
14 ; X32-NEXT: vmovups (%ecx), %ymm1
15 ; X32-NEXT: vcmpltps %ymm0, %ymm1, %ymm1
16 ; X32-NEXT: vmovups (%eax), %ymm2
17 ; X32-NEXT: vcmpltps %ymm0, %ymm2, %ymm0
18 ; X32-NEXT: vandps %ymm1, %ymm0, %ymm0
19 ; X32-NEXT: vandps LCPI0_0, %ymm0, %ymm0
20 ; X32-NEXT: vmovaps %ymm0, (%eax)
21 ; X32-NEXT: vzeroupper
24 ; X64-LABEL: and_masks:
26 ; X64-NEXT: vmovups (%rdi), %ymm0
27 ; X64-NEXT: vmovups (%rsi), %ymm1
28 ; X64-NEXT: vcmpltps %ymm0, %ymm1, %ymm1
29 ; X64-NEXT: vmovups (%rdx), %ymm2
30 ; X64-NEXT: vcmpltps %ymm0, %ymm2, %ymm0
31 ; X64-NEXT: vandps %ymm1, %ymm0, %ymm0
32 ; X64-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0
33 ; X64-NEXT: vmovaps %ymm0, (%rax)
34 ; X64-NEXT: vzeroupper
37 ; X32-AVX2-LABEL: and_masks:
39 ; X32-AVX2-NEXT: movl {{[0-9]+}}(%esp), %eax
40 ; X32-AVX2-NEXT: movl {{[0-9]+}}(%esp), %ecx
41 ; X32-AVX2-NEXT: movl {{[0-9]+}}(%esp), %edx
42 ; X32-AVX2-NEXT: vmovups (%edx), %ymm0
43 ; X32-AVX2-NEXT: vmovups (%ecx), %ymm1
44 ; X32-AVX2-NEXT: vcmpltps %ymm0, %ymm1, %ymm1
45 ; X32-AVX2-NEXT: vmovups (%eax), %ymm2
46 ; X32-AVX2-NEXT: vcmpltps %ymm0, %ymm2, %ymm0
47 ; X32-AVX2-NEXT: vandps %ymm1, %ymm0, %ymm0
48 ; X32-AVX2-NEXT: vpsrld $31, %ymm0, %ymm0
49 ; X32-AVX2-NEXT: vmovdqa %ymm0, (%eax)
50 ; X32-AVX2-NEXT: vzeroupper
53 ; X64-AVX2-LABEL: and_masks:
55 ; X64-AVX2-NEXT: vmovups (%rdi), %ymm0
56 ; X64-AVX2-NEXT: vmovups (%rsi), %ymm1
57 ; X64-AVX2-NEXT: vcmpltps %ymm0, %ymm1, %ymm1
58 ; X64-AVX2-NEXT: vmovups (%rdx), %ymm2
59 ; X64-AVX2-NEXT: vcmpltps %ymm0, %ymm2, %ymm0
60 ; X64-AVX2-NEXT: vandps %ymm1, %ymm0, %ymm0
61 ; X64-AVX2-NEXT: vpsrld $31, %ymm0, %ymm0
62 ; X64-AVX2-NEXT: vmovdqa %ymm0, (%rax)
63 ; X64-AVX2-NEXT: vzeroupper
65 %v0 = load <8 x float>, <8 x float>* %a, align 16
66 %v1 = load <8 x float>, <8 x float>* %b, align 16
67 %m0 = fcmp olt <8 x float> %v1, %v0
68 %v2 = load <8 x float>, <8 x float>* %c, align 16
69 %m1 = fcmp olt <8 x float> %v2, %v0
70 %mand = and <8 x i1> %m1, %m0
71 %r = zext <8 x i1> %mand to <8 x i32>
72 store <8 x i32> %r, <8 x i32>* undef, align 32
76 define void @neg_masks(<8 x float>* %a, <8 x float>* %b, <8 x float>* %c) nounwind uwtable noinline ssp {
77 ; X32-LABEL: neg_masks:
79 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
80 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
81 ; X32-NEXT: vmovups (%ecx), %ymm0
82 ; X32-NEXT: vcmpnltps (%eax), %ymm0, %ymm0
83 ; X32-NEXT: vandps LCPI1_0, %ymm0, %ymm0
84 ; X32-NEXT: vmovaps %ymm0, (%eax)
85 ; X32-NEXT: vzeroupper
88 ; X64-LABEL: neg_masks:
90 ; X64-NEXT: vmovups (%rsi), %ymm0
91 ; X64-NEXT: vcmpnltps (%rdi), %ymm0, %ymm0
92 ; X64-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0
93 ; X64-NEXT: vmovaps %ymm0, (%rax)
94 ; X64-NEXT: vzeroupper
97 ; X32-AVX2-LABEL: neg_masks:
99 ; X32-AVX2-NEXT: movl {{[0-9]+}}(%esp), %eax
100 ; X32-AVX2-NEXT: movl {{[0-9]+}}(%esp), %ecx
101 ; X32-AVX2-NEXT: vmovups (%ecx), %ymm0
102 ; X32-AVX2-NEXT: vcmpnltps (%eax), %ymm0, %ymm0
103 ; X32-AVX2-NEXT: vbroadcastss {{.*#+}} ymm1 = [1,1,1,1,1,1,1,1]
104 ; X32-AVX2-NEXT: vandps %ymm1, %ymm0, %ymm0
105 ; X32-AVX2-NEXT: vmovaps %ymm0, (%eax)
106 ; X32-AVX2-NEXT: vzeroupper
107 ; X32-AVX2-NEXT: retl
109 ; X64-AVX2-LABEL: neg_masks:
110 ; X64-AVX2: ## %bb.0:
111 ; X64-AVX2-NEXT: vmovups (%rsi), %ymm0
112 ; X64-AVX2-NEXT: vcmpnltps (%rdi), %ymm0, %ymm0
113 ; X64-AVX2-NEXT: vbroadcastss {{.*#+}} ymm1 = [1,1,1,1,1,1,1,1]
114 ; X64-AVX2-NEXT: vandps %ymm1, %ymm0, %ymm0
115 ; X64-AVX2-NEXT: vmovaps %ymm0, (%rax)
116 ; X64-AVX2-NEXT: vzeroupper
117 ; X64-AVX2-NEXT: retq
118 %v0 = load <8 x float>, <8 x float>* %a, align 16
119 %v1 = load <8 x float>, <8 x float>* %b, align 16
120 %m0 = fcmp olt <8 x float> %v1, %v0
121 %mand = xor <8 x i1> %m0, <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>
122 %r = zext <8 x i1> %mand to <8 x i32>
123 store <8 x i32> %r, <8 x i32>* undef, align 32
127 define <8 x i32> @and_mask_constant(<8 x i32> %v0, <8 x i32> %v1) {
128 ; X32-LABEL: and_mask_constant:
130 ; X32-NEXT: vextractf128 $1, %ymm0, %xmm1
131 ; X32-NEXT: vpxor %xmm2, %xmm2, %xmm2
132 ; X32-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1
133 ; X32-NEXT: vpcmpeqd %xmm2, %xmm0, %xmm0
134 ; X32-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
135 ; X32-NEXT: vandps LCPI2_0, %ymm0, %ymm0
138 ; X64-LABEL: and_mask_constant:
140 ; X64-NEXT: vextractf128 $1, %ymm0, %xmm1
141 ; X64-NEXT: vpxor %xmm2, %xmm2, %xmm2
142 ; X64-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1
143 ; X64-NEXT: vpcmpeqd %xmm2, %xmm0, %xmm0
144 ; X64-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
145 ; X64-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0
148 ; X32-AVX2-LABEL: and_mask_constant:
149 ; X32-AVX2: ## %bb.0:
150 ; X32-AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1
151 ; X32-AVX2-NEXT: vpcmpeqd %ymm1, %ymm0, %ymm0
152 ; X32-AVX2-NEXT: vpand LCPI2_0, %ymm0, %ymm0
153 ; X32-AVX2-NEXT: retl
155 ; X64-AVX2-LABEL: and_mask_constant:
156 ; X64-AVX2: ## %bb.0:
157 ; X64-AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1
158 ; X64-AVX2-NEXT: vpcmpeqd %ymm1, %ymm0, %ymm0
159 ; X64-AVX2-NEXT: vpand {{.*}}(%rip), %ymm0, %ymm0
160 ; X64-AVX2-NEXT: retq
161 %m = icmp eq <8 x i32> %v0, zeroinitializer
162 %mand = and <8 x i1> %m, <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false>
163 %r = zext <8 x i1> %mand to <8 x i32>