[AArch64][PATCH 2/2] Combine AES instructions with xor and zero operands
authorAndre Vieira <andre.simoesdiasvieira@arm.com>
Thu, 21 Jun 2018 09:08:43 +0000 (09:08 +0000)
committerAndre Vieira <avieira@gcc.gnu.org>
Thu, 21 Jun 2018 09:08:43 +0000 (09:08 +0000)
gcc
2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* config/aarch64/aarch64-simd.md
(*aarch64_crypto_aes<aes_op>v16qi_xor_combine): New.

gcc/testsuite
2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* gcc/gcc.target/aarch64/aes_xor_combine.c: New test.

From-SVN: r261836

gcc/ChangeLog
gcc/config/aarch64/aarch64-simd.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/aes_xor_combine.c [new file with mode: 0644]

index 1731f5a05d2adef4d93497f2651d3c213c45b81a..1e851db45c6a4a65e38604580c981a2a581fcadf 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+
+       * config/aarch64/aarch64-simd.md
+       (*aarch64_crypto_aes<aes_op>v16qi_xor_combine): New.
+
 2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * config/aarch64/aarch64-simd.md (aarch64_crypto_aes<aes_op>v16qi):
index 7e9ae086b10c9bdd339b521c9444dc04b0d5b137..315c8dc4b85a849b2ec8d0bc0befbacda8fc0da3 100644 (file)
   [(set_attr "type" "crypto_aese")]
 )
 
+(define_insn "*aarch64_crypto_aes<aes_op>v16qi_xor_combine"
+  [(set (match_operand:V16QI 0 "register_operand" "=w")
+       (unspec:V16QI [(xor:V16QI
+                       (match_operand:V16QI 1 "register_operand" "%0")
+                       (match_operand:V16QI 2 "register_operand" "w"))
+                      (match_operand:V16QI 3 "aarch64_simd_imm_zero" "")]
+                      CRYPTO_AES))]
+  "TARGET_SIMD && TARGET_AES"
+  "aes<aes_op>\\t%0.16b, %2.16b"
+  [(set_attr "type" "crypto_aese")]
+)
+
+(define_insn "*aarch64_crypto_aes<aes_op>v16qi_xor_combine"
+  [(set (match_operand:V16QI 0 "register_operand" "=w")
+       (unspec:V16QI [(match_operand:V16QI 3 "aarch64_simd_imm_zero" "")
+       (xor:V16QI (match_operand:V16QI 1 "register_operand" "%0")
+                  (match_operand:V16QI 2 "register_operand" "w"))]
+       CRYPTO_AES))]
+  "TARGET_SIMD && TARGET_AES"
+  "aes<aes_op>\\t%0.16b, %2.16b"
+  [(set_attr "type" "crypto_aese")]
+)
+
 ;; When AES/AESMC fusion is enabled we want the register allocation to
 ;; look like:
 ;;    AESE Vn, _
index e58afe59ab32e68228c03cbb5603a15a04c16602..e32abfaeb0eeba7cf61b9cd94bdf827721f85046 100644 (file)
@@ -1,3 +1,7 @@
+2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+
+       * gcc/gcc.target/aarch64/aes_xor_combine.c: New test.
+
 2018-06-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * gcc/gcc.target/aarch64/aes_2.c: New test.
diff --git a/gcc/testsuite/gcc.target/aarch64/aes_xor_combine.c b/gcc/testsuite/gcc.target/aarch64/aes_xor_combine.c
new file mode 100644 (file)
index 0000000..833e9b3
--- /dev/null
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mcpu=cortex-a55+crypto" } */
+#include <arm_neon.h>
+
+#define AESE(r, v, key) (r = vaeseq_u8 ((v), (key)));
+#define AESD(r, v, key) (r = vaesdq_u8 ((v), (key)));
+
+const uint8x16_t zero = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+uint8x16_t foo0 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESE(dummy, a ^ b, zero);
+  return dummy;
+}
+
+uint8x16_t foo1 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESE(dummy, a ^ b, zero);
+  AESE(dummy, dummy ^ a, zero);
+  return dummy;
+}
+
+uint8x16_t bar0 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESE(dummy, zero, a ^ b);
+  return dummy;
+}
+
+uint8x16_t bar1 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESE(dummy, zero, a ^ b);
+  AESE(dummy, zero, b ^ dummy);
+  return dummy;
+}
+
+uint8x16_t foo2 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESD(dummy, a ^ b, zero);
+  return dummy;
+}
+
+uint8x16_t foo3 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESD(dummy, a ^ b, zero);
+  AESD(dummy, dummy ^ a, zero);
+  return dummy;
+}
+
+uint8x16_t bar2 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESD(dummy, zero, a ^ b);
+  return dummy;
+}
+
+uint8x16_t bar3 (uint8x16_t a, uint8x16_t b)
+{
+  uint8x16_t dummy;
+  AESD(dummy, zero, a ^ b);
+  AESD(dummy, zero, b ^ dummy);
+  return dummy;
+}
+/* { dg-final { scan-assembler-not "eor" } } */
+/* { dg-final { scan-assembler-not "mov" } } */