(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
crypto-builtin-1.c
       1  /* { dg-do compile { target { powerpc*-*-* } } } */
       2  /* { dg-skip-if "" { powerpc*-*-darwin* } } */
       3  /* { dg-require-effective-target powerpc_p8vector_ok } */
       4  /* { dg-options "-mdejagnu-cpu=power8 -O2 -ftree-vectorize -fvect-cost-model=dynamic -fno-unroll-loops -fno-unroll-all-loops" } */
       5  
       6  #include <altivec.h>
       7  typedef vector unsigned long long	crypto_t;
       8  typedef vector unsigned long long	v2di_t;
       9  typedef vector unsigned int		v4si_t;
      10  typedef vector unsigned short		v8hi_t;
      11  typedef vector unsigned char		v16qi_t;
      12  
      13  crypto_t crypto1 (crypto_t a)
      14  {
      15    return __builtin_crypto_vsbox (a);
      16  }
      17  
      18  v16qi_t crypto1_be (v16qi_t a)
      19  {
      20    return vec_sbox_be (a);
      21  }
      22  
      23  crypto_t crypto2 (crypto_t a, crypto_t b)
      24  {
      25    return __builtin_crypto_vcipher (a, b);
      26  }
      27  
      28  v16qi_t crypto2_be (v16qi_t a, v16qi_t b)
      29  {
      30    return vec_cipher_be (a, b);
      31  }
      32  
      33  crypto_t crypto3 (crypto_t a, crypto_t b)
      34  {
      35    return __builtin_crypto_vcipherlast (a, b);
      36  }
      37  
      38  v16qi_t crypto3_be (v16qi_t a, v16qi_t b)
      39  {
      40    return vec_cipherlast_be (a, b);
      41  }
      42  
      43  crypto_t crypto4 (crypto_t a, crypto_t b)
      44  {
      45    return __builtin_crypto_vncipher (a, b);
      46  }
      47  
      48  v16qi_t crypto4_be (v16qi_t a, v16qi_t b)
      49  {
      50    return vec_ncipher_be (a, b);
      51  }
      52  
      53  crypto_t crypto5 (crypto_t a, crypto_t b)
      54  {
      55    return __builtin_crypto_vncipherlast (a, b);
      56  }
      57  
      58  v16qi_t crypto5_be (v16qi_t a, v16qi_t b)
      59  {
      60    return vec_ncipherlast_be (a, b);
      61  }
      62  
      63  v16qi_t crypto6a (v16qi_t a, v16qi_t b, v16qi_t c)
      64  {
      65    return __builtin_crypto_vpermxor (a, b, c);
      66  }
      67  
      68  v8hi_t crypto6b (v8hi_t a, v8hi_t b, v8hi_t c)
      69  {
      70    return __builtin_crypto_vpermxor (a, b, c);
      71  }
      72  
      73  v4si_t crypto6c (v4si_t a, v4si_t b, v4si_t c)
      74  {
      75    return __builtin_crypto_vpermxor (a, b, c);
      76  }
      77  
      78  v2di_t crypto6d (v2di_t a, v2di_t b, v2di_t c)
      79  {
      80    return __builtin_crypto_vpermxor (a, b, c);
      81  }
      82  
      83  v16qi_t crypto7a (v16qi_t a, v16qi_t b)
      84  {
      85    return __builtin_crypto_vpmsumb (a, b);
      86  }
      87  
      88  v16qi_t crypto7b (v16qi_t a, v16qi_t b)
      89  {
      90    return __builtin_crypto_vpmsum (a, b);
      91  }
      92  
      93  v8hi_t crypto7c (v8hi_t a, v8hi_t b)
      94  {
      95    return __builtin_crypto_vpmsumh (a, b);
      96  }
      97  
      98  v8hi_t crypto7d (v8hi_t a, v8hi_t b)
      99  {
     100    return __builtin_crypto_vpmsum (a, b);
     101  }
     102  
     103  v4si_t crypto7e (v4si_t a, v4si_t b)
     104  {
     105    return __builtin_crypto_vpmsumw (a, b);
     106  }
     107  
     108  v4si_t crypto7f (v4si_t a, v4si_t b)
     109  {
     110    return __builtin_crypto_vpmsum (a, b);
     111  }
     112  
     113  v2di_t crypto7g (v2di_t a, v2di_t b)
     114  {
     115    return __builtin_crypto_vpmsumd (a, b);
     116  }
     117  
     118  v2di_t crypto7h (v2di_t a, v2di_t b)
     119  {
     120    return __builtin_crypto_vpmsum (a, b);
     121  }
     122  
     123  v2di_t crypto8a (v2di_t a)
     124  {
     125    return __builtin_crypto_vshasigmad (a, 0, 8);
     126  }
     127  
     128  v2di_t crypto8b (v2di_t a)
     129  {
     130    return __builtin_crypto_vshasigma (a, 0, 8);
     131  }
     132  
     133  v4si_t crypto8c (v4si_t a)
     134  {
     135    return __builtin_crypto_vshasigmaw (a, 1, 15);
     136  }
     137  
     138  v4si_t crypto8d (v4si_t a)
     139  {
     140    return __builtin_crypto_vshasigma (a, 1, 15);
     141  }
     142  
     143  /* Note space is used after the instruction so that vcipherlast does not match
     144     vcipher.  */
     145  /* { dg-final { scan-assembler-times "vcipher "      2 } } */
     146  /* { dg-final { scan-assembler-times "vcipherlast "  2 } } */
     147  /* { dg-final { scan-assembler-times "vncipher "     2 } } */
     148  /* { dg-final { scan-assembler-times "vncipherlast " 2 } } */
     149  /* { dg-final { scan-assembler-times "vpermxor "     4 } } */
     150  /* { dg-final { scan-assembler-times "vpmsumb "      2 } } */
     151  /* { dg-final { scan-assembler-times "vpmsumd "      2 } } */
     152  /* { dg-final { scan-assembler-times "vpmsumh "      2 } } */
     153  /* { dg-final { scan-assembler-times "vpmsumw "      2 } } */
     154  /* { dg-final { scan-assembler-times "vsbox "        2 } } */
     155  /* { dg-final { scan-assembler-times "vshasigmad "   2 } } */
     156  /* { dg-final { scan-assembler-times "vshasigmaw "   2 } } */