[{"id":3684659,"web_url":"http://patchwork.ozlabs.org/comment/3684659/","msgid":"<59acedf8-8ade-4574-9329-1f19d2fb90d4@linux.ibm.com>","list_archive_url":null,"date":"2026-04-30T12:20:12","subject":"Re: [PATCH v4] rs6000: Builtins for AES acceleration instructions\n [RFC02657]","submitter":{"id":88474,"url":"http://patchwork.ozlabs.org/api/people/88474/","name":"Surya Kumari Jangala","email":"jskumari@linux.ibm.com"},"content":"Hi,\n\nOn 30/04/26 3:15 PM, Avinash Jayakar wrote:\n> Hi,\n> \n> Thanks for the review of the documentation. I have incorporated the changes\n> requested.\n> \n> Changes from v3:\n> * Addressed review comments regarding ISA version.\n> * Updated AES builtin description in extend.text.\n> \n> Changes from v2:\n> * Added extend.texi documentation for the new builtins.\n> \n> Changes from v1:\n> * Update commit message.\n> * Add comments for iterators/attributes in crypto.md.\n> * Corrected formatting in crypto.md.\n> * Removed mma attribute for aes builtins.\n> * Updated function names in aes-builtin-1.c.\n> * aes-builtin-1.c now has 1 builtin per function.\n> * Separated out the combined builtin test case in aes-builtin-3.c.\n> \n> Following patch depends on these 2 patches in the following order:\n> 1. mcpu=future: https://gcc.gnu.org/pipermail/gcc-patches/2025-December/703739.html\n> 2. future builtin infra: https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709782.html\n> \n> Bootstrapped and regtested on powerpc64le-linux-gnu with no regressions.\n> \n> Thanks and regards,\n> Avinash Jayakar\n> \n> This patch adds new builtins for AES acceleration instructions which\n> may or may not be supported in a future processor. Note, the names of\n> the builtins may change in future.\n> \n> The following new builtins for AES acceleration can be used with\n> -mcpu=future option:\n> __vector_pair  __builtin_aes_encrypt_paired (__vector_pair,\n> \t\t\t\t\t     __vector_pair, uint2);\n> __vector_pair  __builtin_aes128_encrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes192_encrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes256_encrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes_decrypt_paired (__vector_pair,\n> \t\t\t\t\t     __vector_pair, uint2);\n> __vector_pair  __builtin_aes128_decrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes192_decrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes256_decrypt_paired (__vector_pair,\n> \t\t\t\t\t\t__vector_pair);\n> __vector_pair  __builtin_aes_genlastkey_paired (__vector_pair, uint2);\n> __vector_pair  __builtin_aes128_genlastkey_paired (__vector_pair);\n> __vector_pair  __builtin_aes192_genlastkey_paired (__vector_pair);\n> __vector_pair  __builtin_aes256_genlastkey_paired (__vector_pair);\n> vec_t __builtin_galois_field_mult (vec_t, vec_t, uint1);\n> vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);\n> vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);\n> \n> 2026-04-30  Avinash Jayakar  <avinashd@linux.ibm.com>\n> \n> gcc/ChangeLog:\n> \t* config/rs6000/crypto.md (UNSPEC_XXAESENCP): New unspec entry.\n> \t(UNSPEC_XXAES128ENCP): Likewise.\n> \t(UNSPEC_XXAES192ENCP): Likewise.\n> \t(UNSPEC_XXAES256ENCP): Likewise.\n> \t(UNSPEC_XXAESDECP): Likewise.\n> \t(UNSPEC_XXAES128DECP): Likewise.\n> \t(UNSPEC_XXAES192DECP): Likewise.\n> \t(UNSPEC_XXAES256DECP): Likewise.\n> \t(UNSPEC_XXAESGENLKP): Likewise.\n> \t(UNSPEC_XXAES128GENLKP): Likewise.\n> \t(UNSPEC_XXAES192GENLKP): Likewise.\n> \t(UNSPEC_XXAES256GENLKP): Likewise.\n> \t(UNSPEC_XXGFMUL128): Likewise.\n> \t(UNSPEC_XXGFMUL128GCM): Likewise.\n> \t(UNSPEC_XXGFMUL128XTS): Likewise.\n> \t(AESACC_base_code): New iterator for xxaesencp and xxaesdecp base\n> \tmnemonics.\n> \t(AESACC_code): New iterator for xxaesencp and xxaesdecp extended\n> \tmnemonics.\n> \t(AESGENLKP_code): New iterator for xxaesgenlkp extended mnemonics.\n> \t(AESGF_code): New iterator for xxgfmul128 extended mnemonics.\n> \t(AESACC_base_insn): New attribute iterator for xxaesencp and xxaesdecp\n> \tbase mnemonics.\n> \t(AESACC_insn): New attribute iterator for xxaesencp and xxaesdecp\n> \textended mnemonics.\n> \t(AESGENLKP_insn): New attribute iterator for xxaesgenlkp extended\n> \tmnemonics.\n> \t(AESGF_insn): New attribute iterator for xxgfmul128 extended mnemonics.\n> \t(<AESACC_base_insn>): New define_insn for xxaesencp and xxaesdecp base\n> \tmnemonics.\n> \t(<AESACC_insn>): New define_insn for xxaesencp and xxaesdecp extended\n> \tmnemonics.\n> \t(<AESGENLKP_insn>): New define_insn for xxaesgenlkp extended mnemonics.\n> \t(xxaesgenlkp): New define_insn for genlkp base mnemonic.\n> \t(<AESGF_insn>): New define_insn for xxgfmul128 extended mnemonics.\n> \t(xxgfmul128): New define_insn for xxgfmul128 base mnemonic.\n> \t* config/rs6000/rs6000-builtins.def: Added new builtin definitions for\n> \tAES acceleration.\n> \t* doc/extend.texi: Add new section for AES acceleration builtins\n> \tfor Future ISA.\n> \n> gcc/testsuite/ChangeLog:\n> \t* gcc.target/powerpc/aes-builtin-1.c: New test.\n> \t* gcc.target/powerpc/aes-builtin-2.c: New test.\n> \t* gcc.target/powerpc/aes-builtin-3.c: New test.\n> ---\n>  gcc/config/rs6000/crypto.md                   | 102 +++++++++++-\n>  gcc/config/rs6000/rs6000-builtins.def         |  46 ++++++\n>  gcc/doc/extend.texi                           |  53 ++++++\n>  .../gcc.target/powerpc/aes-builtin-1.c        | 155 ++++++++++++++++++\n>  .../gcc.target/powerpc/aes-builtin-2.c        |  34 ++++\n>  .../gcc.target/powerpc/aes-builtin-3.c        |  52 ++++++\n>  6 files changed, 441 insertions(+), 1 deletion(-)\n>  create mode 100644 gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c\n>  create mode 100644 gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c\n>  create mode 100644 gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c\n> \n> diff --git a/gcc/config/rs6000/crypto.md b/gcc/config/rs6000/crypto.md\n> index f91791673c9..a25d9f75439 100644\n> --- a/gcc/config/rs6000/crypto.md\n> +++ b/gcc/config/rs6000/crypto.md\n> @@ -35,7 +35,22 @@ (define_c_enum \"unspec\"\n>     UNSPEC_VSBOX\n>     UNSPEC_VSHASIGMA\n>     UNSPEC_VPERMXOR\n> -   UNSPEC_VPMSUM])\n> +   UNSPEC_VPMSUM\n> +   UNSPEC_XXAESENCP\n> +   UNSPEC_XXAES128ENCP\n> +   UNSPEC_XXAES192ENCP\n> +   UNSPEC_XXAES256ENCP\n> +   UNSPEC_XXAESDECP\n> +   UNSPEC_XXAES128DECP\n> +   UNSPEC_XXAES192DECP\n> +   UNSPEC_XXAES256DECP\n> +   UNSPEC_XXAESGENLKP\n> +   UNSPEC_XXAES128GENLKP\n> +   UNSPEC_XXAES192GENLKP\n> +   UNSPEC_XXAES256GENLKP\n> +   UNSPEC_XXGFMUL128\n> +   UNSPEC_XXGFMUL128GCM\n> +   UNSPEC_XXGFMUL128XTS])\n>  \n>  ;; Iterator for VPMSUM/VPERMXOR\n>  (define_mode_iterator CR_mode [V16QI V8HI V4SI V2DI])\n> @@ -62,6 +77,40 @@ (define_int_attr CR_insn [(UNSPEC_VCIPHER      \"vcipher\")\n>  \t\t\t  (UNSPEC_VCIPHERLAST  \"vcipherlast\")\n>  \t\t\t  (UNSPEC_VNCIPHERLAST \"vncipherlast\")])\n>  \n> +;; Iterator and attribute for AES encrypt/decrypt\n> +(define_int_iterator AESACC_base_code [UNSPEC_XXAESENCP\n> +\t\t\t\t       UNSPEC_XXAESDECP])\n> +(define_int_attr AESACC_base_insn [(UNSPEC_XXAESENCP  \"xxaesencp\")\n> +\t\t\t\t   (UNSPEC_XXAESDECP  \"xxaesdecp\")])\n> +\n> +;; Iterator and attribute for AES encrypt/decrypt extended mnemonics\n> +(define_int_iterator AESACC_code [UNSPEC_XXAES128ENCP\n> +\t\t\t\t  UNSPEC_XXAES192ENCP\n> +\t\t\t\t  UNSPEC_XXAES256ENCP\n> +\t\t\t\t  UNSPEC_XXAES128DECP\n> +\t\t\t\t  UNSPEC_XXAES192DECP\n> +\t\t\t\t  UNSPEC_XXAES256DECP])\n> +(define_int_attr AESACC_insn [(UNSPEC_XXAES128ENCP  \"xxaes128encp\")\n> +\t\t\t      (UNSPEC_XXAES192ENCP  \"xxaes192encp\")\n> +\t\t\t      (UNSPEC_XXAES256ENCP  \"xxaes256encp\")\n> +\t\t\t      (UNSPEC_XXAES128DECP  \"xxaes128decp\")\n> +\t\t\t      (UNSPEC_XXAES192DECP  \"xxaes192decp\")\n> +\t\t\t      (UNSPEC_XXAES256DECP  \"xxaes256decp\")])\n> +\n> +;; Iterator and attribute for AES gen last key extended mnemonics\n> +(define_int_iterator AESGENLKP_code [UNSPEC_XXAES128GENLKP\n> +\t\t\t\t     UNSPEC_XXAES192GENLKP\n> +\t\t\t\t     UNSPEC_XXAES256GENLKP])\n> +(define_int_attr AESGENLKP_insn [(UNSPEC_XXAES128GENLKP  \"xxaes128genlkp\")\n> +\t\t\t\t (UNSPEC_XXAES192GENLKP  \"xxaes192genlkp\")\n> +\t\t\t\t (UNSPEC_XXAES256GENLKP  \"xxaes256genlkp\")])\n> +\n> +;; Iterator and attribute for AES galois field mult extended mnemonics\n> +(define_int_iterator AESGF_code [UNSPEC_XXGFMUL128GCM\n> +\t\t\t\t UNSPEC_XXGFMUL128XTS])\n> +(define_int_attr AESGF_insn [(UNSPEC_XXGFMUL128GCM  \"xxgfmul128gcm\")\n> +\t\t\t     (UNSPEC_XXGFMUL128XTS  \"xxgfmul128xts\")])\n> +\n>  ;; 2 operand crypto instructions\n>  (define_insn \"crypto_<CR_insn>_<mode>\"\n>    [(set (match_operand:CR_vqdi 0 \"register_operand\" \"=v\")\n> @@ -111,3 +160,54 @@ (define_insn \"crypto_vshasigma<CR_char>\"\n>    \"TARGET_CRYPTO\"\n>    \"vshasigma<CR_char> %0,%1,%2,%3\"\n>    [(set_attr \"type\" \"vecsimple\")])\n> +\n> +;; AES acceleration instructions\n> +\n> +(define_insn \"<AESACC_base_insn>\"\n> +  [(set (match_operand:OO 0 \"vsx_register_operand\" \"=wa\")\n> +\t(unspec:OO [(match_operand:OO 1 \"vsx_register_operand\" \"wa\")\n> +\t\t    (match_operand:OO 2 \"vsx_register_operand\" \"wa\")\n> +\t\t    (match_operand:SI 3 \"const_0_to_3_operand\" \"n\")]\n> +\t\t   AESACC_base_code))]\n> +  \"TARGET_FUTURE\"\n> +  \"<AESACC_base_insn> %x0,%x1,%x2,%3\")\n> +\n> +(define_insn \"<AESACC_insn>\"\n> +  [(set (match_operand:OO 0 \"vsx_register_operand\" \"=wa\")\n> +    (unspec:OO [(match_operand:OO 1 \"vsx_register_operand\" \"wa\")\n> +\t\t(match_operand:OO 2 \"vsx_register_operand\" \"wa\")]\n> +\t       AESACC_code))]\n> +  \"TARGET_FUTURE\"\n> +  \"<AESACC_insn> %x0,%x1,%x2\")\n> +\n> +(define_insn \"xxaesgenlkp\"\n> +  [(set (match_operand:OO 0 \"vsx_register_operand\" \"=wa\")\n> +    (unspec:OO [(match_operand:OO 1 \"vsx_register_operand\" \"wa\")\n> +\t\t(match_operand:SI 2 \"const_0_to_3_operand\" \"n\")]\n> +\t       UNSPEC_XXAESGENLKP))]\n> +  \"TARGET_FUTURE\"\n> +  \"xxaesgenlkp %x0,%x1,%2\")\n> +\n> +(define_insn \"<AESGENLKP_insn>\"\n> +  [(set (match_operand:OO 0 \"vsx_register_operand\" \"=wa\")\n> +    (unspec:OO [(match_operand:OO 1 \"vsx_register_operand\" \"wa\")]\n> +\t       AESGENLKP_code))]\n> +  \"TARGET_FUTURE\"\n> +  \"<AESGENLKP_insn> %x0,%x1\")\n> +\n> +(define_insn \"xxgfmul128\"\n> +  [(set (match_operand:V16QI 0 \"vsx_register_operand\" \"=wa\")\n> +    (unspec:V16QI [(match_operand:V16QI 1 \"vsx_register_operand\" \"wa\")\n> +\t\t   (match_operand:V16QI 2 \"vsx_register_operand\" \"wa\")\n> +\t\t   (match_operand:SI 3 \"const_0_to_1_operand\" \"n\")]\n> +\t\t  UNSPEC_XXGFMUL128))]\n> +  \"TARGET_FUTURE\"\n> +  \"xxgfmul128 %x0,%x1,%x2,%3\")\n> +\n> +(define_insn \"<AESGF_insn>\"\n> +  [(set (match_operand:V16QI 0 \"vsx_register_operand\" \"=wa\")\n> +    (unspec:V16QI [(match_operand:V16QI 1 \"vsx_register_operand\" \"wa\")\n> +\t\t   (match_operand:V16QI 2 \"vsx_register_operand\" \"wa\")]\n> +\t\t  AESGF_code))]\n> +  \"TARGET_FUTURE\"\n> +  \"<AESGF_insn> %x0,%x1,%x2\")\n> diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def\n> index 7e5a4fb96e7..0d1529b71d4 100644\n> --- a/gcc/config/rs6000/rs6000-builtins.def\n> +++ b/gcc/config/rs6000/rs6000-builtins.def\n> @@ -3924,3 +3924,49 @@\n>  \n>    void __builtin_vsx_stxvp (v256, unsigned long, const v256 *);\n>      STXVP nothing {mma,pair}\n> +\n> +[future]\n> +  const v256 __builtin_aes_encrypt_paired (v256, v256, const int<2>);\n> +    XXAESENCP xxaesencp {}\n> +\n> +  const v256 __builtin_aes128_encrypt_paired (v256, v256);\n> +    XXAES128ENCP xxaes128encp {}\n> +\n> +  const v256 __builtin_aes192_encrypt_paired (v256, v256);\n> +    XXAES192ENCP xxaes192encp {}\n> +\n> +  const v256 __builtin_aes256_encrypt_paired (v256, v256);\n> +    XXAES256ENCP xxaes256encp {}\n> +\n> +  const v256 __builtin_aes_decrypt_paired (v256, v256, const int<2>);\n> +    XXAESDECP xxaesdecp {}\n> +\n> +  const v256 __builtin_aes128_decrypt_paired (v256, v256);\n> +    XXAES128DECP xxaes128decp {}\n> +\n> +  const v256 __builtin_aes192_decrypt_paired (v256, v256);\n> +    XXAES192DECP xxaes192decp {}\n> +\n> +  const v256 __builtin_aes256_decrypt_paired (v256, v256);\n> +    XXAES256DECP xxaes256decp {}\n> +\n> +  const v256 __builtin_aes_genlastkey_paired (v256, const int<2>);\n> +    XXAESGENLKP xxaesgenlkp {}\n> +\n> +  const v256 __builtin_aes128_genlastkey_paired (v256);\n> +    XXAES128GENLKP xxaes128genlkp {}\n> +\n> +  const v256 __builtin_aes192_genlastkey_paired (v256);\n> +    XXAES192GENLKP xxaes192genlkp {}\n> +\n> +  const v256 __builtin_aes256_genlastkey_paired (v256);\n> +    XXAES256GENLKP xxaes256genlkp {}\n> +\n> +  const vuc __builtin_galois_field_mult (vuc, vuc, const int<1>);\n> +    XXGFMUL128 xxgfmul128 {}\n> +\n> +  const vuc __builtin_galois_field_mult_gcm (vuc, vuc);\n> +    XXGFMUL128GCM xxgfmul128gcm {}\n> +\n> +  const vuc __builtin_galois_field_mult_xts (vuc, vuc);\n> +    XXGFMUL128XTS xxgfmul128xts {}\n> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi\n> index 0faa5323ce1..a77f8c4cede 100644\n> --- a/gcc/doc/extend.texi\n> +++ b/gcc/doc/extend.texi\n> @@ -24696,6 +24696,7 @@ The PVIPR documents the following overloaded functions:\n>  * PowerPC AltiVec Built-in Functions Available on ISA 2.07::\n>  * PowerPC AltiVec Built-in Functions Available on ISA 3.0::\n>  * PowerPC AltiVec Built-in Functions Available on ISA 3.1::\n> +* PowerPC AltiVec/VSX Built-in Functions Available on Future ISA::\n>  @end menu\n>  \n>  @node PowerPC AltiVec Built-in Functions on ISA 2.05\n> @@ -26729,6 +26730,58 @@ vector unsigned char);\n>  vector unsigned char);\n>  @end smallexample\n>  \n> +@node PowerPC AltiVec/VSX Built-in Functions Available on Future ISA\n> +@subsubsection PowerPC AltiVec/VSX Built-in Functions Available on Future ISA\n> +\n> +The following additional built-in functions are available for the\n> +PowerPC family of processors, starting with Future ISA.\n> +\n> +Future ISA of the PowerPC may add new instructions for accelerating AES\n> +algorithm. GCC provides support for these new instructions through the\n> +following built-in functions:\n> +\n> +@smallexample\n> +__vector_pair  __builtin_aes_encrypt_paired (__vector_pair, __vector_pair,\n> +                                             int);\n> +\n> +__vector_pair  __builtin_aes128_encrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes192_encrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes256_encrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes_decrypt_paired (__vector_pair, __vector_pair,\n> +                                             int);\n> +\n> +__vector_pair  __builtin_aes128_decrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes192_decrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes256_decrypt_paired (__vector_pair, __vector_pair);\n> +\n> +__vector_pair  __builtin_aes_genlastkey_paired (__vector_pair, int);\n> +\n> +__vector_pair  __builtin_aes128_genlastkey_paired (__vector_pair);\n> +\n> +__vector_pair  __builtin_aes192_genlastkey_paired (__vector_pair);\n> +\n> +__vector_pair  __builtin_aes256_genlastkey_paired (__vector_pair);\n> +\n> +vec_t __builtin_galois_field_mult (vec_t, vec_t, int);\n> +\n> +vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);\n> +\n> +vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);\n> +@end smallexample\n> +\n> +The third argument to @var{__builtin_aes_encrypt_paired} and\n> +@var{__builtin_aes_decrypt_paired} must be a constant integer that is 0, 1 or\n> +2. The values correspond to 128, 192 and 256 bit AES encryption/decryption\n> +respectively.\n> +The third argument to @var{__builtin_galois_field_mult} must be a constant\n> +integer that is 0 or 1. The values correspond to gcm and xts variant\n> +respectively.\n\nLet us keep the above 2 paragraphs before the list of builtins. This is because following the list of aes builtins, we will have another section for other builtins such as for ECC.\nSo before the list of builtins, we can write as:\n\nFuture ISA of the PowerPC may add new instructions for accelerating AES\nalgorithm. GCC provides support for these new instructions through the\nfollowing 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.\nThe third argument to @var{__builtin_galois_field_mult} must be a constant\ninteger that is 0 or 1. The values correspond to gcm and xts variant respectively.\n\n\nWith this change, the patch looks fine to me. I cannot approve for upstreaming however.\n\n-Surya\n\n> +\n>  @node PowerPC Hardware Transactional Memory Built-in Functions\n>  @subsection PowerPC Hardware Transactional Memory Built-in Functions\n>  GCC provides two interfaces for accessing the Hardware Transactional\n> diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c\n> new file mode 100644\n> index 00000000000..2777fcdc7ae\n> --- /dev/null\n> +++ b/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c\n> @@ -0,0 +1,155 @@\n> +/* { dg-do compile } */\n> +/* { dg-options \"-mdejagnu-cpu=future -O2\" } */\n> +\n> +void\n> +aes_enc_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 0);\n> +  *res = c;\n> +}\n> +void\n> +aes_enc_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 1);\n> +  *res = c;\n> +}\n> +void\n> +aes_enc_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_encrypt_paired (t, k, 2);\n> +  *res = c;\n> +}\n> +void\n> +aes_enc_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes128_encrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_enc_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes192_encrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_enc_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes256_encrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 0);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 1);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_decrypt_paired (t, k, 2);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes128_decrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes192_decrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes256_decrypt_paired (t, k);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_0 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_genlastkey_paired (k, 0);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_1 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_genlastkey_paired (k, 1);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_2 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes_genlastkey_paired (k, 2);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_128 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes128_genlastkey_paired (k);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_192 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes192_genlastkey_paired (k);\n> +  *res = c;\n> +}\n> +void\n> +aes_genlastkey_paired_256 (__vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair k = *key;\n> +  __vector_pair c = __builtin_aes256_genlastkey_paired (k);\n> +  *res = c;\n> +}\n> +\n> +\n> +/* { dg-final { scan-assembler-times {\\mxxaesencp\\M} 3 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes128encp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes192encp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes256encp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaesdecp\\M} 3 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes128decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes192decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes256decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaesgenlkp\\M} 3 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes128genlkp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes192genlkp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes256genlkp\\M} 1 } } */\n> diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c\n> new file mode 100644\n> index 00000000000..98f16ad0fe8\n> --- /dev/null\n> +++ b/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c\n> @@ -0,0 +1,34 @@\n> +/* { dg-do compile } */\n> +/* { dg-options \"-mdejagnu-cpu=future -O2\" } */\n> +\n> +typedef unsigned char vec_t __attribute__((vector_size(16)));\n> +\n> +void\n> +gfmul (vec_t *a, vec_t *b, vec_t *res)\n> +{\n> +  vec_t A = *a;\n> +  vec_t B = *b;\n> +  vec_t R = __builtin_galois_field_mult (A, B, 0);\n> +  R = __builtin_galois_field_mult (R, B, 1);\n> +  *res = R;\n> +}\n> +void\n> +gfmul_gcm (vec_t *a, vec_t *b, vec_t *res)\n> +{\n> +  vec_t A = *a;\n> +  vec_t B = *b;\n> +  vec_t R = __builtin_galois_field_mult_gcm (A, B);\n> +  *res = R;\n> +}\n> +void\n> +gfmul_xts (vec_t *a, vec_t *b, vec_t *res)\n> +{\n> +  vec_t A = *a;\n> +  vec_t B = *b;\n> +  vec_t R = __builtin_galois_field_mult_xts (A, B);\n> +  *res = R;\n> +}\n> +\n> +/* { dg-final { scan-assembler-times {\\mxxgfmul128\\M} 2 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxgfmul128gcm\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxgfmul128xts\\M} 1 } } */\n> diff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c\n> new file mode 100644\n> index 00000000000..007bf878afb\n> --- /dev/null\n> +++ b/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c\n> @@ -0,0 +1,52 @@\n> +/* { dg-do compile } */\n> +/* { dg-options \"-mdejagnu-cpu=future -O2\" } */\n> +\n> +void\n> +aes_dec_pair (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair lk = __builtin_aes_genlastkey_paired (k, 0);\n> +  __vector_pair c = __builtin_aes_decrypt_paired (t, lk, 0);\n> +  lk = __builtin_aes_genlastkey_paired (k, 1);\n> +  c = __builtin_aes_decrypt_paired (c, lk, 1);\n> +  lk = __builtin_aes_genlastkey_paired (k, 2);\n> +  c = __builtin_aes_decrypt_paired (c, lk, 2);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair lk = __builtin_aes128_genlastkey_paired (k);\n> +  __vector_pair c = __builtin_aes128_decrypt_paired (t, lk);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair lk = __builtin_aes192_genlastkey_paired (k);\n> +  __vector_pair c = __builtin_aes192_decrypt_paired (t, lk);\n> +  *res = c;\n> +}\n> +void\n> +aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)\n> +{\n> +  __vector_pair t = *text;\n> +  __vector_pair k = *key;\n> +  __vector_pair lk = __builtin_aes256_genlastkey_paired (k);\n> +  __vector_pair c = __builtin_aes256_decrypt_paired (t, lk);\n> +  *res = c;\n> +}\n> +\n> +/* { dg-final { scan-assembler-times {\\mxxaesdecp\\M} 3 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes128decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes192decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes256decp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaesgenlkp\\M} 3 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes128genlkp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes192genlkp\\M} 1 } } */\n> +/* { dg-final { scan-assembler-times {\\mxxaes256genlkp\\M} 1 } } */\n> \\ No newline at end of file","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=aONcXXyb;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=aONcXXyb","sourceware.org;\n dmarc=none (p=none dis=none) header.from=linux.ibm.com","sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com","server2.sourceware.org;\n arc=none smtp.remote-ip=148.163.156.1"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5tYn2qt6z1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 22:20:58 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 15FC043B5526\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 12:20:56 +0000 (GMT)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n by sourceware.org (Postfix) with ESMTPS id E9D6F43B5539;\n Thu, 30 Apr 2026 12:20:23 +0000 (GMT)","from pps.filterd (m0356517.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63U240Mb2939523; Thu, 30 Apr 2026 12:20:22 GMT","from ppma13.dal12v.mail.ibm.com\n (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drnb5fm5g-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 30 Apr 2026 12:20:22 +0000 (GMT)","from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1])\n by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 63UC8tRY003024;\n Thu, 30 Apr 2026 12:20:21 GMT","from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4])\n by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dsa5gjs7a-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 30 Apr 2026 12:20:21 +0000 (GMT)","from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com\n [10.39.53.228])\n by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 63UCKJYE27918966\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Thu, 30 Apr 2026 12:20:20 GMT","from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id AC2DA58063;\n Thu, 30 Apr 2026 12:20:19 +0000 (GMT)","from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 9FAAF58055;\n Thu, 30 Apr 2026 12:20:14 +0000 (GMT)","from [9.124.222.168] (unknown [9.124.222.168])\n by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n Thu, 30 Apr 2026 12:20:14 +0000 (GMT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 15FC043B5526","OpenDKIM Filter v2.11.0 sourceware.org E9D6F43B5539"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org E9D6F43B5539","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org E9D6F43B5539","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777551624; cv=none;\n b=YIVEaA8cEy+XwYgabNZR1nG6G7RJrjyK0GHBPa6ehdIe/0Zl0SBjq1ZE0awWE9q6CPtS0AG0MyNv+nbkNmEYnp1iYlnnvH+mjqUW0sqZj+dn3/RA4MgO9GVjxWtL+4Qcg1zBSqbAchfhm6dpa1EAveEqQuXuo84RF/cboVc6jLk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777551624; c=relaxed/simple;\n bh=X3gICYzbCpKNHe6X70eZn2spzX5dOWs5VAFQpFITmlw=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=qlRQGPW6yNDwIO8dzc3h230YUfK2W/oBzSl/FGv4DwQvGytXmWH+ZBTlvr8MAGJltnKB3DhLEuKZ5nTKIbT0X0ZI5Jp7LoDQjr2FEQ6vwc5FM93uzw+kfM88nlrcVr1K4+Vv92YgeS5EjNPjfXh2DtEtK5+fQZbvQRXFW0mb2rg=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:content-type:date:from:in-reply-to\n :message-id:mime-version:references:subject:to; s=pp1; bh=Zr6uu1\n 9Azfv8nxqOgyZRON+8DWxsEVVsgkKIqpahlo4=; b=aONcXXybA9IdfbQ1ta2rK/\n p9dmXXXTSq3uMj4kHFoaKEsfY8AebhVGHph4C4yTBiyslKZu7k5mf1uhb3kBmtei\n dDrhIPdX1jDLz+EHGurjaNCLEUejwDe6mIhiNwf2HxTFglU4h1keEolO1QSiuAHQ\n BOARJVjFnb4TcFYMQfGpb4KKd/oSqRJVL5/y2oId8JWS2r+qi7fLBzgKRX5SBXyX\n uwVoUUrQ77ot6MfmW7KUg5YA644XRfY9PtDRISqj48AfXe7QmmrnRwIhZPgQ4oAR\n W9nRCc9Cpx5iGeDlstc7cSk14Bo1oYCsT7+1E9Y3QNSaJi1j7PdkoNTDtEOWQpjg\n ==","Message-ID":"<59acedf8-8ade-4574-9329-1f19d2fb90d4@linux.ibm.com>","Date":"Thu, 30 Apr 2026 17:50:12 +0530","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4] rs6000: Builtins for AES acceleration instructions\n [RFC02657]","To":"Avinash Jayakar <avinashd@linux.ibm.com>, gcc-patches@gcc.gnu.org","Cc":"segher@kernel.crashing.org, meissner@linux.ibm.com, dje.gcc@gmail.com,\n linkw@gcc.gnu.org, jeevitha@linux.ibm.com, kishan@linux.ibm.com,\n mmatti@linux.ibm.com, vijay@linux.ibm.com","References":"<20260430094500.696262-1-avinashd@linux.ibm.com>","From":"Surya Kumari Jangala <jskumari@linux.ibm.com>","Content-Language":"en-US","In-Reply-To":"<20260430094500.696262-1-avinashd@linux.ibm.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-TM-AS-GCONF":"00","X-Proofpoint-Reinject":"loops=2 maxloops=12","X-Authority-Analysis":"v=2.4 cv=AqDeGu9P c=1 sm=1 tr=0 ts=69f34906 cx=c_pps\n a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17\n a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=mDV3o1hIAAAA:8\n a=VnNF1IyMAAAA:8 a=A9N1LdzQasVdY6276QEA:9 a=QEXdDO2ut3YA:10","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDMwMDEyNSBTYWx0ZWRfXzBfxhWWZUpCh\n lEKTUFxabnI61Owbja5+ZxnvAsgJYBZF4r+HNfi1qi3k+2nphotSKxJfTIWAP2+HQhFCZSEr5Bx\n 90e8+zTw/0tGv8ybj/ZN4szkB0EA0JPldC4kejzbMpWdTkxUPK/iwTcWqHOqT5xanT5npBK5wiu\n Hfnhgk4bibTgSx11StKsq6uNy2AXcdXQ3pwqQB9apZ3sQ+nuOw5uD90Y8MtJCi1FiajcpY3GzyZ\n gSVOkp2fK8eH8+RXOk71e7zw6t64KMcrc9XIW8vGwTFBGQWzr9lM3V0OyA8t2H6Z/8toGGJeSHo\n RMJrS3r6q9pt+PlFhp8EVoQyaW4hdvEAxVgr7fzco2dbQfA6WFQ8b+8HYAzsF22gOCOGp+Pcsmf\n rg7JjTrQIYgV5+Nj8onSL9rQoA6wtFSFG6BFN909F5opHwBT2kQqkwfNNk9K4UpO7N21xao62Xg\n MrAqs4GggiE0oin+jpQ==","X-Proofpoint-GUID":"zWSDcMORZlssXVXp77n-RGPmeJHvpZQv","X-Proofpoint-ORIG-GUID":"HFWUS62aG8cpx9req0L-Ze3Sr05N13nY","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-30_04,2026-04-30_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n adultscore=0 priorityscore=1501 phishscore=0 suspectscore=0 clxscore=1015\n lowpriorityscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604300125","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}}]