[AArch64 3/3] Fix XOR_one_cmpl pattern; add SIMD-reg variants for BIC,ORN,EON
authorAlan Lawrence <alan.lawrence@arm.com>
Fri, 19 Dec 2014 17:59:23 +0000 (17:59 +0000)
committerAlan Lawrence <alalaw01@gcc.gnu.org>
Fri, 19 Dec 2014 17:59:23 +0000 (17:59 +0000)
gcc/:

* config/aarch64/aarch64.c (<LOGICAL:optab>_one_cmpl<mode>3):
Reparameterize to...
(<NLOGICAL:optab>_one_cmpl<mode>3): with extra SIMD-register variant.
(xor_one_cmpl<mode>3): New define_insn_and_split.

* config/aarch64/iterators.md (NLOGICAL): New define_code_iterator.

gcc/testsuite/:

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

From-SVN: r218961

gcc/ChangeLog
gcc/config/aarch64/aarch64.md
gcc/config/aarch64/iterators.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/eon_1.c [new file with mode: 0644]

index 10b5538cd60156e801b6a28f9c37071fa1ee834b..e5733ae9c8813c8f16eaac5429177ca926ba77e4 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-19  Alan Lawrence  <alan.lawrence@arm.com>
+
+       * config/aarch64/aarch64.c (<LOGICAL:optab>_one_cmpl<mode>3):
+       Reparameterize to...
+       (<NLOGICAL:optab>_one_cmpl<mode>3): with extra SIMD-register variant.
+       (xor_one_cmpl<mode>3): New define_insn_and_split.
+
+       * config/aarch64/iterators.md (NLOGICAL): New define_code_iterator.
+
 2014-12-19  Alan Lawrence  <alan.lawrence@arm.com>
 
        * config/aarch64/aarch64.md (<optab><mode>3, one_cmpl<mode>2):
index bc9138d6cf9331f94ad03281545517d5741ea8d6..7b05359ef6c8de50f97e2b28a9ca3ead8b723d83 100644 (file)
   [(set_attr "type" "logic_shift_imm")]
 )
 
-(define_insn "*<LOGICAL:optab>_one_cmpl<mode>3"
-  [(set (match_operand:GPI 0 "register_operand" "=r")
-       (LOGICAL:GPI (not:GPI
-                     (match_operand:GPI 1 "register_operand" "r"))
-                    (match_operand:GPI 2 "register_operand" "r")))]
+;; Binary logical operators negating one operand, i.e. (a & !b), (a | !b).
+
+(define_insn "*<NLOGICAL:optab>_one_cmpl<mode>3"
+  [(set (match_operand:GPI 0 "register_operand" "=r,w")
+       (NLOGICAL:GPI (not:GPI (match_operand:GPI 1 "register_operand" "r,w"))
+                    (match_operand:GPI 2 "register_operand" "r,w")))]
+  ""
+  "@
+  <NLOGICAL:nlogical>\\t%<w>0, %<w>2, %<w>1
+  <NLOGICAL:nlogical>\\t%0.<Vbtype>, %2.<Vbtype>, %1.<Vbtype>"
+  [(set_attr "type" "logic_reg,neon_logic")
+   (set_attr "simd" "*,yes")]
+)
+
+;; (xor (not a) b) is simplify_rtx-ed down to (not (xor a b)).
+;; eon does not operate on SIMD registers so the vector variant must be split.
+(define_insn_and_split "*xor_one_cmpl<mode>3"
+  [(set (match_operand:GPI 0 "register_operand" "=r,w")
+        (not:GPI (xor:GPI (match_operand:GPI 1 "register_operand" "r,?w")
+                          (match_operand:GPI 2 "register_operand" "r,w"))))]
+  ""
+  "eon\\t%<w>0, %<w>1, %<w>2" ;; For GPR registers (only).
+  "reload_completed && (which_alternative == 1)" ;; For SIMD registers.
+  [(set (match_operand:GPI 0 "register_operand" "=w")
+        (xor:GPI (match_operand:GPI 1 "register_operand" "w")
+                 (match_operand:GPI 2 "register_operand" "w")))
+   (set (match_dup 0) (not:GPI (match_dup 0)))]
   ""
-  "<LOGICAL:nlogical>\\t%<w>0, %<w>2, %<w>1"
-  [(set_attr "type" "logic_reg")]
+  [(set_attr "type" "logic_reg,multiple")
+   (set_attr "simd" "*,yes")]
 )
 
 (define_insn "*and_one_cmpl<mode>3_compare0"
index 26e3ebcbcabbf224eb05b1b31d8a814e4e992f0d..fe9fa97b998965d2c55081e6256296aa251be059 100644 (file)
 ;; Code iterator for logical operations
 (define_code_iterator LOGICAL [and ior xor])
 
+;; Code iterator for logical operations whose :nlogical works on SIMD registers.
+(define_code_iterator NLOGICAL [and ior])
+
 ;; Code iterator for sign/zero extension
 (define_code_iterator ANY_EXTEND [sign_extend zero_extend])
 
index 39f8ad2358bf453974461eebf59e26550aa48d0d..291de7744a404f51c31837ae740e362403346980 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-19  Alan Lawrence  <alan.lawrence@arm.com>
+
+       * gcc.target/aarch64/eon_1.c: New test.
+
 2014-12-19  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60493
diff --git a/gcc/testsuite/gcc.target/aarch64/eon_1.c b/gcc/testsuite/gcc.target/aarch64/eon_1.c
new file mode 100644 (file)
index 0000000..dcdf3b4
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* { dg-final { scan-assembler-not "\tf?mov\t" } } */
+
+typedef long long int64_t;
+typedef int64_t int64x1_t __attribute__ ((__vector_size__ (8)));
+
+/* { dg-final { scan-assembler-times "\\teon\\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 1 } } */
+
+int64_t
+test_eon (int64_t a, int64_t b)
+{
+  return a ^ ~b;
+}
+
+/* { dg-final { scan-assembler-times "\\tmvn\\tx\[0-9\]+, x\[0-9\]+" 1 } } */
+int64_t
+test_not (int64_t a)
+{
+  return ~a;
+}
+
+/* There is no eon for SIMD regs; we prefer eor+mvn to mov+mov+eon+mov.  */
+
+/* { dg-final { scan-assembler-times "\\teor\\tv\[0-9\]+\.8b, v\[0-9\]+\.8b, v\[0-9\]+\.8b" 1 } } */
+/* { dg-final { scan-assembler-times "\\tmvn\\tv\[0-9\]+\.8b, v\[0-9\]+\.8b" 2 } } */
+int64x1_t
+test_vec_eon (int64x1_t a, int64x1_t b)
+{
+  return a ^ ~b;
+}
+
+int64x1_t
+test_vec_not (int64x1_t a)
+{
+  return ~a;
+}
+