+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):
[(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"
--- /dev/null
+/* { 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;
+}
+