summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/avx512f-kortestw-2.c
blob: 4b9cadcc2d1d9f29f43dbd9b21a3860d146e8ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* { dg-do run } */
/* { dg-options "-O2 -mavx512f" } */
/* { dg-require-effective-target avx512f } */

#include "avx512f-check.h"

void
avx512f_test () {
  volatile __mmask16 k1;
  __mmask16 k2;
  volatile short r = 0;

  /* Test kortestc.  */
  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (45) );

  r += _mm512_kortestc (k1, k2);

  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (0) );

  r += _mm512_kortestc (k1, k2);
  if (r)
    abort ();

  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (-1) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (0) );

  r += _mm512_kortestc (k1, k2);
  if (!r)
    abort ();

  r = 0;
  /* Test kortestz.  */
  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (45) );

  r += _mm512_kortestz (k1, k2);

  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (-1) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (0) );

  r += _mm512_kortestz (k1, k2);
  if (r)
    abort ();

  __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) );
  __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (0) );

  r += _mm512_kortestz (k1, k2);
  if (!r)
    abort ();
}