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 -mattr=+avx512vl -mattr=+avx512bw -mattr=+avx512dq | FileCheck %s --check-prefix=ALL --check-prefix=SKX 4 5 attributes #0 = { nounwind } 6 7define <16 x i8> @trunc_16x32_to_16x8(<16 x i32> %i) #0 { 8; ALL-LABEL: trunc_16x32_to_16x8: 9; ALL: ## BB#0: 10; ALL-NEXT: vpmovdb %zmm0, %xmm0 11; ALL-NEXT: retq 12 %x = trunc <16 x i32> %i to <16 x i8> 13 ret <16 x i8> %x 14} 15 16define <8 x i16> @trunc_8x64_to_8x16(<8 x i64> %i) #0 { 17; ALL-LABEL: trunc_8x64_to_8x16: 18; ALL: ## BB#0: 19; ALL-NEXT: vpmovqw %zmm0, %xmm0 20; ALL-NEXT: retq 21 %x = trunc <8 x i64> %i to <8 x i16> 22 ret <8 x i16> %x 23} 24 25define <16 x i16> @trunc_v16i32_to_v16i16(<16 x i32> %x) #0 { 26; ALL-LABEL: trunc_v16i32_to_v16i16: 27; ALL: ## BB#0: 28; ALL-NEXT: vpmovdw %zmm0, %ymm0 29; ALL-NEXT: retq 30 %1 = trunc <16 x i32> %x to <16 x i16> 31 ret <16 x i16> %1 32} 33 34define <8 x i8> @trunc_qb_512(<8 x i64> %i) #0 { 35; ALL-LABEL: trunc_qb_512: 36; ALL: ## BB#0: 37; ALL-NEXT: vpmovqw %zmm0, %xmm0 38; ALL-NEXT: retq 39 %x = trunc <8 x i64> %i to <8 x i8> 40 ret <8 x i8> %x 41} 42 43define void @trunc_qb_512_mem(<8 x i64> %i, <8 x i8>* %res) #0 { 44; ALL-LABEL: trunc_qb_512_mem: 45; ALL: ## BB#0: 46; ALL-NEXT: vpmovqb %zmm0, (%rdi) 47; ALL-NEXT: retq 48 %x = trunc <8 x i64> %i to <8 x i8> 49 store <8 x i8> %x, <8 x i8>* %res 50 ret void 51} 52 53define <4 x i8> @trunc_qb_256(<4 x i64> %i) #0 { 54; KNL-LABEL: trunc_qb_256: 55; KNL: ## BB#0: 56; KNL-NEXT: vpmovqd %zmm0, %ymm0 57; KNL-NEXT: retq 58; 59; SKX-LABEL: trunc_qb_256: 60; SKX: ## BB#0: 61; SKX-NEXT: vpmovqd %ymm0, %xmm0 62; SKX-NEXT: retq 63 %x = trunc <4 x i64> %i to <4 x i8> 64 ret <4 x i8> %x 65} 66 67define void @trunc_qb_256_mem(<4 x i64> %i, <4 x i8>* %res) #0 { 68; KNL-LABEL: trunc_qb_256_mem: 69; KNL: ## BB#0: 70; KNL-NEXT: vpmovqd %zmm0, %ymm0 71; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u] 72; KNL-NEXT: vmovd %xmm0, (%rdi) 73; KNL-NEXT: retq 74; 75; SKX-LABEL: trunc_qb_256_mem: 76; SKX: ## BB#0: 77; SKX-NEXT: vpmovqb %ymm0, (%rdi) 78; SKX-NEXT: retq 79 %x = trunc <4 x i64> %i to <4 x i8> 80 store <4 x i8> %x, <4 x i8>* %res 81 ret void 82} 83 84define <2 x i8> @trunc_qb_128(<2 x i64> %i) #0 { 85; ALL-LABEL: trunc_qb_128: 86; ALL: ## BB#0: 87; ALL-NEXT: retq 88 %x = trunc <2 x i64> %i to <2 x i8> 89 ret <2 x i8> %x 90} 91 92define void @trunc_qb_128_mem(<2 x i64> %i, <2 x i8>* %res) #0 { 93; KNL-LABEL: trunc_qb_128_mem: 94; KNL: ## BB#0: 95; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,8,u,u,u,u,u,u,u,u,u,u,u,u,u,u] 96; KNL-NEXT: vmovd %xmm0, %eax 97; KNL-NEXT: movw %ax, (%rdi) 98; KNL-NEXT: retq 99; 100; SKX-LABEL: trunc_qb_128_mem: 101; SKX: ## BB#0: 102; SKX-NEXT: vpmovqb %xmm0, (%rdi) 103; SKX-NEXT: retq 104 %x = trunc <2 x i64> %i to <2 x i8> 105 store <2 x i8> %x, <2 x i8>* %res 106 ret void 107} 108 109define <8 x i16> @trunc_qw_512(<8 x i64> %i) #0 { 110; ALL-LABEL: trunc_qw_512: 111; ALL: ## BB#0: 112; ALL-NEXT: vpmovqw %zmm0, %xmm0 113; ALL-NEXT: retq 114 %x = trunc <8 x i64> %i to <8 x i16> 115 ret <8 x i16> %x 116} 117 118define void @trunc_qw_512_mem(<8 x i64> %i, <8 x i16>* %res) #0 { 119; ALL-LABEL: trunc_qw_512_mem: 120; ALL: ## BB#0: 121; ALL-NEXT: vpmovqw %zmm0, (%rdi) 122; ALL-NEXT: retq 123 %x = trunc <8 x i64> %i to <8 x i16> 124 store <8 x i16> %x, <8 x i16>* %res 125 ret void 126} 127 128define <4 x i16> @trunc_qw_256(<4 x i64> %i) #0 { 129; KNL-LABEL: trunc_qw_256: 130; KNL: ## BB#0: 131; KNL-NEXT: vpmovqd %zmm0, %ymm0 132; KNL-NEXT: retq 133; 134; SKX-LABEL: trunc_qw_256: 135; SKX: ## BB#0: 136; SKX-NEXT: vpmovqd %ymm0, %xmm0 137; SKX-NEXT: retq 138 %x = trunc <4 x i64> %i to <4 x i16> 139 ret <4 x i16> %x 140} 141 142define void @trunc_qw_256_mem(<4 x i64> %i, <4 x i16>* %res) #0 { 143; KNL-LABEL: trunc_qw_256_mem: 144; KNL: ## BB#0: 145; KNL-NEXT: vpmovqd %zmm0, %ymm0 146; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15] 147; KNL-NEXT: vmovq %xmm0, (%rdi) 148; KNL-NEXT: retq 149; 150; SKX-LABEL: trunc_qw_256_mem: 151; SKX: ## BB#0: 152; SKX-NEXT: vpmovqw %ymm0, (%rdi) 153; SKX-NEXT: retq 154 %x = trunc <4 x i64> %i to <4 x i16> 155 store <4 x i16> %x, <4 x i16>* %res 156 ret void 157} 158 159define <2 x i16> @trunc_qw_128(<2 x i64> %i) #0 { 160; ALL-LABEL: trunc_qw_128: 161; ALL: ## BB#0: 162; ALL-NEXT: retq 163 %x = trunc <2 x i64> %i to <2 x i16> 164 ret <2 x i16> %x 165} 166 167define void @trunc_qw_128_mem(<2 x i64> %i, <2 x i16>* %res) #0 { 168; KNL-LABEL: trunc_qw_128_mem: 169; KNL: ## BB#0: 170; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3] 171; KNL-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7] 172; KNL-NEXT: vmovd %xmm0, (%rdi) 173; KNL-NEXT: retq 174; 175; SKX-LABEL: trunc_qw_128_mem: 176; SKX: ## BB#0: 177; SKX-NEXT: vpmovqw %xmm0, (%rdi) 178; SKX-NEXT: retq 179 %x = trunc <2 x i64> %i to <2 x i16> 180 store <2 x i16> %x, <2 x i16>* %res 181 ret void 182} 183 184define <8 x i32> @trunc_qd_512(<8 x i64> %i) #0 { 185; ALL-LABEL: trunc_qd_512: 186; ALL: ## BB#0: 187; ALL-NEXT: vpmovqd %zmm0, %ymm0 188; ALL-NEXT: retq 189 %x = trunc <8 x i64> %i to <8 x i32> 190 ret <8 x i32> %x 191} 192 193define void @trunc_qd_512_mem(<8 x i64> %i, <8 x i32>* %res) #0 { 194; ALL-LABEL: trunc_qd_512_mem: 195; ALL: ## BB#0: 196; ALL-NEXT: vpmovqd %zmm0, (%rdi) 197; ALL-NEXT: retq 198 %x = trunc <8 x i64> %i to <8 x i32> 199 store <8 x i32> %x, <8 x i32>* %res 200 ret void 201} 202 203define <4 x i32> @trunc_qd_256(<4 x i64> %i) #0 { 204; KNL-LABEL: trunc_qd_256: 205; KNL: ## BB#0: 206; KNL-NEXT: vpmovqd %zmm0, %ymm0 207; KNL-NEXT: retq 208; 209; SKX-LABEL: trunc_qd_256: 210; SKX: ## BB#0: 211; SKX-NEXT: vpmovqd %ymm0, %xmm0 212; SKX-NEXT: retq 213 %x = trunc <4 x i64> %i to <4 x i32> 214 ret <4 x i32> %x 215} 216 217define void @trunc_qd_256_mem(<4 x i64> %i, <4 x i32>* %res) #0 { 218; KNL-LABEL: trunc_qd_256_mem: 219; KNL: ## BB#0: 220; KNL-NEXT: vpmovqd %zmm0, %ymm0 221; KNL-NEXT: vmovaps %xmm0, (%rdi) 222; KNL-NEXT: retq 223; 224; SKX-LABEL: trunc_qd_256_mem: 225; SKX: ## BB#0: 226; SKX-NEXT: vpmovqd %ymm0, (%rdi) 227; SKX-NEXT: retq 228 %x = trunc <4 x i64> %i to <4 x i32> 229 store <4 x i32> %x, <4 x i32>* %res 230 ret void 231} 232 233define <2 x i32> @trunc_qd_128(<2 x i64> %i) #0 { 234; ALL-LABEL: trunc_qd_128: 235; ALL: ## BB#0: 236; ALL-NEXT: retq 237 %x = trunc <2 x i64> %i to <2 x i32> 238 ret <2 x i32> %x 239} 240 241define void @trunc_qd_128_mem(<2 x i64> %i, <2 x i32>* %res) #0 { 242; KNL-LABEL: trunc_qd_128_mem: 243; KNL: ## BB#0: 244; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3] 245; KNL-NEXT: vmovq %xmm0, (%rdi) 246; KNL-NEXT: retq 247; 248; SKX-LABEL: trunc_qd_128_mem: 249; SKX: ## BB#0: 250; SKX-NEXT: vpmovqd %xmm0, (%rdi) 251; SKX-NEXT: retq 252 %x = trunc <2 x i64> %i to <2 x i32> 253 store <2 x i32> %x, <2 x i32>* %res 254 ret void 255} 256 257define <16 x i8> @trunc_db_512(<16 x i32> %i) #0 { 258; ALL-LABEL: trunc_db_512: 259; ALL: ## BB#0: 260; ALL-NEXT: vpmovdb %zmm0, %xmm0 261; ALL-NEXT: retq 262 %x = trunc <16 x i32> %i to <16 x i8> 263 ret <16 x i8> %x 264} 265 266define void @trunc_db_512_mem(<16 x i32> %i, <16 x i8>* %res) #0 { 267; ALL-LABEL: trunc_db_512_mem: 268; ALL: ## BB#0: 269; ALL-NEXT: vpmovdb %zmm0, (%rdi) 270; ALL-NEXT: retq 271 %x = trunc <16 x i32> %i to <16 x i8> 272 store <16 x i8> %x, <16 x i8>* %res 273 ret void 274} 275 276define <8 x i8> @trunc_db_256(<8 x i32> %i) #0 { 277; KNL-LABEL: trunc_db_256: 278; KNL: ## BB#0: 279; KNL-NEXT: vpmovdw %zmm0, %ymm0 280; KNL-NEXT: retq 281; 282; SKX-LABEL: trunc_db_256: 283; SKX: ## BB#0: 284; SKX-NEXT: vpmovdw %ymm0, %xmm0 285; SKX-NEXT: retq 286 %x = trunc <8 x i32> %i to <8 x i8> 287 ret <8 x i8> %x 288} 289 290define void @trunc_db_256_mem(<8 x i32> %i, <8 x i8>* %res) #0 { 291; KNL-LABEL: trunc_db_256_mem: 292; KNL: ## BB#0: 293; KNL-NEXT: vpmovdw %zmm0, %ymm0 294; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u] 295; KNL-NEXT: vmovq %xmm0, (%rdi) 296; KNL-NEXT: retq 297; 298; SKX-LABEL: trunc_db_256_mem: 299; SKX: ## BB#0: 300; SKX-NEXT: vpmovdb %ymm0, (%rdi) 301; SKX-NEXT: retq 302 %x = trunc <8 x i32> %i to <8 x i8> 303 store <8 x i8> %x, <8 x i8>* %res 304 ret void 305} 306 307define <4 x i8> @trunc_db_128(<4 x i32> %i) #0 { 308; ALL-LABEL: trunc_db_128: 309; ALL: ## BB#0: 310; ALL-NEXT: retq 311 %x = trunc <4 x i32> %i to <4 x i8> 312 ret <4 x i8> %x 313} 314 315define void @trunc_db_128_mem(<4 x i32> %i, <4 x i8>* %res) #0 { 316; KNL-LABEL: trunc_db_128_mem: 317; KNL: ## BB#0: 318; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u] 319; KNL-NEXT: vmovd %xmm0, (%rdi) 320; KNL-NEXT: retq 321; 322; SKX-LABEL: trunc_db_128_mem: 323; SKX: ## BB#0: 324; SKX-NEXT: vpmovdb %xmm0, (%rdi) 325; SKX-NEXT: retq 326 %x = trunc <4 x i32> %i to <4 x i8> 327 store <4 x i8> %x, <4 x i8>* %res 328 ret void 329} 330 331define <16 x i16> @trunc_dw_512(<16 x i32> %i) #0 { 332; ALL-LABEL: trunc_dw_512: 333; ALL: ## BB#0: 334; ALL-NEXT: vpmovdw %zmm0, %ymm0 335; ALL-NEXT: retq 336 %x = trunc <16 x i32> %i to <16 x i16> 337 ret <16 x i16> %x 338} 339 340define void @trunc_dw_512_mem(<16 x i32> %i, <16 x i16>* %res) #0 { 341; ALL-LABEL: trunc_dw_512_mem: 342; ALL: ## BB#0: 343; ALL-NEXT: vpmovdw %zmm0, (%rdi) 344; ALL-NEXT: retq 345 %x = trunc <16 x i32> %i to <16 x i16> 346 store <16 x i16> %x, <16 x i16>* %res 347 ret void 348} 349 350define <8 x i16> @trunc_dw_256(<8 x i32> %i) #0 { 351; KNL-LABEL: trunc_dw_256: 352; KNL: ## BB#0: 353; KNL-NEXT: vpmovdw %zmm0, %ymm0 354; KNL-NEXT: retq 355; 356; SKX-LABEL: trunc_dw_256: 357; SKX: ## BB#0: 358; SKX-NEXT: vpmovdw %ymm0, %xmm0 359; SKX-NEXT: retq 360 %x = trunc <8 x i32> %i to <8 x i16> 361 ret <8 x i16> %x 362} 363 364define void @trunc_dw_256_mem(<8 x i32> %i, <8 x i16>* %res) #0 { 365; KNL-LABEL: trunc_dw_256_mem: 366; KNL: ## BB#0: 367; KNL-NEXT: vpmovdw %zmm0, %ymm0 368; KNL-NEXT: vmovaps %xmm0, (%rdi) 369; KNL-NEXT: retq 370; 371; SKX-LABEL: trunc_dw_256_mem: 372; SKX: ## BB#0: 373; SKX-NEXT: vpmovdw %ymm0, (%rdi) 374; SKX-NEXT: retq 375 %x = trunc <8 x i32> %i to <8 x i16> 376 store <8 x i16> %x, <8 x i16>* %res 377 ret void 378} 379 380define void @trunc_dw_128_mem(<4 x i32> %i, <4 x i16>* %res) #0 { 381; KNL-LABEL: trunc_dw_128_mem: 382; KNL: ## BB#0: 383; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15] 384; KNL-NEXT: vmovq %xmm0, (%rdi) 385; KNL-NEXT: retq 386; 387; SKX-LABEL: trunc_dw_128_mem: 388; SKX: ## BB#0: 389; SKX-NEXT: vpmovdw %xmm0, (%rdi) 390; SKX-NEXT: retq 391 %x = trunc <4 x i32> %i to <4 x i16> 392 store <4 x i16> %x, <4 x i16>* %res 393 ret void 394} 395 396define <32 x i8> @trunc_wb_512(<32 x i16> %i) #0 { 397; KNL-LABEL: trunc_wb_512: 398; KNL: ## BB#0: 399; KNL-NEXT: vpmovsxwd %ymm0, %zmm0 400; KNL-NEXT: vpmovdb %zmm0, %xmm0 401; KNL-NEXT: vpmovsxwd %ymm1, %zmm1 402; KNL-NEXT: vpmovdb %zmm1, %xmm1 403; KNL-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0 404; KNL-NEXT: retq 405; 406; SKX-LABEL: trunc_wb_512: 407; SKX: ## BB#0: 408; SKX-NEXT: vpmovwb %zmm0, %ymm0 409; SKX-NEXT: retq 410 %x = trunc <32 x i16> %i to <32 x i8> 411 ret <32 x i8> %x 412} 413 414define void @trunc_wb_512_mem(<32 x i16> %i, <32 x i8>* %res) #0 { 415; KNL-LABEL: trunc_wb_512_mem: 416; KNL: ## BB#0: 417; KNL-NEXT: vpmovsxwd %ymm0, %zmm0 418; KNL-NEXT: vpmovdb %zmm0, %xmm0 419; KNL-NEXT: vpmovsxwd %ymm1, %zmm1 420; KNL-NEXT: vpmovdb %zmm1, %xmm1 421; KNL-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0 422; KNL-NEXT: vmovaps %ymm0, (%rdi) 423; KNL-NEXT: retq 424; 425; SKX-LABEL: trunc_wb_512_mem: 426; SKX: ## BB#0: 427; SKX-NEXT: vpmovwb %zmm0, (%rdi) 428; SKX-NEXT: retq 429 %x = trunc <32 x i16> %i to <32 x i8> 430 store <32 x i8> %x, <32 x i8>* %res 431 ret void 432} 433 434define <16 x i8> @trunc_wb_256(<16 x i16> %i) #0 { 435; KNL-LABEL: trunc_wb_256: 436; KNL: ## BB#0: 437; KNL-NEXT: vpmovsxwd %ymm0, %zmm0 438; KNL-NEXT: vpmovdb %zmm0, %xmm0 439; KNL-NEXT: retq 440; 441; SKX-LABEL: trunc_wb_256: 442; SKX: ## BB#0: 443; SKX-NEXT: vpmovwb %ymm0, %xmm0 444; SKX-NEXT: retq 445 %x = trunc <16 x i16> %i to <16 x i8> 446 ret <16 x i8> %x 447} 448 449define void @trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) #0 { 450; KNL-LABEL: trunc_wb_256_mem: 451; KNL: ## BB#0: 452; KNL-NEXT: vpmovsxwd %ymm0, %zmm0 453; KNL-NEXT: vpmovdb %zmm0, %xmm0 454; KNL-NEXT: vmovaps %xmm0, (%rdi) 455; KNL-NEXT: retq 456; 457; SKX-LABEL: trunc_wb_256_mem: 458; SKX: ## BB#0: 459; SKX-NEXT: vpmovwb %ymm0, (%rdi) 460; SKX-NEXT: retq 461 %x = trunc <16 x i16> %i to <16 x i8> 462 store <16 x i8> %x, <16 x i8>* %res 463 ret void 464} 465 466define <8 x i8> @trunc_wb_128(<8 x i16> %i) #0 { 467; ALL-LABEL: trunc_wb_128: 468; ALL: ## BB#0: 469; ALL-NEXT: retq 470 %x = trunc <8 x i16> %i to <8 x i8> 471 ret <8 x i8> %x 472} 473 474define void @trunc_wb_128_mem(<8 x i16> %i, <8 x i8>* %res) #0 { 475; KNL-LABEL: trunc_wb_128_mem: 476; KNL: ## BB#0: 477; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u] 478; KNL-NEXT: vmovq %xmm0, (%rdi) 479; KNL-NEXT: retq 480; 481; SKX-LABEL: trunc_wb_128_mem: 482; SKX: ## BB#0: 483; SKX-NEXT: vpmovwb %xmm0, (%rdi) 484; SKX-NEXT: retq 485 %x = trunc <8 x i16> %i to <8 x i8> 486 store <8 x i8> %x, <8 x i8>* %res 487 ret void 488} 489