1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=avx2 -show-mc-encoding | FileCheck %s --check-prefix=CHECK --check-prefix=AVX2 --check-prefix=X86 --check-prefix=X86-AVX
3 ; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+avx512f,+avx512bw,+avx512vl,+avx512dq -show-mc-encoding | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512VL --check-prefix=X86 --check-prefix=X86-AVX512VL
4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=avx2 -show-mc-encoding | FileCheck %s --check-prefix=CHECK --check-prefix=AVX2 --check-prefix=X64 --check-prefix=X64-AVX
5 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512vl,+avx512dq -show-mc-encoding | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512VL --check-prefix=X64 --check-prefix=X64-AVX512VL
7 ; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/sse2-builtins.c
9 define <32 x i8> @test_x86_avx2_paddus_b(<32 x i8> %a0, <32 x i8> %a1) {
10 ; X86-AVX-LABEL: test_x86_avx2_paddus_b:
12 ; X86-AVX-NEXT: vpaddusb %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdc,0xc1]
13 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
15 ; X86-AVX512VL-LABEL: test_x86_avx2_paddus_b:
16 ; X86-AVX512VL: ## %bb.0:
17 ; X86-AVX512VL-NEXT: vpaddusb %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xdc,0xc1]
18 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
20 ; X64-AVX-LABEL: test_x86_avx2_paddus_b:
22 ; X64-AVX-NEXT: vpaddusb %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdc,0xc1]
23 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
25 ; X64-AVX512VL-LABEL: test_x86_avx2_paddus_b:
26 ; X64-AVX512VL: ## %bb.0:
27 ; X64-AVX512VL-NEXT: vpaddusb %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xdc,0xc1]
28 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
29 %1 = add <32 x i8> %a0, %a1
30 %2 = icmp ugt <32 x i8> %a0, %1
31 %3 = select <32 x i1> %2, <32 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <32 x i8> %1
35 define <16 x i16> @test_x86_avx2_paddus_w(<16 x i16> %a0, <16 x i16> %a1) {
36 ; X86-AVX-LABEL: test_x86_avx2_paddus_w:
38 ; X86-AVX-NEXT: vpaddusw %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdd,0xc1]
39 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
41 ; X86-AVX512VL-LABEL: test_x86_avx2_paddus_w:
42 ; X86-AVX512VL: ## %bb.0:
43 ; X86-AVX512VL-NEXT: vpaddusw %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xdd,0xc1]
44 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
46 ; X64-AVX-LABEL: test_x86_avx2_paddus_w:
48 ; X64-AVX-NEXT: vpaddusw %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdd,0xc1]
49 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
51 ; X64-AVX512VL-LABEL: test_x86_avx2_paddus_w:
52 ; X64-AVX512VL: ## %bb.0:
53 ; X64-AVX512VL-NEXT: vpaddusw %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xdd,0xc1]
54 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
55 %1 = add <16 x i16> %a0, %a1
56 %2 = icmp ugt <16 x i16> %a0, %1
57 %3 = select <16 x i1> %2, <16 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <16 x i16> %1
61 define <32 x i8> @test_x86_avx2_psubus_b(<32 x i8> %a0, <32 x i8> %a1) {
62 ; X86-AVX-LABEL: test_x86_avx2_psubus_b:
64 ; X86-AVX-NEXT: vpsubusb %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd8,0xc1]
65 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
67 ; X86-AVX512VL-LABEL: test_x86_avx2_psubus_b:
68 ; X86-AVX512VL: ## %bb.0:
69 ; X86-AVX512VL-NEXT: vpsubusb %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xd8,0xc1]
70 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
72 ; X64-AVX-LABEL: test_x86_avx2_psubus_b:
74 ; X64-AVX-NEXT: vpsubusb %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd8,0xc1]
75 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
77 ; X64-AVX512VL-LABEL: test_x86_avx2_psubus_b:
78 ; X64-AVX512VL: ## %bb.0:
79 ; X64-AVX512VL-NEXT: vpsubusb %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xd8,0xc1]
80 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
81 %cmp = icmp ugt <32 x i8> %a0, %a1
82 %sel = select <32 x i1> %cmp, <32 x i8> %a0, <32 x i8> %a1
83 %sub = sub <32 x i8> %sel, %a1
87 define <16 x i16> @test_x86_avx2_psubus_w(<16 x i16> %a0, <16 x i16> %a1) {
88 ; X86-AVX-LABEL: test_x86_avx2_psubus_w:
90 ; X86-AVX-NEXT: vpsubusw %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd9,0xc1]
91 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
93 ; X86-AVX512VL-LABEL: test_x86_avx2_psubus_w:
94 ; X86-AVX512VL: ## %bb.0:
95 ; X86-AVX512VL-NEXT: vpsubusw %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xd9,0xc1]
96 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
98 ; X64-AVX-LABEL: test_x86_avx2_psubus_w:
100 ; X64-AVX-NEXT: vpsubusw %ymm1, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd9,0xc1]
101 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
103 ; X64-AVX512VL-LABEL: test_x86_avx2_psubus_w:
104 ; X64-AVX512VL: ## %bb.0:
105 ; X64-AVX512VL-NEXT: vpsubusw %ymm1, %ymm0, %ymm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfd,0xd9,0xc1]
106 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
107 %cmp = icmp ugt <16 x i16> %a0, %a1
108 %sel = select <16 x i1> %cmp, <16 x i16> %a0, <16 x i16> %a1
109 %sub = sub <16 x i16> %sel, %a1
113 define <32 x i16> @test_x86_avx2_paddus_w_512(<32 x i16> %a, <32 x i16> %b) {
114 ; X86-AVX-LABEL: test_x86_avx2_paddus_w_512:
116 ; X86-AVX-NEXT: vpaddusw %ymm2, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdd,0xc2]
117 ; X86-AVX-NEXT: vpaddusw %ymm3, %ymm1, %ymm1 ## encoding: [0xc5,0xf5,0xdd,0xcb]
118 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
120 ; X86-AVX512VL-LABEL: test_x86_avx2_paddus_w_512:
121 ; X86-AVX512VL: ## %bb.0:
122 ; X86-AVX512VL-NEXT: vpaddusw %zmm1, %zmm0, %zmm0 ## encoding: [0x62,0xf1,0x7d,0x48,0xdd,0xc1]
123 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
125 ; X64-AVX-LABEL: test_x86_avx2_paddus_w_512:
127 ; X64-AVX-NEXT: vpaddusw %ymm2, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xdd,0xc2]
128 ; X64-AVX-NEXT: vpaddusw %ymm3, %ymm1, %ymm1 ## encoding: [0xc5,0xf5,0xdd,0xcb]
129 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
131 ; X64-AVX512VL-LABEL: test_x86_avx2_paddus_w_512:
132 ; X64-AVX512VL: ## %bb.0:
133 ; X64-AVX512VL-NEXT: vpaddusw %zmm1, %zmm0, %zmm0 ## encoding: [0x62,0xf1,0x7d,0x48,0xdd,0xc1]
134 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
135 %1 = add <32 x i16> %a, %b
136 %2 = icmp ugt <32 x i16> %a, %1
137 %3 = select <32 x i1> %2, <32 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <32 x i16> %1
141 define <32 x i16> @test_x86_avx2_psubus_w_512(<32 x i16> %a, <32 x i16> %b) {
142 ; X86-AVX-LABEL: test_x86_avx2_psubus_w_512:
144 ; X86-AVX-NEXT: vpsubusw %ymm2, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd9,0xc2]
145 ; X86-AVX-NEXT: vpsubusw %ymm3, %ymm1, %ymm1 ## encoding: [0xc5,0xf5,0xd9,0xcb]
146 ; X86-AVX-NEXT: retl ## encoding: [0xc3]
148 ; X86-AVX512VL-LABEL: test_x86_avx2_psubus_w_512:
149 ; X86-AVX512VL: ## %bb.0:
150 ; X86-AVX512VL-NEXT: vpsubusw %zmm1, %zmm0, %zmm0 ## encoding: [0x62,0xf1,0x7d,0x48,0xd9,0xc1]
151 ; X86-AVX512VL-NEXT: retl ## encoding: [0xc3]
153 ; X64-AVX-LABEL: test_x86_avx2_psubus_w_512:
155 ; X64-AVX-NEXT: vpsubusw %ymm2, %ymm0, %ymm0 ## encoding: [0xc5,0xfd,0xd9,0xc2]
156 ; X64-AVX-NEXT: vpsubusw %ymm3, %ymm1, %ymm1 ## encoding: [0xc5,0xf5,0xd9,0xcb]
157 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
159 ; X64-AVX512VL-LABEL: test_x86_avx2_psubus_w_512:
160 ; X64-AVX512VL: ## %bb.0:
161 ; X64-AVX512VL-NEXT: vpsubusw %zmm1, %zmm0, %zmm0 ## encoding: [0x62,0xf1,0x7d,0x48,0xd9,0xc1]
162 ; X64-AVX512VL-NEXT: retq ## encoding: [0xc3]
163 %cmp = icmp ugt <32 x i16> %a, %b
164 %sel = select <32 x i1> %cmp, <32 x i16> %a, <32 x i16> %b
165 %sub = sub <32 x i16> %sel, %b