{"id":2231042,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2231042/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260430094500.696262-1-avinashd@linux.ibm.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260430094500.696262-1-avinashd@linux.ibm.com>","date":"2026-04-30T09:45:00","name":"[v4] rs6000: Builtins for AES acceleration instructions [RFC02657]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cdcb4e2ac45225c62f02a33f52b43be234c04e94","submitter":{"id":91453,"url":"http://patchwork.ozlabs.org/api/1.1/people/91453/?format=json","name":"Avinash Jayakar","email":"avinashd@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260430094500.696262-1-avinashd@linux.ibm.com/mbox/","series":[{"id":502258,"url":"http://patchwork.ozlabs.org/api/1.1/series/502258/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=502258","date":"2026-04-30T09:45:00","name":"[v4] rs6000: Builtins for AES acceleration instructions [RFC02657]","version":4,"mbox":"http://patchwork.ozlabs.org/series/502258/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231042/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231042/checks/","tags":{},"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=amAivByZ;\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=amAivByZ","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 4g5q6g4SkLz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 19:45:46 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 6816A436A06C\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 09:45:43 +0000 (GMT)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n by sourceware.org (Postfix) with ESMTPS id 06D734BAE7D0;\n Thu, 30 Apr 2026 09:45:11 +0000 (GMT)","from pps.filterd (m0360083.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63TKKsDR2992108; Thu, 30 Apr 2026 09:45:10 GMT","from ppma12.dal12v.mail.ibm.com\n (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn44y4k1-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 30 Apr 2026 09:45:10 +0000 (GMT)","from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1])\n by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 63U9NkCa027416;\n Thu, 30 Apr 2026 09:45:09 GMT","from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224])\n by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ds7xqjg1p-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 30 Apr 2026 09:45:09 +0000 (GMT)","from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com\n [10.20.54.102])\n by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 63U9j5q027787736\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Thu, 30 Apr 2026 09:45:05 GMT","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 642D92004D;\n Thu, 30 Apr 2026 09:45:05 +0000 (GMT)","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 1C36620040;\n Thu, 30 Apr 2026 09:45:03 +0000 (GMT)","from li-4c4c4544-0036-3810-8050-b5c04f423534.ibm.com (unknown\n [9.109.217.178])\n by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP;\n Thu, 30 Apr 2026 09:45:02 +0000 (GMT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 6816A436A06C","OpenDKIM Filter v2.11.0 sourceware.org 06D734BAE7D0"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 06D734BAE7D0","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 06D734BAE7D0","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777542312; cv=none;\n b=PAqBHM43yw2sM6uJjftQHWk3cgQapoKS/9ayuzUUU2f+BgYgDcVJ1xreHj63tXX58nKAfJffIKhVcLvIRZ1J5CxPi8LKpV5kW9380E9srAJgTsoLhprYwWJQj316HLOb6iRsPkJmF8f9qD6kR0oZ4VDYBJs7/SfWZksyQrX1vHI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777542312; c=relaxed/simple;\n bh=9Ez/p45ante4CIRpWGMOBs20Qx/S+pbUxyV7uw/hIyw=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=cbUx5W0EB1CXBai2AJbm0GAYAaccXeuFdoXgDZGSMygIfzn7+4mqqG9Nklne/KdJ8Rcj2hVUURlBCfhacQjr890enfX8MpRlESLQ/vaqYllYVYYDG0cy3+y8GJ6dQa4Xc6Exh8tmgHkcfx5VZV4pYqd1h5t8S0Cc7h+P1Ryh/m4=","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:date:from:message-id:mime-version\n :subject:to; s=pp1; bh=vL5VgiW79jAzxMQPFksXHBM1lQtw4eRFb0rxPToWz\n 5Q=; b=amAivByZmH5BFF3EuvzinFQNtsOxwybKb6jPXIpM7hGJaCS7NNlu62P3T\n rS0BHE4fo9ycVabeTATFyYkQJwpSmy3yczs0YVG35ZxSUOoUAU9++JU4vgNpz0U1\n WcS7F2CNVCNjntUT4KbQzHneuA3p022rj0NUcNrZseK0dbsoKEIkNsODFJFqJIKH\n SYzzw9Gx0Gd3uprZAzBtQxq+bq1E7vOSXkb0bQv3fsCFTRihSlJ0+rnJYo/Qq7e6\n 2W+bWYs5xSrqOaA7p1XwNMkSdytkbn+T0cPTjY86K8ru7xJeG321dHjoY2EnnhQc\n xqYit83RGzJn/MNWpGmvGrg/57i6Q==","From":"Avinash Jayakar <avinashd@linux.ibm.com>","To":"gcc-patches@gcc.gnu.org","Cc":"segher@kernel.crashing.org, jskumari@linux.ibm.com,\n meissner@linux.ibm.com,\n dje.gcc@gmail.com, linkw@gcc.gnu.org, jeevitha@linux.ibm.com,\n kishan@linux.ibm.com, mmatti@linux.ibm.com, vijay@linux.ibm.com,\n Avinash Jayakar <avinashd@linux.ibm.com>","Subject":"[PATCH v4] rs6000: Builtins for AES acceleration instructions\n [RFC02657]","Date":"Thu, 30 Apr 2026 15:15:00 +0530","Message-ID":"<20260430094500.696262-1-avinashd@linux.ibm.com>","X-Mailer":"git-send-email 2.51.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","X-Proofpoint-Reinject":"loops=2 maxloops=12","X-Proofpoint-ORIG-GUID":"TVzeaNzkj6dLTlBfKqLUzkF2yLGMr0Bb","X-Authority-Analysis":"v=2.4 cv=Ft81OWrq c=1 sm=1 tr=0 ts=69f324a6 cx=c_pps\n a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=iQ6ETzBq9ecOQQE5vZCe:22 a=mDV3o1hIAAAA:8 a=VnNF1IyMAAAA:8\n a=TaJYR2ad02vticZoeLEA:9","X-Proofpoint-GUID":"dFZc85Dr2No4mHhpa0ndk9DgHutYTj5m","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDMwMDA5MiBTYWx0ZWRfX32n/S7/W8hn6\n D13AXMCJhjKkmW/+pN7gJlz+7ZhFPcdCjUX0mTe4AzNVvBLSyJ9Yerhl2xS61k17kJfngJrUgyN\n 84taOrrE0X1tS7My4aIoCcq6vsSnQSQ0MvLuAF0GjC5xZgWHkZWq7ycu1ALJDt2B5nQtkX2VkbX\n 2raD6cCFqm7L2ZOHD/bTwDz6/tFddhye+NUeZMBiJfdFwjpRd3xYArApSzL9khZb2sbY6s97ECH\n 4RsjSjlz9GZhOEz4BFDPtwYEXwKyYawYCZcPtM7iHpZhyo+pbPnDlvavHuBNpCo3fxxg5YL/s6+\n 7hy4UPeR9xolbNk+lpYdKIuMLJIpdbqbjo8R21cJPrg7Q0xx2sXnPucvs0dYEk7/soo90FXbiSJ\n q+GXqXkg8jVpi2bi+ECw5o+NNB0hjMZS7M9OAD7t0gpR/AF9+HIbji+m6upQcjjiyGhq5IeRaT2\n 1+iyaVZJjxTHgj5CNvA==","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_02,2026-04-28_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0\n clxscore=1015 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604300092","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"},"content":"Hi,\n\nThanks for the review of the documentation. I have incorporated the changes\nrequested.\n\nChanges from v3:\n* Addressed review comments regarding ISA version.\n* Updated AES builtin description in extend.text.\n\nChanges from v2:\n* Added extend.texi documentation for the new builtins.\n\nChanges 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\nFollowing patch depends on these 2 patches in the following order:\n1. mcpu=future: https://gcc.gnu.org/pipermail/gcc-patches/2025-December/703739.html\n2. future builtin infra: https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709782.html\n\nBootstrapped and regtested on powerpc64le-linux-gnu with no regressions.\n\nThanks and regards,\nAvinash Jayakar\n\nThis patch adds new builtins for AES acceleration instructions which\nmay or may not be supported in a future processor. Note, the names of\nthe builtins may change in future.\n\nThe 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);\nvec_t __builtin_galois_field_mult (vec_t, vec_t, uint1);\nvec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);\nvec_t __builtin_galois_field_mult_xts (vec_t, vec_t);\n\n2026-04-30  Avinash Jayakar  <avinashd@linux.ibm.com>\n\ngcc/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\ngcc/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","diff":"diff --git a/gcc/config/rs6000/crypto.md b/gcc/config/rs6000/crypto.md\nindex 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\")\ndiff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def\nindex 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 {}\ndiff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi\nindex 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+\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\ndiff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-1.c\nnew file mode 100644\nindex 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 } } */\ndiff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-2.c\nnew file mode 100644\nindex 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 } } */\ndiff --git a/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c b/gcc/testsuite/gcc.target/powerpc/aes-builtin-3.c\nnew file mode 100644\nindex 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\n","prefixes":["v4"]}