]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Builtins for AES acceleration instructions [RFC02657]
authorAvinash Jayakar <avinashd@linux.ibm.com>
Wed, 4 Mar 2026 10:00:24 +0000 (05:00 -0500)
committerAvinash Jayakar <avinashd@linux.ibm.com>
Thu, 7 May 2026 10:33:59 +0000 (16:03 +0530)
This patch adds new builtins for AES acceleration instructions which
may or may not be supported in a future processor. Note, the names of
the builtins may change in future.

The following new builtins for AES acceleration can be used with
-mcpu=future option:
__vector_pair  __builtin_aes_encrypt_paired (__vector_pair,
     __vector_pair, uint2);
__vector_pair  __builtin_aes128_encrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes192_encrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes256_encrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes_decrypt_paired (__vector_pair,
     __vector_pair, uint2);
__vector_pair  __builtin_aes128_decrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes192_decrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes256_decrypt_paired (__vector_pair,
__vector_pair);
__vector_pair  __builtin_aes_genlastkey_paired (__vector_pair, uint2);
__vector_pair  __builtin_aes128_genlastkey_paired (__vector_pair);
__vector_pair  __builtin_aes192_genlastkey_paired (__vector_pair);
__vector_pair  __builtin_aes256_genlastkey_paired (__vector_pair);
vec_t __builtin_galois_field_mult (vec_t, vec_t, uint1);
vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);
vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);

2026-05-07  Avinash Jayakar  <avinashd@linux.ibm.com>

gcc/ChangeLog:
* config/rs6000/crypto.md (UNSPEC_XXAESENCP): New unspec entry.
(UNSPEC_XXAES128ENCP): Likewise.
(UNSPEC_XXAES192ENCP): Likewise.
(UNSPEC_XXAES256ENCP): Likewise.
(UNSPEC_XXAESDECP): Likewise.
(UNSPEC_XXAES128DECP): Likewise.
(UNSPEC_XXAES192DECP): Likewise.
(UNSPEC_XXAES256DECP): Likewise.
(UNSPEC_XXAESGENLKP): Likewise.
(UNSPEC_XXAES128GENLKP): Likewise.
(UNSPEC_XXAES192GENLKP): Likewise.
(UNSPEC_XXAES256GENLKP): Likewise.
(UNSPEC_XXGFMUL128): Likewise.
(UNSPEC_XXGFMUL128GCM): Likewise.
(UNSPEC_XXGFMUL128XTS): Likewise.
(AESACC_base_code): New iterator for xxaesencp and xxaesdecp base
mnemonics.
(AESACC_code): New iterator for xxaesencp and xxaesdecp extended
mnemonics.
(AESGENLKP_code): New iterator for xxaesgenlkp extended mnemonics.
(AESGF_code): New iterator for xxgfmul128 extended mnemonics.
(AESACC_base_insn): New attribute iterator for xxaesencp and xxaesdecp
base mnemonics.
(AESACC_insn): New attribute iterator for xxaesencp and xxaesdecp
extended mnemonics.
(AESGENLKP_insn): New attribute iterator for xxaesgenlkp extended
mnemonics.
(AESGF_insn): New attribute iterator for xxgfmul128 extended mnemonics.
(<AESACC_base_insn>): New define_insn for xxaesencp and xxaesdecp base
mnemonics.
(<AESACC_insn>): New define_insn for xxaesencp and xxaesdecp extended
mnemonics.
(<AESGENLKP_insn>): New define_insn for xxaesgenlkp extended mnemonics.
(xxaesgenlkp): New define_insn for genlkp base mnemonic.
(<AESGF_insn>): New define_insn for xxgfmul128 extended mnemonics.
(xxgfmul128): New define_insn for xxgfmul128 base mnemonic.
* config/rs6000/rs6000-builtins.def: Added new builtin definitions for
AES acceleration.
* doc/extend.texi: Add new section for AES acceleration builtins
for Future ISA.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/aes-builtin-1.c: New test.
* gcc.target/powerpc/aes-builtin-2.c: New test.
* gcc.target/powerpc/aes-builtin-3.c: New test.

gcc/config/rs6000/crypto.md
gcc/config/rs6000/rs6000-builtins.def
gcc/doc/extend.texi
gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c [new file with mode: 0644]

index f91791673c9f41177878d705b09a9b6e9a760f77..a25d9f75439b625cfc9e987c8c82fd6810d14855 100644 (file)
    UNSPEC_VSBOX
    UNSPEC_VSHASIGMA
    UNSPEC_VPERMXOR
-   UNSPEC_VPMSUM])
+   UNSPEC_VPMSUM
+   UNSPEC_XXAESENCP
+   UNSPEC_XXAES128ENCP
+   UNSPEC_XXAES192ENCP
+   UNSPEC_XXAES256ENCP
+   UNSPEC_XXAESDECP
+   UNSPEC_XXAES128DECP
+   UNSPEC_XXAES192DECP
+   UNSPEC_XXAES256DECP
+   UNSPEC_XXAESGENLKP
+   UNSPEC_XXAES128GENLKP
+   UNSPEC_XXAES192GENLKP
+   UNSPEC_XXAES256GENLKP
+   UNSPEC_XXGFMUL128
+   UNSPEC_XXGFMUL128GCM
+   UNSPEC_XXGFMUL128XTS])
 
 ;; Iterator for VPMSUM/VPERMXOR
 (define_mode_iterator CR_mode [V16QI V8HI V4SI V2DI])
                          (UNSPEC_VCIPHERLAST  "vcipherlast")
                          (UNSPEC_VNCIPHERLAST "vncipherlast")])
 
+;; Iterator and attribute for AES encrypt/decrypt
+(define_int_iterator AESACC_base_code [UNSPEC_XXAESENCP
+                                      UNSPEC_XXAESDECP])
+(define_int_attr AESACC_base_insn [(UNSPEC_XXAESENCP  "xxaesencp")
+                                  (UNSPEC_XXAESDECP  "xxaesdecp")])
+
+;; Iterator and attribute for AES encrypt/decrypt extended mnemonics
+(define_int_iterator AESACC_code [UNSPEC_XXAES128ENCP
+                                 UNSPEC_XXAES192ENCP
+                                 UNSPEC_XXAES256ENCP
+                                 UNSPEC_XXAES128DECP
+                                 UNSPEC_XXAES192DECP
+                                 UNSPEC_XXAES256DECP])
+(define_int_attr AESACC_insn [(UNSPEC_XXAES128ENCP  "xxaes128encp")
+                             (UNSPEC_XXAES192ENCP  "xxaes192encp")
+                             (UNSPEC_XXAES256ENCP  "xxaes256encp")
+                             (UNSPEC_XXAES128DECP  "xxaes128decp")
+                             (UNSPEC_XXAES192DECP  "xxaes192decp")
+                             (UNSPEC_XXAES256DECP  "xxaes256decp")])
+
+;; Iterator and attribute for AES gen last key extended mnemonics
+(define_int_iterator AESGENLKP_code [UNSPEC_XXAES128GENLKP
+                                    UNSPEC_XXAES192GENLKP
+                                    UNSPEC_XXAES256GENLKP])
+(define_int_attr AESGENLKP_insn [(UNSPEC_XXAES128GENLKP  "xxaes128genlkp")
+                                (UNSPEC_XXAES192GENLKP  "xxaes192genlkp")
+                                (UNSPEC_XXAES256GENLKP  "xxaes256genlkp")])
+
+;; Iterator and attribute for AES galois field mult extended mnemonics
+(define_int_iterator AESGF_code [UNSPEC_XXGFMUL128GCM
+                                UNSPEC_XXGFMUL128XTS])
+(define_int_attr AESGF_insn [(UNSPEC_XXGFMUL128GCM  "xxgfmul128gcm")
+                            (UNSPEC_XXGFMUL128XTS  "xxgfmul128xts")])
+
 ;; 2 operand crypto instructions
 (define_insn "crypto_<CR_insn>_<mode>"
   [(set (match_operand:CR_vqdi 0 "register_operand" "=v")
   "TARGET_CRYPTO"
   "vshasigma<CR_char> %0,%1,%2,%3"
   [(set_attr "type" "vecsimple")])
+
+;; AES acceleration instructions
+
+(define_insn "<AESACC_base_insn>"
+  [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+       (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+                   (match_operand:OO 2 "vsx_register_operand" "wa")
+                   (match_operand:SI 3 "const_0_to_3_operand" "n")]
+                  AESACC_base_code))]
+  "TARGET_FUTURE"
+  "<AESACC_base_insn> %x0,%x1,%x2,%3")
+
+(define_insn "<AESACC_insn>"
+  [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+    (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+               (match_operand:OO 2 "vsx_register_operand" "wa")]
+              AESACC_code))]
+  "TARGET_FUTURE"
+  "<AESACC_insn> %x0,%x1,%x2")
+
+(define_insn "xxaesgenlkp"
+  [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+    (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+               (match_operand:SI 2 "const_0_to_3_operand" "n")]
+              UNSPEC_XXAESGENLKP))]
+  "TARGET_FUTURE"
+  "xxaesgenlkp %x0,%x1,%2")
+
+(define_insn "<AESGENLKP_insn>"
+  [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+    (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")]
+              AESGENLKP_code))]
+  "TARGET_FUTURE"
+  "<AESGENLKP_insn> %x0,%x1")
+
+(define_insn "xxgfmul128"
+  [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
+    (unspec:V16QI [(match_operand:V16QI 1 "vsx_register_operand" "wa")
+                  (match_operand:V16QI 2 "vsx_register_operand" "wa")
+                  (match_operand:SI 3 "const_0_to_1_operand" "n")]
+                 UNSPEC_XXGFMUL128))]
+  "TARGET_FUTURE"
+  "xxgfmul128 %x0,%x1,%x2,%3")
+
+(define_insn "<AESGF_insn>"
+  [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
+    (unspec:V16QI [(match_operand:V16QI 1 "vsx_register_operand" "wa")
+                  (match_operand:V16QI 2 "vsx_register_operand" "wa")]
+                 AESGF_code))]
+  "TARGET_FUTURE"
+  "<AESGF_insn> %x0,%x1,%x2")
index 7e5a4fb96e72a0d9c64d6276f49fce588026c00a..0d1529b71d428b8871ce3d76f3965fb590555050 100644 (file)
 
   void __builtin_vsx_stxvp (v256, unsigned long, const v256 *);
     STXVP nothing {mma,pair}
+
+[future]
+  const v256 __builtin_aes_encrypt_paired (v256, v256, const int<2>);
+    XXAESENCP xxaesencp {}
+
+  const v256 __builtin_aes128_encrypt_paired (v256, v256);
+    XXAES128ENCP xxaes128encp {}
+
+  const v256 __builtin_aes192_encrypt_paired (v256, v256);
+    XXAES192ENCP xxaes192encp {}
+
+  const v256 __builtin_aes256_encrypt_paired (v256, v256);
+    XXAES256ENCP xxaes256encp {}
+
+  const v256 __builtin_aes_decrypt_paired (v256, v256, const int<2>);
+    XXAESDECP xxaesdecp {}
+
+  const v256 __builtin_aes128_decrypt_paired (v256, v256);
+    XXAES128DECP xxaes128decp {}
+
+  const v256 __builtin_aes192_decrypt_paired (v256, v256);
+    XXAES192DECP xxaes192decp {}
+
+  const v256 __builtin_aes256_decrypt_paired (v256, v256);
+    XXAES256DECP xxaes256decp {}
+
+  const v256 __builtin_aes_genlastkey_paired (v256, const int<2>);
+    XXAESGENLKP xxaesgenlkp {}
+
+  const v256 __builtin_aes128_genlastkey_paired (v256);
+    XXAES128GENLKP xxaes128genlkp {}
+
+  const v256 __builtin_aes192_genlastkey_paired (v256);
+    XXAES192GENLKP xxaes192genlkp {}
+
+  const v256 __builtin_aes256_genlastkey_paired (v256);
+    XXAES256GENLKP xxaes256genlkp {}
+
+  const vuc __builtin_galois_field_mult (vuc, vuc, const int<1>);
+    XXGFMUL128 xxgfmul128 {}
+
+  const vuc __builtin_galois_field_mult_gcm (vuc, vuc);
+    XXGFMUL128GCM xxgfmul128gcm {}
+
+  const vuc __builtin_galois_field_mult_xts (vuc, vuc);
+    XXGFMUL128XTS xxgfmul128xts {}
index 181e7e1bf52485b7f562897c01eaac691e5aae05..42f83b98a05bcb16d19080fe856fab271d0d09c7 100644 (file)
@@ -24654,6 +24654,7 @@ The PVIPR documents the following overloaded functions:
 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
 * PowerPC AltiVec Built-in Functions Available on ISA 3.1::
+* PowerPC AltiVec/VSX Built-in Functions Available on Future ISA::
 @end menu
 
 @node PowerPC AltiVec Built-in Functions on ISA 2.05
@@ -26687,6 +26688,56 @@ vector unsigned char);
 vector unsigned char);
 @end smallexample
 
+@node PowerPC AltiVec/VSX Built-in Functions Available on Future ISA
+@subsubsection PowerPC AltiVec/VSX Built-in Functions Available on Future ISA
+
+The following additional built-in functions are available for the
+PowerPC family of processors, starting with Future ISA.
+
+Future ISA of the PowerPC may add new instructions for accelerating AES
+algorithm. GCC provides support for these new instructions through the
+following built-in functions. The third argument to
+@var{__builtin_aes_encrypt_paired} and @var{__builtin_aes_decrypt_paired} must
+be a constant integer that is 0, 1 or 2. The values correspond to 128, 192 and
+256 bit AES encryption/decryption respectively. The third argument to
+@var{__builtin_galois_field_mult} must be a constant integer that is 0 or 1.
+The values correspond to gcm and xts variant respectively.
+
+@smallexample
+__vector_pair  __builtin_aes_encrypt_paired (__vector_pair, __vector_pair,
+                                             int);
+
+__vector_pair  __builtin_aes128_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes192_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes256_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes_decrypt_paired (__vector_pair, __vector_pair,
+                                             int);
+
+__vector_pair  __builtin_aes128_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes192_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes256_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair  __builtin_aes_genlastkey_paired (__vector_pair, int);
+
+__vector_pair  __builtin_aes128_genlastkey_paired (__vector_pair);
+
+__vector_pair  __builtin_aes192_genlastkey_paired (__vector_pair);
+
+__vector_pair  __builtin_aes256_genlastkey_paired (__vector_pair);
+
+vec_t __builtin_galois_field_mult (vec_t, vec_t, int);
+
+vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);
+
+vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);
+@end smallexample
+
+
 @node PowerPC Hardware Transactional Memory Built-in Functions
 @subsection PowerPC Hardware Transactional Memory Built-in Functions
 GCC provides two interfaces for accessing the Hardware Transactional
diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c
new file mode 100644 (file)
index 0000000..2777fcd
--- /dev/null
@@ -0,0 +1,155 @@
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+void
+aes_enc_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 0);
+  *res = c;
+}
+void
+aes_enc_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 1);
+  *res = c;
+}
+void
+aes_enc_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 2);
+  *res = c;
+}
+void
+aes_enc_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes128_encrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_enc_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes192_encrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_enc_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes256_encrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_dec_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 0);
+  *res = c;
+}
+void
+aes_dec_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 1);
+  *res = c;
+}
+void
+aes_dec_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 2);
+  *res = c;
+}
+void
+aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes128_decrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes192_decrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes256_decrypt_paired (t, k);
+  *res = c;
+}
+void
+aes_genlastkey_paired_0 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_genlastkey_paired (k, 0);
+  *res = c;
+}
+void
+aes_genlastkey_paired_1 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_genlastkey_paired (k, 1);
+  *res = c;
+}
+void
+aes_genlastkey_paired_2 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes_genlastkey_paired (k, 2);
+  *res = c;
+}
+void
+aes_genlastkey_paired_128 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes128_genlastkey_paired (k);
+  *res = c;
+}
+void
+aes_genlastkey_paired_192 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes192_genlastkey_paired (k);
+  *res = c;
+}
+void
+aes_genlastkey_paired_256 (__vector_pair *key, __vector_pair *res)
+{
+  __vector_pair k = *key;
+  __vector_pair c = __builtin_aes256_genlastkey_paired (k);
+  *res = c;
+}
+
+
+/* { dg-final { scan-assembler-times {\mxxaesencp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesdecp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesgenlkp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256genlkp\M} 1 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c
new file mode 100644 (file)
index 0000000..98f16ad
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+typedef unsigned char vec_t __attribute__((vector_size(16)));
+
+void
+gfmul (vec_t *a, vec_t *b, vec_t *res)
+{
+  vec_t A = *a;
+  vec_t B = *b;
+  vec_t R = __builtin_galois_field_mult (A, B, 0);
+  R = __builtin_galois_field_mult (R, B, 1);
+  *res = R;
+}
+void
+gfmul_gcm (vec_t *a, vec_t *b, vec_t *res)
+{
+  vec_t A = *a;
+  vec_t B = *b;
+  vec_t R = __builtin_galois_field_mult_gcm (A, B);
+  *res = R;
+}
+void
+gfmul_xts (vec_t *a, vec_t *b, vec_t *res)
+{
+  vec_t A = *a;
+  vec_t B = *b;
+  vec_t R = __builtin_galois_field_mult_xts (A, B);
+  *res = R;
+}
+
+/* { dg-final { scan-assembler-times {\mxxgfmul128\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mxxgfmul128gcm\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxgfmul128xts\M} 1 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c
new file mode 100644 (file)
index 0000000..007bf87
--- /dev/null
@@ -0,0 +1,52 @@
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+void
+aes_dec_pair (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair lk = __builtin_aes_genlastkey_paired (k, 0);
+  __vector_pair c = __builtin_aes_decrypt_paired (t, lk, 0);
+  lk = __builtin_aes_genlastkey_paired (k, 1);
+  c = __builtin_aes_decrypt_paired (c, lk, 1);
+  lk = __builtin_aes_genlastkey_paired (k, 2);
+  c = __builtin_aes_decrypt_paired (c, lk, 2);
+  *res = c;
+}
+void
+aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair lk = __builtin_aes128_genlastkey_paired (k);
+  __vector_pair c = __builtin_aes128_decrypt_paired (t, lk);
+  *res = c;
+}
+void
+aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair lk = __builtin_aes192_genlastkey_paired (k);
+  __vector_pair c = __builtin_aes192_decrypt_paired (t, lk);
+  *res = c;
+}
+void
+aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+  __vector_pair t = *text;
+  __vector_pair k = *key;
+  __vector_pair lk = __builtin_aes256_genlastkey_paired (k);
+  __vector_pair c = __builtin_aes256_decrypt_paired (t, lk);
+  *res = c;
+}
+
+/* { dg-final { scan-assembler-times {\mxxaesdecp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesgenlkp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256genlkp\M} 1 } } */
\ No newline at end of file