Home | History | Annotate | Download | only in X86
      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,+avx512vl,+avx512bw,+avx512dq,+fast-variable-shuffle | FileCheck %s --check-prefixes=ALL,SKX
      4 
      5  attributes #0 = { nounwind }
      6 
      7 define <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:    vzeroupper
     12 ; ALL-NEXT:    retq
     13   %x = trunc <16 x i32> %i to <16 x i8>
     14   ret <16 x i8> %x
     15 }
     16 
     17 define <8 x i16> @trunc_8x64_to_8x16(<8 x i64> %i) #0 {
     18 ; ALL-LABEL: trunc_8x64_to_8x16:
     19 ; ALL:       ## %bb.0:
     20 ; ALL-NEXT:    vpmovqw %zmm0, %xmm0
     21 ; ALL-NEXT:    vzeroupper
     22 ; ALL-NEXT:    retq
     23   %x = trunc <8 x i64> %i to <8 x i16>
     24   ret <8 x i16> %x
     25 }
     26 
     27 define <16 x i16> @trunc_v16i32_to_v16i16(<16 x i32> %x) #0 {
     28 ; ALL-LABEL: trunc_v16i32_to_v16i16:
     29 ; ALL:       ## %bb.0:
     30 ; ALL-NEXT:    vpmovdw %zmm0, %ymm0
     31 ; ALL-NEXT:    retq
     32   %1 = trunc <16 x i32> %x to <16 x i16>
     33   ret <16 x i16> %1
     34 }
     35 
     36 define <8 x i8> @trunc_qb_512(<8 x i64> %i) #0 {
     37 ; ALL-LABEL: trunc_qb_512:
     38 ; ALL:       ## %bb.0:
     39 ; ALL-NEXT:    vpmovqw %zmm0, %xmm0
     40 ; ALL-NEXT:    vzeroupper
     41 ; ALL-NEXT:    retq
     42   %x = trunc <8 x i64> %i to <8 x i8>
     43   ret <8 x i8> %x
     44 }
     45 
     46 define void @trunc_qb_512_mem(<8 x i64> %i, <8 x i8>* %res) #0 {
     47 ; ALL-LABEL: trunc_qb_512_mem:
     48 ; ALL:       ## %bb.0:
     49 ; ALL-NEXT:    vpmovqb %zmm0, (%rdi)
     50 ; ALL-NEXT:    vzeroupper
     51 ; ALL-NEXT:    retq
     52     %x = trunc <8 x i64> %i to <8 x i8>
     53     store <8 x i8> %x, <8 x i8>* %res
     54     ret void
     55 }
     56 
     57 define <4 x i8> @trunc_qb_256(<4 x i64> %i) #0 {
     58 ; KNL-LABEL: trunc_qb_256:
     59 ; KNL:       ## %bb.0:
     60 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
     61 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
     62 ; KNL-NEXT:    ## kill: def $xmm0 killed $xmm0 killed $ymm0
     63 ; KNL-NEXT:    vzeroupper
     64 ; KNL-NEXT:    retq
     65 ;
     66 ; SKX-LABEL: trunc_qb_256:
     67 ; SKX:       ## %bb.0:
     68 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
     69 ; SKX-NEXT:    vzeroupper
     70 ; SKX-NEXT:    retq
     71   %x = trunc <4 x i64> %i to <4 x i8>
     72   ret <4 x i8> %x
     73 }
     74 
     75 define void @trunc_qb_256_mem(<4 x i64> %i, <4 x i8>* %res) #0 {
     76 ; KNL-LABEL: trunc_qb_256_mem:
     77 ; KNL:       ## %bb.0:
     78 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
     79 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
     80 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u]
     81 ; KNL-NEXT:    vmovd %xmm0, (%rdi)
     82 ; KNL-NEXT:    vzeroupper
     83 ; KNL-NEXT:    retq
     84 ;
     85 ; SKX-LABEL: trunc_qb_256_mem:
     86 ; SKX:       ## %bb.0:
     87 ; SKX-NEXT:    vpmovqb %ymm0, (%rdi)
     88 ; SKX-NEXT:    vzeroupper
     89 ; SKX-NEXT:    retq
     90     %x = trunc <4 x i64> %i to <4 x i8>
     91     store <4 x i8> %x, <4 x i8>* %res
     92     ret void
     93 }
     94 
     95 define <2 x i8> @trunc_qb_128(<2 x i64> %i) #0 {
     96 ; ALL-LABEL: trunc_qb_128:
     97 ; ALL:       ## %bb.0:
     98 ; ALL-NEXT:    retq
     99   %x = trunc <2 x i64> %i to <2 x i8>
    100   ret <2 x i8> %x
    101 }
    102 
    103 define void @trunc_qb_128_mem(<2 x i64> %i, <2 x i8>* %res) #0 {
    104 ; KNL-LABEL: trunc_qb_128_mem:
    105 ; KNL:       ## %bb.0:
    106 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,8,u,u,u,u,u,u,u,u,u,u,u,u,u,u]
    107 ; KNL-NEXT:    vpextrw $0, %xmm0, (%rdi)
    108 ; KNL-NEXT:    retq
    109 ;
    110 ; SKX-LABEL: trunc_qb_128_mem:
    111 ; SKX:       ## %bb.0:
    112 ; SKX-NEXT:    vpmovqb %xmm0, (%rdi)
    113 ; SKX-NEXT:    retq
    114     %x = trunc <2 x i64> %i to <2 x i8>
    115     store <2 x i8> %x, <2 x i8>* %res
    116     ret void
    117 }
    118 
    119 define <8 x i16> @trunc_qw_512(<8 x i64> %i) #0 {
    120 ; ALL-LABEL: trunc_qw_512:
    121 ; ALL:       ## %bb.0:
    122 ; ALL-NEXT:    vpmovqw %zmm0, %xmm0
    123 ; ALL-NEXT:    vzeroupper
    124 ; ALL-NEXT:    retq
    125   %x = trunc <8 x i64> %i to <8 x i16>
    126   ret <8 x i16> %x
    127 }
    128 
    129 define void @trunc_qw_512_mem(<8 x i64> %i, <8 x i16>* %res) #0 {
    130 ; ALL-LABEL: trunc_qw_512_mem:
    131 ; ALL:       ## %bb.0:
    132 ; ALL-NEXT:    vpmovqw %zmm0, (%rdi)
    133 ; ALL-NEXT:    vzeroupper
    134 ; ALL-NEXT:    retq
    135     %x = trunc <8 x i64> %i to <8 x i16>
    136     store <8 x i16> %x, <8 x i16>* %res
    137     ret void
    138 }
    139 
    140 define <4 x i16> @trunc_qw_256(<4 x i64> %i) #0 {
    141 ; KNL-LABEL: trunc_qw_256:
    142 ; KNL:       ## %bb.0:
    143 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    144 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
    145 ; KNL-NEXT:    ## kill: def $xmm0 killed $xmm0 killed $ymm0
    146 ; KNL-NEXT:    vzeroupper
    147 ; KNL-NEXT:    retq
    148 ;
    149 ; SKX-LABEL: trunc_qw_256:
    150 ; SKX:       ## %bb.0:
    151 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
    152 ; SKX-NEXT:    vzeroupper
    153 ; SKX-NEXT:    retq
    154   %x = trunc <4 x i64> %i to <4 x i16>
    155   ret <4 x i16> %x
    156 }
    157 
    158 define void @trunc_qw_256_mem(<4 x i64> %i, <4 x i16>* %res) #0 {
    159 ; KNL-LABEL: trunc_qw_256_mem:
    160 ; KNL:       ## %bb.0:
    161 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    162 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
    163 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
    164 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    165 ; KNL-NEXT:    vzeroupper
    166 ; KNL-NEXT:    retq
    167 ;
    168 ; SKX-LABEL: trunc_qw_256_mem:
    169 ; SKX:       ## %bb.0:
    170 ; SKX-NEXT:    vpmovqw %ymm0, (%rdi)
    171 ; SKX-NEXT:    vzeroupper
    172 ; SKX-NEXT:    retq
    173     %x = trunc <4 x i64> %i to <4 x i16>
    174     store <4 x i16> %x, <4 x i16>* %res
    175     ret void
    176 }
    177 
    178 define <2 x i16> @trunc_qw_128(<2 x i64> %i) #0 {
    179 ; ALL-LABEL: trunc_qw_128:
    180 ; ALL:       ## %bb.0:
    181 ; ALL-NEXT:    retq
    182   %x = trunc <2 x i64> %i to <2 x i16>
    183   ret <2 x i16> %x
    184 }
    185 
    186 define void @trunc_qw_128_mem(<2 x i64> %i, <2 x i16>* %res) #0 {
    187 ; KNL-LABEL: trunc_qw_128_mem:
    188 ; KNL:       ## %bb.0:
    189 ; KNL-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
    190 ; KNL-NEXT:    vpshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7]
    191 ; KNL-NEXT:    vmovd %xmm0, (%rdi)
    192 ; KNL-NEXT:    retq
    193 ;
    194 ; SKX-LABEL: trunc_qw_128_mem:
    195 ; SKX:       ## %bb.0:
    196 ; SKX-NEXT:    vpmovqw %xmm0, (%rdi)
    197 ; SKX-NEXT:    retq
    198     %x = trunc <2 x i64> %i to <2 x i16>
    199     store <2 x i16> %x, <2 x i16>* %res
    200     ret void
    201 }
    202 
    203 define <8 x i32> @trunc_qd_512(<8 x i64> %i) #0 {
    204 ; ALL-LABEL: trunc_qd_512:
    205 ; ALL:       ## %bb.0:
    206 ; ALL-NEXT:    vpmovqd %zmm0, %ymm0
    207 ; ALL-NEXT:    retq
    208   %x = trunc <8 x i64> %i to <8 x i32>
    209   ret <8 x i32> %x
    210 }
    211 
    212 define void @trunc_qd_512_mem(<8 x i64> %i, <8 x i32>* %res) #0 {
    213 ; ALL-LABEL: trunc_qd_512_mem:
    214 ; ALL:       ## %bb.0:
    215 ; ALL-NEXT:    vpmovqd %zmm0, (%rdi)
    216 ; ALL-NEXT:    vzeroupper
    217 ; ALL-NEXT:    retq
    218     %x = trunc <8 x i64> %i to <8 x i32>
    219     store <8 x i32> %x, <8 x i32>* %res
    220     ret void
    221 }
    222 
    223 define <4 x i32> @trunc_qd_256(<4 x i64> %i) #0 {
    224 ; KNL-LABEL: trunc_qd_256:
    225 ; KNL:       ## %bb.0:
    226 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    227 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
    228 ; KNL-NEXT:    ## kill: def $xmm0 killed $xmm0 killed $ymm0
    229 ; KNL-NEXT:    vzeroupper
    230 ; KNL-NEXT:    retq
    231 ;
    232 ; SKX-LABEL: trunc_qd_256:
    233 ; SKX:       ## %bb.0:
    234 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
    235 ; SKX-NEXT:    vzeroupper
    236 ; SKX-NEXT:    retq
    237   %x = trunc <4 x i64> %i to <4 x i32>
    238   ret <4 x i32> %x
    239 }
    240 
    241 define void @trunc_qd_256_mem(<4 x i64> %i, <4 x i32>* %res) #0 {
    242 ; KNL-LABEL: trunc_qd_256_mem:
    243 ; KNL:       ## %bb.0:
    244 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    245 ; KNL-NEXT:    vpmovqd %zmm0, %ymm0
    246 ; KNL-NEXT:    vmovdqa %xmm0, (%rdi)
    247 ; KNL-NEXT:    vzeroupper
    248 ; KNL-NEXT:    retq
    249 ;
    250 ; SKX-LABEL: trunc_qd_256_mem:
    251 ; SKX:       ## %bb.0:
    252 ; SKX-NEXT:    vpmovqd %ymm0, (%rdi)
    253 ; SKX-NEXT:    vzeroupper
    254 ; SKX-NEXT:    retq
    255     %x = trunc <4 x i64> %i to <4 x i32>
    256     store <4 x i32> %x, <4 x i32>* %res
    257     ret void
    258 }
    259 
    260 define <2 x i32> @trunc_qd_128(<2 x i64> %i) #0 {
    261 ; ALL-LABEL: trunc_qd_128:
    262 ; ALL:       ## %bb.0:
    263 ; ALL-NEXT:    retq
    264   %x = trunc <2 x i64> %i to <2 x i32>
    265   ret <2 x i32> %x
    266 }
    267 
    268 define void @trunc_qd_128_mem(<2 x i64> %i, <2 x i32>* %res) #0 {
    269 ; KNL-LABEL: trunc_qd_128_mem:
    270 ; KNL:       ## %bb.0:
    271 ; KNL-NEXT:    vpermilps {{.*#+}} xmm0 = xmm0[0,2,2,3]
    272 ; KNL-NEXT:    vmovlps %xmm0, (%rdi)
    273 ; KNL-NEXT:    retq
    274 ;
    275 ; SKX-LABEL: trunc_qd_128_mem:
    276 ; SKX:       ## %bb.0:
    277 ; SKX-NEXT:    vpmovqd %xmm0, (%rdi)
    278 ; SKX-NEXT:    retq
    279     %x = trunc <2 x i64> %i to <2 x i32>
    280     store <2 x i32> %x, <2 x i32>* %res
    281     ret void
    282 }
    283 
    284 define <16 x i8> @trunc_db_512(<16 x i32> %i) #0 {
    285 ; ALL-LABEL: trunc_db_512:
    286 ; ALL:       ## %bb.0:
    287 ; ALL-NEXT:    vpmovdb %zmm0, %xmm0
    288 ; ALL-NEXT:    vzeroupper
    289 ; ALL-NEXT:    retq
    290   %x = trunc <16 x i32> %i to <16 x i8>
    291   ret <16 x i8> %x
    292 }
    293 
    294 define void @trunc_db_512_mem(<16 x i32> %i, <16 x i8>* %res) #0 {
    295 ; ALL-LABEL: trunc_db_512_mem:
    296 ; ALL:       ## %bb.0:
    297 ; ALL-NEXT:    vpmovdb %zmm0, (%rdi)
    298 ; ALL-NEXT:    vzeroupper
    299 ; ALL-NEXT:    retq
    300     %x = trunc <16 x i32> %i to <16 x i8>
    301     store <16 x i8> %x, <16 x i8>* %res
    302     ret void
    303 }
    304 
    305 define <8 x i8> @trunc_db_256(<8 x i32> %i) #0 {
    306 ; KNL-LABEL: trunc_db_256:
    307 ; KNL:       ## %bb.0:
    308 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    309 ; KNL-NEXT:    vpmovdw %zmm0, %ymm0
    310 ; KNL-NEXT:    ## kill: def $xmm0 killed $xmm0 killed $ymm0
    311 ; KNL-NEXT:    vzeroupper
    312 ; KNL-NEXT:    retq
    313 ;
    314 ; SKX-LABEL: trunc_db_256:
    315 ; SKX:       ## %bb.0:
    316 ; SKX-NEXT:    vpmovdw %ymm0, %xmm0
    317 ; SKX-NEXT:    vzeroupper
    318 ; SKX-NEXT:    retq
    319   %x = trunc <8 x i32> %i to <8 x i8>
    320   ret <8 x i8> %x
    321 }
    322 
    323 define void @trunc_db_256_mem(<8 x i32> %i, <8 x i8>* %res) #0 {
    324 ; KNL-LABEL: trunc_db_256_mem:
    325 ; KNL:       ## %bb.0:
    326 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    327 ; KNL-NEXT:    vpmovdw %zmm0, %ymm0
    328 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
    329 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    330 ; KNL-NEXT:    vzeroupper
    331 ; KNL-NEXT:    retq
    332 ;
    333 ; SKX-LABEL: trunc_db_256_mem:
    334 ; SKX:       ## %bb.0:
    335 ; SKX-NEXT:    vpmovdb %ymm0, (%rdi)
    336 ; SKX-NEXT:    vzeroupper
    337 ; SKX-NEXT:    retq
    338     %x = trunc <8 x i32> %i to <8 x i8>
    339     store <8 x i8> %x, <8 x i8>* %res
    340     ret void
    341 }
    342 
    343 define <4 x i8> @trunc_db_128(<4 x i32> %i) #0 {
    344 ; ALL-LABEL: trunc_db_128:
    345 ; ALL:       ## %bb.0:
    346 ; ALL-NEXT:    retq
    347   %x = trunc <4 x i32> %i to <4 x i8>
    348   ret <4 x i8> %x
    349 }
    350 
    351 define void @trunc_db_128_mem(<4 x i32> %i, <4 x i8>* %res) #0 {
    352 ; KNL-LABEL: trunc_db_128_mem:
    353 ; KNL:       ## %bb.0:
    354 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u]
    355 ; KNL-NEXT:    vmovd %xmm0, (%rdi)
    356 ; KNL-NEXT:    retq
    357 ;
    358 ; SKX-LABEL: trunc_db_128_mem:
    359 ; SKX:       ## %bb.0:
    360 ; SKX-NEXT:    vpmovdb %xmm0, (%rdi)
    361 ; SKX-NEXT:    retq
    362     %x = trunc <4 x i32> %i to <4 x i8>
    363     store <4 x i8> %x, <4 x i8>* %res
    364     ret void
    365 }
    366 
    367 define <16 x i16> @trunc_dw_512(<16 x i32> %i) #0 {
    368 ; ALL-LABEL: trunc_dw_512:
    369 ; ALL:       ## %bb.0:
    370 ; ALL-NEXT:    vpmovdw %zmm0, %ymm0
    371 ; ALL-NEXT:    retq
    372   %x = trunc <16 x i32> %i to <16 x i16>
    373   ret <16 x i16> %x
    374 }
    375 
    376 define void @trunc_dw_512_mem(<16 x i32> %i, <16 x i16>* %res) #0 {
    377 ; ALL-LABEL: trunc_dw_512_mem:
    378 ; ALL:       ## %bb.0:
    379 ; ALL-NEXT:    vpmovdw %zmm0, (%rdi)
    380 ; ALL-NEXT:    vzeroupper
    381 ; ALL-NEXT:    retq
    382     %x = trunc <16 x i32> %i to <16 x i16>
    383     store <16 x i16> %x, <16 x i16>* %res
    384     ret void
    385 }
    386 
    387 define <8 x i16> @trunc_dw_256(<8 x i32> %i) #0 {
    388 ; KNL-LABEL: trunc_dw_256:
    389 ; KNL:       ## %bb.0:
    390 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    391 ; KNL-NEXT:    vpmovdw %zmm0, %ymm0
    392 ; KNL-NEXT:    ## kill: def $xmm0 killed $xmm0 killed $ymm0
    393 ; KNL-NEXT:    vzeroupper
    394 ; KNL-NEXT:    retq
    395 ;
    396 ; SKX-LABEL: trunc_dw_256:
    397 ; SKX:       ## %bb.0:
    398 ; SKX-NEXT:    vpmovdw %ymm0, %xmm0
    399 ; SKX-NEXT:    vzeroupper
    400 ; SKX-NEXT:    retq
    401   %x = trunc <8 x i32> %i to <8 x i16>
    402   ret <8 x i16> %x
    403 }
    404 
    405 define void @trunc_dw_256_mem(<8 x i32> %i, <8 x i16>* %res) #0 {
    406 ; KNL-LABEL: trunc_dw_256_mem:
    407 ; KNL:       ## %bb.0:
    408 ; KNL-NEXT:    ## kill: def $ymm0 killed $ymm0 def $zmm0
    409 ; KNL-NEXT:    vpmovdw %zmm0, %ymm0
    410 ; KNL-NEXT:    vmovdqa %xmm0, (%rdi)
    411 ; KNL-NEXT:    vzeroupper
    412 ; KNL-NEXT:    retq
    413 ;
    414 ; SKX-LABEL: trunc_dw_256_mem:
    415 ; SKX:       ## %bb.0:
    416 ; SKX-NEXT:    vpmovdw %ymm0, (%rdi)
    417 ; SKX-NEXT:    vzeroupper
    418 ; SKX-NEXT:    retq
    419     %x = trunc <8 x i32> %i to <8 x i16>
    420     store <8 x i16> %x, <8 x i16>* %res
    421     ret void
    422 }
    423 
    424 define void @trunc_dw_128_mem(<4 x i32> %i, <4 x i16>* %res) #0 {
    425 ; KNL-LABEL: trunc_dw_128_mem:
    426 ; KNL:       ## %bb.0:
    427 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
    428 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    429 ; KNL-NEXT:    retq
    430 ;
    431 ; SKX-LABEL: trunc_dw_128_mem:
    432 ; SKX:       ## %bb.0:
    433 ; SKX-NEXT:    vpmovdw %xmm0, (%rdi)
    434 ; SKX-NEXT:    retq
    435     %x = trunc <4 x i32> %i to <4 x i16>
    436     store <4 x i16> %x, <4 x i16>* %res
    437     ret void
    438 }
    439 
    440 define <32 x i8> @trunc_wb_512(<32 x i16> %i) #0 {
    441 ; KNL-LABEL: trunc_wb_512:
    442 ; KNL:       ## %bb.0:
    443 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    444 ; KNL-NEXT:    vpmovdb %zmm0, %xmm0
    445 ; KNL-NEXT:    vpmovsxwd %ymm1, %zmm1
    446 ; KNL-NEXT:    vpmovdb %zmm1, %xmm1
    447 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    448 ; KNL-NEXT:    retq
    449 ;
    450 ; SKX-LABEL: trunc_wb_512:
    451 ; SKX:       ## %bb.0:
    452 ; SKX-NEXT:    vpmovwb %zmm0, %ymm0
    453 ; SKX-NEXT:    retq
    454   %x = trunc <32 x i16> %i to <32 x i8>
    455   ret <32 x i8> %x
    456 }
    457 
    458 define void @trunc_wb_512_mem(<32 x i16> %i, <32 x i8>* %res) #0 {
    459 ; KNL-LABEL: trunc_wb_512_mem:
    460 ; KNL:       ## %bb.0:
    461 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    462 ; KNL-NEXT:    vpmovdb %zmm0, %xmm0
    463 ; KNL-NEXT:    vpmovsxwd %ymm1, %zmm1
    464 ; KNL-NEXT:    vpmovdb %zmm1, %xmm1
    465 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    466 ; KNL-NEXT:    vmovdqa %ymm0, (%rdi)
    467 ; KNL-NEXT:    vzeroupper
    468 ; KNL-NEXT:    retq
    469 ;
    470 ; SKX-LABEL: trunc_wb_512_mem:
    471 ; SKX:       ## %bb.0:
    472 ; SKX-NEXT:    vpmovwb %zmm0, (%rdi)
    473 ; SKX-NEXT:    vzeroupper
    474 ; SKX-NEXT:    retq
    475     %x = trunc <32 x i16> %i to <32 x i8>
    476     store <32 x i8> %x, <32 x i8>* %res
    477     ret void
    478 }
    479 
    480 define <16 x i8> @trunc_wb_256(<16 x i16> %i) #0 {
    481 ; KNL-LABEL: trunc_wb_256:
    482 ; KNL:       ## %bb.0:
    483 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    484 ; KNL-NEXT:    vpmovdb %zmm0, %xmm0
    485 ; KNL-NEXT:    vzeroupper
    486 ; KNL-NEXT:    retq
    487 ;
    488 ; SKX-LABEL: trunc_wb_256:
    489 ; SKX:       ## %bb.0:
    490 ; SKX-NEXT:    vpmovwb %ymm0, %xmm0
    491 ; SKX-NEXT:    vzeroupper
    492 ; SKX-NEXT:    retq
    493   %x = trunc <16 x i16> %i to <16 x i8>
    494   ret <16 x i8> %x
    495 }
    496 
    497 define void @trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) #0 {
    498 ; KNL-LABEL: trunc_wb_256_mem:
    499 ; KNL:       ## %bb.0:
    500 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    501 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
    502 ; KNL-NEXT:    vzeroupper
    503 ; KNL-NEXT:    retq
    504 ;
    505 ; SKX-LABEL: trunc_wb_256_mem:
    506 ; SKX:       ## %bb.0:
    507 ; SKX-NEXT:    vpmovwb %ymm0, (%rdi)
    508 ; SKX-NEXT:    vzeroupper
    509 ; SKX-NEXT:    retq
    510     %x = trunc <16 x i16> %i to <16 x i8>
    511     store <16 x i8> %x, <16 x i8>* %res
    512     ret void
    513 }
    514 
    515 define <8 x i8> @trunc_wb_128(<8 x i16> %i) #0 {
    516 ; ALL-LABEL: trunc_wb_128:
    517 ; ALL:       ## %bb.0:
    518 ; ALL-NEXT:    retq
    519   %x = trunc <8 x i16> %i to <8 x i8>
    520   ret <8 x i8> %x
    521 }
    522 
    523 define void @trunc_wb_128_mem(<8 x i16> %i, <8 x i8>* %res) #0 {
    524 ; KNL-LABEL: trunc_wb_128_mem:
    525 ; KNL:       ## %bb.0:
    526 ; KNL-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
    527 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    528 ; KNL-NEXT:    retq
    529 ;
    530 ; SKX-LABEL: trunc_wb_128_mem:
    531 ; SKX:       ## %bb.0:
    532 ; SKX-NEXT:    vpmovwb %xmm0, (%rdi)
    533 ; SKX-NEXT:    retq
    534     %x = trunc <8 x i16> %i to <8 x i8>
    535     store <8 x i8> %x, <8 x i8>* %res
    536     ret void
    537 }
    538 
    539 
    540 define void @usat_trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) {
    541 ; KNL-LABEL: usat_trunc_wb_256_mem:
    542 ; KNL:       ## %bb.0:
    543 ; KNL-NEXT:    vpminuw {{.*}}(%rip), %ymm0, %ymm0
    544 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    545 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
    546 ; KNL-NEXT:    vzeroupper
    547 ; KNL-NEXT:    retq
    548 ;
    549 ; SKX-LABEL: usat_trunc_wb_256_mem:
    550 ; SKX:       ## %bb.0:
    551 ; SKX-NEXT:    vpmovuswb %ymm0, (%rdi)
    552 ; SKX-NEXT:    vzeroupper
    553 ; SKX-NEXT:    retq
    554   %x3 = icmp ult <16 x i16> %i, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    555   %x5 = select <16 x i1> %x3, <16 x i16> %i, <16 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    556   %x6 = trunc <16 x i16> %x5 to <16 x i8>
    557   store <16 x i8> %x6, <16 x i8>* %res, align 1
    558   ret void
    559 }
    560 
    561 define <16 x i8> @usat_trunc_wb_256(<16 x i16> %i) {
    562 ; KNL-LABEL: usat_trunc_wb_256:
    563 ; KNL:       ## %bb.0:
    564 ; KNL-NEXT:    vpminuw {{.*}}(%rip), %ymm0, %ymm0
    565 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    566 ; KNL-NEXT:    vpmovdb %zmm0, %xmm0
    567 ; KNL-NEXT:    vzeroupper
    568 ; KNL-NEXT:    retq
    569 ;
    570 ; SKX-LABEL: usat_trunc_wb_256:
    571 ; SKX:       ## %bb.0:
    572 ; SKX-NEXT:    vpmovuswb %ymm0, %xmm0
    573 ; SKX-NEXT:    vzeroupper
    574 ; SKX-NEXT:    retq
    575   %x3 = icmp ult <16 x i16> %i, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    576   %x5 = select <16 x i1> %x3, <16 x i16> %i, <16 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    577   %x6 = trunc <16 x i16> %x5 to <16 x i8>
    578   ret <16 x i8> %x6
    579 }
    580 
    581 define void @usat_trunc_wb_128_mem(<8 x i16> %i, <8 x i8>* %res) {
    582 ; KNL-LABEL: usat_trunc_wb_128_mem:
    583 ; KNL:       ## %bb.0:
    584 ; KNL-NEXT:    vpminuw {{.*}}(%rip), %xmm0, %xmm0
    585 ; KNL-NEXT:    vpackuswb %xmm0, %xmm0, %xmm0
    586 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    587 ; KNL-NEXT:    retq
    588 ;
    589 ; SKX-LABEL: usat_trunc_wb_128_mem:
    590 ; SKX:       ## %bb.0:
    591 ; SKX-NEXT:    vpmovuswb %xmm0, (%rdi)
    592 ; SKX-NEXT:    retq
    593   %x3 = icmp ult <8 x i16> %i, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    594   %x5 = select <8 x i1> %x3, <8 x i16> %i, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    595   %x6 = trunc <8 x i16> %x5 to <8 x i8>
    596   store <8 x i8> %x6, <8 x i8>* %res, align 1
    597   ret void
    598 }
    599 
    600 define void @usat_trunc_db_512_mem(<16 x i32> %i, <16 x i8>* %res) {
    601 ; ALL-LABEL: usat_trunc_db_512_mem:
    602 ; ALL:       ## %bb.0:
    603 ; ALL-NEXT:    vpmovusdb %zmm0, (%rdi)
    604 ; ALL-NEXT:    vzeroupper
    605 ; ALL-NEXT:    retq
    606   %x3 = icmp ult <16 x i32> %i, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    607   %x5 = select <16 x i1> %x3, <16 x i32> %i, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    608   %x6 = trunc <16 x i32> %x5 to <16 x i8>
    609   store <16 x i8> %x6, <16 x i8>* %res, align 1
    610   ret void
    611 }
    612 
    613 define void @usat_trunc_qb_512_mem(<8 x i64> %i, <8 x i8>* %res) {
    614 ; ALL-LABEL: usat_trunc_qb_512_mem:
    615 ; ALL:       ## %bb.0:
    616 ; ALL-NEXT:    vpmovusqb %zmm0, (%rdi)
    617 ; ALL-NEXT:    vzeroupper
    618 ; ALL-NEXT:    retq
    619   %x3 = icmp ult <8 x i64> %i, <i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255>
    620   %x5 = select <8 x i1> %x3, <8 x i64> %i, <8 x i64> <i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255>
    621   %x6 = trunc <8 x i64> %x5 to <8 x i8>
    622   store <8 x i8> %x6, <8 x i8>* %res, align 1
    623   ret void
    624 }
    625 
    626 define void @usat_trunc_qd_512_mem(<8 x i64> %i, <8 x i32>* %res) {
    627 ; ALL-LABEL: usat_trunc_qd_512_mem:
    628 ; ALL:       ## %bb.0:
    629 ; ALL-NEXT:    vpmovusqd %zmm0, (%rdi)
    630 ; ALL-NEXT:    vzeroupper
    631 ; ALL-NEXT:    retq
    632   %x3 = icmp ult <8 x i64> %i, <i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295>
    633   %x5 = select <8 x i1> %x3, <8 x i64> %i, <8 x i64> <i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295>
    634   %x6 = trunc <8 x i64> %x5 to <8 x i32>
    635   store <8 x i32> %x6, <8 x i32>* %res, align 1
    636   ret void
    637 }
    638 
    639 define void @usat_trunc_qw_512_mem(<8 x i64> %i, <8 x i16>* %res) {
    640 ; ALL-LABEL: usat_trunc_qw_512_mem:
    641 ; ALL:       ## %bb.0:
    642 ; ALL-NEXT:    vpmovusqw %zmm0, (%rdi)
    643 ; ALL-NEXT:    vzeroupper
    644 ; ALL-NEXT:    retq
    645   %x3 = icmp ult <8 x i64> %i, <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    646   %x5 = select <8 x i1> %x3, <8 x i64> %i, <8 x i64> <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    647   %x6 = trunc <8 x i64> %x5 to <8 x i16>
    648   store <8 x i16> %x6, <8 x i16>* %res, align 1
    649   ret void
    650 }
    651 
    652 define <32 x i8> @usat_trunc_db_1024(<32 x i32> %i) {
    653 ; KNL-LABEL: usat_trunc_db_1024:
    654 ; KNL:       ## %bb.0:
    655 ; KNL-NEXT:    vpmovusdb %zmm0, %xmm0
    656 ; KNL-NEXT:    vpmovusdb %zmm1, %xmm1
    657 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    658 ; KNL-NEXT:    retq
    659 ;
    660 ; SKX-LABEL: usat_trunc_db_1024:
    661 ; SKX:       ## %bb.0:
    662 ; SKX-NEXT:    vpbroadcastd {{.*#+}} zmm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
    663 ; SKX-NEXT:    vpminud %zmm2, %zmm1, %zmm1
    664 ; SKX-NEXT:    vpminud %zmm2, %zmm0, %zmm0
    665 ; SKX-NEXT:    vpmovdw %zmm0, %ymm0
    666 ; SKX-NEXT:    vpmovdw %zmm1, %ymm1
    667 ; SKX-NEXT:    vinserti64x4 $1, %ymm1, %zmm0, %zmm0
    668 ; SKX-NEXT:    vpmovwb %zmm0, %ymm0
    669 ; SKX-NEXT:    retq
    670   %x3 = icmp ult <32 x i32> %i, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    671   %x5 = select <32 x i1> %x3, <32 x i32> %i, <32 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    672   %x6 = trunc <32 x i32> %x5 to <32 x i8>
    673   ret <32 x i8> %x6
    674 }
    675 
    676 define void @usat_trunc_db_1024_mem(<32 x i32> %i, <32 x i8>* %p) {
    677 ; KNL-LABEL: usat_trunc_db_1024_mem:
    678 ; KNL:       ## %bb.0:
    679 ; KNL-NEXT:    vpmovusdb %zmm0, %xmm0
    680 ; KNL-NEXT:    vpmovusdb %zmm1, %xmm1
    681 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    682 ; KNL-NEXT:    vmovdqu %ymm0, (%rdi)
    683 ; KNL-NEXT:    vzeroupper
    684 ; KNL-NEXT:    retq
    685 ;
    686 ; SKX-LABEL: usat_trunc_db_1024_mem:
    687 ; SKX:       ## %bb.0:
    688 ; SKX-NEXT:    vpbroadcastd {{.*#+}} zmm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
    689 ; SKX-NEXT:    vpminud %zmm2, %zmm1, %zmm1
    690 ; SKX-NEXT:    vpminud %zmm2, %zmm0, %zmm0
    691 ; SKX-NEXT:    vpmovdw %zmm0, %ymm0
    692 ; SKX-NEXT:    vpmovdw %zmm1, %ymm1
    693 ; SKX-NEXT:    vinserti64x4 $1, %ymm1, %zmm0, %zmm0
    694 ; SKX-NEXT:    vpmovwb %zmm0, (%rdi)
    695 ; SKX-NEXT:    vzeroupper
    696 ; SKX-NEXT:    retq
    697   %x3 = icmp ult <32 x i32> %i, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    698   %x5 = select <32 x i1> %x3, <32 x i32> %i, <32 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    699   %x6 = trunc <32 x i32> %x5 to <32 x i8>
    700   store <32 x i8>%x6, <32 x i8>* %p, align 1
    701   ret void
    702 }
    703 
    704 define <16 x i16> @usat_trunc_dw_512(<16 x i32> %i) {
    705 ; ALL-LABEL: usat_trunc_dw_512:
    706 ; ALL:       ## %bb.0:
    707 ; ALL-NEXT:    vpmovusdw %zmm0, %ymm0
    708 ; ALL-NEXT:    retq
    709   %x3 = icmp ult <16 x i32> %i, <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
    710   %x5 = select <16 x i1> %x3, <16 x i32> %i, <16 x i32> <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
    711   %x6 = trunc <16 x i32> %x5 to <16 x i16>
    712   ret <16 x i16> %x6
    713 }
    714 
    715 define <8 x i8> @usat_trunc_wb_128(<8 x i16> %i) {
    716 ; ALL-LABEL: usat_trunc_wb_128:
    717 ; ALL:       ## %bb.0:
    718 ; ALL-NEXT:    vpminuw {{.*}}(%rip), %xmm0, %xmm0
    719 ; ALL-NEXT:    retq
    720   %x3 = icmp ult <8 x i16> %i, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    721   %x5 = select <8 x i1> %x3, <8 x i16> %i, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    722   %x6 = trunc <8 x i16> %x5 to <8 x i8>
    723   ret <8 x i8>%x6
    724 }
    725 
    726 define <16 x i16> @usat_trunc_qw_1024(<16 x i64> %i) {
    727 ; ALL-LABEL: usat_trunc_qw_1024:
    728 ; ALL:       ## %bb.0:
    729 ; ALL-NEXT:    vpbroadcastq {{.*#+}} zmm2 = [65535,65535,65535,65535,65535,65535,65535,65535]
    730 ; ALL-NEXT:    vpminuq %zmm2, %zmm1, %zmm1
    731 ; ALL-NEXT:    vpminuq %zmm2, %zmm0, %zmm0
    732 ; ALL-NEXT:    vpmovqd %zmm0, %ymm0
    733 ; ALL-NEXT:    vpmovqd %zmm1, %ymm1
    734 ; ALL-NEXT:    vinserti64x4 $1, %ymm1, %zmm0, %zmm0
    735 ; ALL-NEXT:    vpmovdw %zmm0, %ymm0
    736 ; ALL-NEXT:    retq
    737   %x3 = icmp ult <16 x i64> %i, <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    738   %x5 = select <16 x i1> %x3, <16 x i64> %i, <16 x i64> <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    739   %x6 = trunc <16 x i64> %x5 to <16 x i16>
    740   ret <16 x i16> %x6
    741 }
    742 
    743 define <16 x i8> @usat_trunc_db_256(<8 x i32> %x) {
    744 ; KNL-LABEL: usat_trunc_db_256:
    745 ; KNL:       ## %bb.0:
    746 ; KNL-NEXT:    vpbroadcastd {{.*#+}} ymm1 = [255,255,255,255,255,255,255,255]
    747 ; KNL-NEXT:    vpminud %ymm1, %ymm0, %ymm0
    748 ; KNL-NEXT:    vpmovdw %zmm0, %ymm0
    749 ; KNL-NEXT:    vpackuswb %xmm0, %xmm0, %xmm0
    750 ; KNL-NEXT:    vzeroupper
    751 ; KNL-NEXT:    retq
    752 ;
    753 ; SKX-LABEL: usat_trunc_db_256:
    754 ; SKX:       ## %bb.0:
    755 ; SKX-NEXT:    vpminud {{.*}}(%rip){1to8}, %ymm0, %ymm0
    756 ; SKX-NEXT:    vpmovdw %ymm0, %xmm0
    757 ; SKX-NEXT:    vpackuswb %xmm0, %xmm0, %xmm0
    758 ; SKX-NEXT:    vzeroupper
    759 ; SKX-NEXT:    retq
    760   %tmp1 = icmp ult <8 x i32> %x, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    761   %tmp2 = select <8 x i1> %tmp1, <8 x i32> %x, <8 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    762   %tmp3 = trunc <8 x i32> %tmp2 to <8 x i8>
    763   %tmp4 = shufflevector <8 x i8> %tmp3, <8 x i8> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
    764   ret <16 x i8> %tmp4
    765 }
    766 
    767 
    768 
    769 ; Tests for the following unsigned saturation pattern:
    770 
    771 ; %a = icmp sgt %x, C1
    772 ; %b = select %a, %x, C2
    773 ; %c = icmp slt %b, C2
    774 ; %d = select %c, %b, C2
    775 ; %res = trunc %d
    776 
    777 
    778 define void @smax_usat_trunc_wb_256_mem1(<16 x i16> %i, <16 x i8>* %res) {
    779 ; KNL-LABEL: smax_usat_trunc_wb_256_mem1:
    780 ; KNL:       ## %bb.0:
    781 ; KNL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    782 ; KNL-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    783 ; KNL-NEXT:    vpminsw {{.*}}(%rip), %ymm0, %ymm0
    784 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    785 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
    786 ; KNL-NEXT:    vzeroupper
    787 ; KNL-NEXT:    retq
    788 ;
    789 ; SKX-LABEL: smax_usat_trunc_wb_256_mem1:
    790 ; SKX:       ## %bb.0:
    791 ; SKX-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    792 ; SKX-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    793 ; SKX-NEXT:    vpmovuswb %ymm0, (%rdi)
    794 ; SKX-NEXT:    vzeroupper
    795 ; SKX-NEXT:    retq
    796   %x1 = icmp sgt <16 x i16> %i, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    797   %x2 = select <16 x i1> %x1, <16 x i16> %i, <16 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    798   %x3 = icmp slt <16 x i16> %x2, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    799   %x5 = select <16 x i1> %x3, <16 x i16> %x2, <16 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    800   %x6 = trunc <16 x i16> %x5 to <16 x i8>
    801   store <16 x i8> %x6, <16 x i8>* %res, align 1
    802   ret void
    803 }
    804 
    805 ; Test for smax(smin(x, C2), C1).
    806 define void @smax_usat_trunc_wb_256_mem2(<16 x i16> %i, <16 x i8>* %res) {
    807 ; KNL-LABEL: smax_usat_trunc_wb_256_mem2:
    808 ; KNL:       ## %bb.0:
    809 ; KNL-NEXT:    vpminsw {{.*}}(%rip), %ymm0, %ymm0
    810 ; KNL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    811 ; KNL-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    812 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    813 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
    814 ; KNL-NEXT:    vzeroupper
    815 ; KNL-NEXT:    retq
    816 ;
    817 ; SKX-LABEL: smax_usat_trunc_wb_256_mem2:
    818 ; SKX:       ## %bb.0:
    819 ; SKX-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    820 ; SKX-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    821 ; SKX-NEXT:    vpmovuswb %ymm0, (%rdi)
    822 ; SKX-NEXT:    vzeroupper
    823 ; SKX-NEXT:    retq
    824   %x1 = icmp slt <16 x i16> %i, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    825   %x2 = select <16 x i1> %x1, <16 x i16> %i, <16 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    826   %x3 = icmp sgt <16 x i16> %x2, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    827   %x5 = select <16 x i1> %x3, <16 x i16> %x2, <16 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    828   %x6 = trunc <16 x i16> %x5 to <16 x i8>
    829   store <16 x i8> %x6, <16 x i8>* %res, align 1
    830   ret void
    831 }
    832 
    833 define <16 x i8> @smax_usat_trunc_wb_256(<16 x i16> %i) {
    834 ; KNL-LABEL: smax_usat_trunc_wb_256:
    835 ; KNL:       ## %bb.0:
    836 ; KNL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    837 ; KNL-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    838 ; KNL-NEXT:    vpminsw {{.*}}(%rip), %ymm0, %ymm0
    839 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
    840 ; KNL-NEXT:    vpmovdb %zmm0, %xmm0
    841 ; KNL-NEXT:    vzeroupper
    842 ; KNL-NEXT:    retq
    843 ;
    844 ; SKX-LABEL: smax_usat_trunc_wb_256:
    845 ; SKX:       ## %bb.0:
    846 ; SKX-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    847 ; SKX-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
    848 ; SKX-NEXT:    vpmovuswb %ymm0, %xmm0
    849 ; SKX-NEXT:    vzeroupper
    850 ; SKX-NEXT:    retq
    851   %x1 = icmp sgt <16 x i16> %i, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    852   %x2 = select <16 x i1> %x1, <16 x i16> %i, <16 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    853   %x3 = icmp slt <16 x i16> %x2, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    854   %x5 = select <16 x i1> %x3, <16 x i16> %x2, <16 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    855   %x6 = trunc <16 x i16> %x5 to <16 x i8>
    856   ret <16 x i8> %x6
    857   }
    858 
    859 define void @smax_usat_trunc_wb_128_mem(<8 x i16> %i, <8 x i8>* %res) {
    860 ; KNL-LABEL: smax_usat_trunc_wb_128_mem:
    861 ; KNL:       ## %bb.0:
    862 ; KNL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    863 ; KNL-NEXT:    vpmaxsw %xmm1, %xmm0, %xmm0
    864 ; KNL-NEXT:    vpminsw {{.*}}(%rip), %xmm0, %xmm0
    865 ; KNL-NEXT:    vpackuswb %xmm0, %xmm0, %xmm0
    866 ; KNL-NEXT:    vmovq %xmm0, (%rdi)
    867 ; KNL-NEXT:    retq
    868 ;
    869 ; SKX-LABEL: smax_usat_trunc_wb_128_mem:
    870 ; SKX:       ## %bb.0:
    871 ; SKX-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    872 ; SKX-NEXT:    vpmaxsw %xmm1, %xmm0, %xmm0
    873 ; SKX-NEXT:    vpmovuswb %xmm0, (%rdi)
    874 ; SKX-NEXT:    retq
    875   %x1 = icmp sgt <8 x i16> %i, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    876   %x2 = select <8 x i1> %x1, <8 x i16> %i, <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
    877   %x3 = icmp slt <8 x i16> %x2, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    878   %x5 = select <8 x i1> %x3, <8 x i16> %x2, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
    879   %x6 = trunc <8 x i16> %x5 to <8 x i8>
    880   store <8 x i8> %x6, <8 x i8>* %res, align 1
    881   ret void
    882 }
    883 
    884 define void @smax_usat_trunc_db_512_mem(<16 x i32> %i, <16 x i8>* %res) {
    885 ; ALL-LABEL: smax_usat_trunc_db_512_mem:
    886 ; ALL:       ## %bb.0:
    887 ; ALL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    888 ; ALL-NEXT:    vpmaxsd %zmm1, %zmm0, %zmm0
    889 ; ALL-NEXT:    vpmovusdb %zmm0, (%rdi)
    890 ; ALL-NEXT:    vzeroupper
    891 ; ALL-NEXT:    retq
    892   %x1 = icmp sgt <16 x i32> %i, <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
    893   %x2 = select <16 x i1> %x1, <16 x i32> %i, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
    894   %x3 = icmp slt <16 x i32> %x2, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    895   %x5 = select <16 x i1> %x3, <16 x i32> %x2, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    896   %x6 = trunc <16 x i32> %x5 to <16 x i8>
    897   store <16 x i8> %x6, <16 x i8>* %res, align 1
    898   ret void
    899 }
    900 
    901 define void @smax_usat_trunc_qb_512_mem(<8 x i64> %i, <8 x i8>* %res) {
    902 ; ALL-LABEL: smax_usat_trunc_qb_512_mem:
    903 ; ALL:       ## %bb.0:
    904 ; ALL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    905 ; ALL-NEXT:    vpmaxsq %zmm1, %zmm0, %zmm0
    906 ; ALL-NEXT:    vpmovusqb %zmm0, (%rdi)
    907 ; ALL-NEXT:    vzeroupper
    908 ; ALL-NEXT:    retq
    909   %x1 = icmp sgt <8 x i64> %i, <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    910   %x2 = select <8 x i1> %x1, <8 x i64> %i, <8 x i64> <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    911   %x3 = icmp slt <8 x i64> %x2, <i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255>
    912   %x5 = select <8 x i1> %x3, <8 x i64> %x2, <8 x i64> <i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255, i64 255>
    913   %x6 = trunc <8 x i64> %x5 to <8 x i8>
    914   store <8 x i8> %x6, <8 x i8>* %res, align 1
    915   ret void
    916 }
    917 
    918 define void @smax_usat_trunc_qd_512_mem(<8 x i64> %i, <8 x i32>* %res) {
    919 ; ALL-LABEL: smax_usat_trunc_qd_512_mem:
    920 ; ALL:       ## %bb.0:
    921 ; ALL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    922 ; ALL-NEXT:    vpmaxsq %zmm1, %zmm0, %zmm0
    923 ; ALL-NEXT:    vpmovusqd %zmm0, (%rdi)
    924 ; ALL-NEXT:    vzeroupper
    925 ; ALL-NEXT:    retq
    926   %x1 = icmp sgt <8 x i64> %i, <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    927   %x2 = select <8 x i1> %x1, <8 x i64> %i, <8 x i64> <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    928   %x3 = icmp slt <8 x i64> %x2, <i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295>
    929   %x5 = select <8 x i1> %x3, <8 x i64> %x2, <8 x i64> <i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295, i64 4294967295>
    930   %x6 = trunc <8 x i64> %x5 to <8 x i32>
    931   store <8 x i32> %x6, <8 x i32>* %res, align 1
    932   ret void
    933 }
    934 
    935 define void @smax_usat_trunc_qw_512_mem(<8 x i64> %i, <8 x i16>* %res) {
    936 ; ALL-LABEL: smax_usat_trunc_qw_512_mem:
    937 ; ALL:       ## %bb.0:
    938 ; ALL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
    939 ; ALL-NEXT:    vpmaxsq %zmm1, %zmm0, %zmm0
    940 ; ALL-NEXT:    vpmovusqw %zmm0, (%rdi)
    941 ; ALL-NEXT:    vzeroupper
    942 ; ALL-NEXT:    retq
    943   %x1 = icmp sgt <8 x i64> %i, <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    944   %x2 = select <8 x i1> %x1, <8 x i64> %i, <8 x i64> <i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0>
    945   %x3 = icmp slt <8 x i64> %x2, <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    946   %x5 = select <8 x i1> %x3, <8 x i64> %x2, <8 x i64> <i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535, i64 65535>
    947   %x6 = trunc <8 x i64> %x5 to <8 x i16>
    948   store <8 x i16> %x6, <8 x i16>* %res, align 1
    949   ret void
    950 }
    951 
    952 define <32 x i8> @smax_usat_trunc_db_1024(<32 x i32> %i) {
    953 ; KNL-LABEL: smax_usat_trunc_db_1024:
    954 ; KNL:       ## %bb.0:
    955 ; KNL-NEXT:    vpxor %xmm2, %xmm2, %xmm2
    956 ; KNL-NEXT:    vpmaxsd %zmm2, %zmm1, %zmm1
    957 ; KNL-NEXT:    vpmaxsd %zmm2, %zmm0, %zmm0
    958 ; KNL-NEXT:    vpmovusdb %zmm0, %xmm0
    959 ; KNL-NEXT:    vpmovusdb %zmm1, %xmm1
    960 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    961 ; KNL-NEXT:    retq
    962 ;
    963 ; SKX-LABEL: smax_usat_trunc_db_1024:
    964 ; SKX:       ## %bb.0:
    965 ; SKX-NEXT:    vpxor %xmm2, %xmm2, %xmm2
    966 ; SKX-NEXT:    vpmaxsd %zmm2, %zmm0, %zmm0
    967 ; SKX-NEXT:    vpmaxsd %zmm2, %zmm1, %zmm1
    968 ; SKX-NEXT:    vpbroadcastd {{.*#+}} zmm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
    969 ; SKX-NEXT:    vpminsd %zmm2, %zmm1, %zmm1
    970 ; SKX-NEXT:    vpminsd %zmm2, %zmm0, %zmm0
    971 ; SKX-NEXT:    vpmovdw %zmm0, %ymm0
    972 ; SKX-NEXT:    vpmovdw %zmm1, %ymm1
    973 ; SKX-NEXT:    vinserti64x4 $1, %ymm1, %zmm0, %zmm0
    974 ; SKX-NEXT:    vpmovwb %zmm0, %ymm0
    975 ; SKX-NEXT:    retq
    976   %x1 = icmp sgt <32 x i32> %i, <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
    977   %x2 = select <32 x i1> %x1, <32 x i32> %i, <32 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
    978   %x3 = icmp slt <32 x i32> %x2, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    979   %x5 = select <32 x i1> %x3, <32 x i32> %x2, <32 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
    980   %x6 = trunc <32 x i32> %x5 to <32 x i8>
    981   ret <32 x i8> %x6
    982 }
    983 
    984 define void @smax_usat_trunc_db_1024_mem(<32 x i32> %i, <32 x i8>* %p) {
    985 ; KNL-LABEL: smax_usat_trunc_db_1024_mem:
    986 ; KNL:       ## %bb.0:
    987 ; KNL-NEXT:    vpxor %xmm2, %xmm2, %xmm2
    988 ; KNL-NEXT:    vpmaxsd %zmm2, %zmm1, %zmm1
    989 ; KNL-NEXT:    vpmaxsd %zmm2, %zmm0, %zmm0
    990 ; KNL-NEXT:    vpmovusdb %zmm0, %xmm0
    991 ; KNL-NEXT:    vpmovusdb %zmm1, %xmm1
    992 ; KNL-NEXT:    vinserti128 $1, %xmm1, %ymm0, %ymm0
    993 ; KNL-NEXT:    vmovdqu %ymm0, (%rdi)
    994 ; KNL-NEXT:    vzeroupper
    995 ; KNL-NEXT:    retq
    996 ;
    997 ; SKX-LABEL: smax_usat_trunc_db_1024_mem:
    998 ; SKX:       ## %bb.0:
    999 ; SKX-NEXT:    vpxor %xmm2, %xmm2, %xmm2
   1000 ; SKX-NEXT:    vpmaxsd %zmm2, %zmm0, %zmm0
   1001 ; SKX-NEXT:    vpmaxsd %zmm2, %zmm1, %zmm1
   1002 ; SKX-NEXT:    vpbroadcastd {{.*#+}} zmm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
   1003 ; SKX-NEXT:    vpminsd %zmm2, %zmm1, %zmm1
   1004 ; SKX-NEXT:    vpminsd %zmm2, %zmm0, %zmm0
   1005 ; SKX-NEXT:    vpmovdw %zmm0, %ymm0
   1006 ; SKX-NEXT:    vpmovdw %zmm1, %ymm1
   1007 ; SKX-NEXT:    vinserti64x4 $1, %ymm1, %zmm0, %zmm0
   1008 ; SKX-NEXT:    vpmovwb %zmm0, (%rdi)
   1009 ; SKX-NEXT:    vzeroupper
   1010 ; SKX-NEXT:    retq
   1011   %x1 = icmp sgt <32 x i32> %i, <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
   1012   %x2 = select <32 x i1> %x1, <32 x i32> %i, <32 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
   1013   %x3 = icmp slt <32 x i32> %x2, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
   1014   %x5 = select <32 x i1> %x3, <32 x i32> %x2, <32 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
   1015   %x6 = trunc <32 x i32> %x5 to <32 x i8>
   1016   store <32 x i8>%x6, <32 x i8>* %p, align 1
   1017   ret void
   1018 }
   1019 
   1020 define <16 x i16> @smax_usat_trunc_dw_512(<16 x i32> %i) {
   1021 ; ALL-LABEL: smax_usat_trunc_dw_512:
   1022 ; ALL:       ## %bb.0:
   1023 ; ALL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
   1024 ; ALL-NEXT:    vpmaxsd %zmm1, %zmm0, %zmm0
   1025 ; ALL-NEXT:    vpmovusdw %zmm0, %ymm0
   1026 ; ALL-NEXT:    retq
   1027   %x1 = icmp sgt <16 x i32> %i, <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
   1028   %x2 = select <16 x i1> %x1, <16 x i32> %i, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
   1029   %x3 = icmp slt <16 x i32> %x2, <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
   1030   %x5 = select <16 x i1> %x3, <16 x i32> %x2, <16 x i32> <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
   1031   %x6 = trunc <16 x i32> %x5 to <16 x i16>
   1032   ret <16 x i16> %x6
   1033 }
   1034 
   1035 define void @negative_test1_smax_usat_trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) {
   1036 ; KNL-LABEL: negative_test1_smax_usat_trunc_wb_256_mem:
   1037 ; KNL:       ## %bb.0:
   1038 ; KNL-NEXT:    vpxor %xmm1, %xmm1, %xmm1
   1039 ; KNL-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
   1040 ; KNL-NEXT:    vpcmpeqd %ymm1, %ymm1, %ymm1
   1041 ; KNL-NEXT:    vpminsw %ymm1, %ymm0, %ymm0
   1042 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
   1043 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
   1044 ; KNL-NEXT:    vzeroupper
   1045 ; KNL-NEXT:    retq
   1046 ;
   1047 ; SKX-LABEL: negative_test1_smax_usat_trunc_wb_256_mem:
   1048 ; SKX:       ## %bb.0:
   1049 ; SKX-NEXT:    vpxor %xmm1, %xmm1, %xmm1
   1050 ; SKX-NEXT:    vpmaxsw %ymm1, %ymm0, %ymm0
   1051 ; SKX-NEXT:    vpcmpeqd %ymm1, %ymm1, %ymm1
   1052 ; SKX-NEXT:    vpminsw %ymm1, %ymm0, %ymm0
   1053 ; SKX-NEXT:    vpmovwb %ymm0, (%rdi)
   1054 ; SKX-NEXT:    vzeroupper
   1055 ; SKX-NEXT:    retq
   1056   %x1 = icmp sgt <16 x i16> %i, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
   1057   %x2 = select <16 x i1> %x1, <16 x i16> %i, <16 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
   1058   %x3 = icmp slt <16 x i16> %x2, <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>
   1059   %x5 = select <16 x i1> %x3, <16 x i16> %x2, <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>
   1060   %x6 = trunc <16 x i16> %x5 to <16 x i8>
   1061   store <16 x i8> %x6, <16 x i8>* %res, align 1
   1062   ret void
   1063 }
   1064 
   1065 define void @negative_test2_smax_usat_trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) {
   1066 ; KNL-LABEL: negative_test2_smax_usat_trunc_wb_256_mem:
   1067 ; KNL:       ## %bb.0:
   1068 ; KNL-NEXT:    vpmaxsw {{.*}}(%rip), %ymm0, %ymm0
   1069 ; KNL-NEXT:    vpminsw {{.*}}(%rip), %ymm0, %ymm0
   1070 ; KNL-NEXT:    vpmovsxwd %ymm0, %zmm0
   1071 ; KNL-NEXT:    vpmovdb %zmm0, (%rdi)
   1072 ; KNL-NEXT:    vzeroupper
   1073 ; KNL-NEXT:    retq
   1074 ;
   1075 ; SKX-LABEL: negative_test2_smax_usat_trunc_wb_256_mem:
   1076 ; SKX:       ## %bb.0:
   1077 ; SKX-NEXT:    vpmaxsw {{.*}}(%rip), %ymm0, %ymm0
   1078 ; SKX-NEXT:    vpminsw {{.*}}(%rip), %ymm0, %ymm0
   1079 ; SKX-NEXT:    vpmovwb %ymm0, (%rdi)
   1080 ; SKX-NEXT:    vzeroupper
   1081 ; SKX-NEXT:    retq
   1082   %x1 = icmp sgt <16 x i16> %i, <i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10>
   1083   %x2 = select <16 x i1> %x1, <16 x i16> %i, <16 x i16> <i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10, i16 -10>
   1084   %x3 = icmp slt <16 x i16> %x2, <i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5>
   1085   %x5 = select <16 x i1> %x3, <16 x i16> %x2, <16 x i16> <i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5, i16 -5>
   1086   %x6 = trunc <16 x i16> %x5 to <16 x i8>
   1087   store <16 x i8> %x6, <16 x i8>* %res, align 1
   1088   ret void
   1089 }
   1090