From 79a77fee9f8eebf5bdd2b4868a0ba18b3ad3b74d Mon Sep 17 00:00:00 2001 From: ktkachov Date: Tue, 10 Nov 2015 09:37:51 +0000 Subject: [PATCH] [AArch64][2/3] Implement negcc, notcc optabs * config/aarch64/aarch64.md (cc): New define_expand. * config/aarch64/iterators.md (NEG_NOT): New code iterator. (neg_not_op): New code attribute. * gcc.target/aarch64/cond_op_imm_1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230090 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++ gcc/config/aarch64/aarch64.md | 18 +++++ gcc/config/aarch64/iterators.md | 6 ++ gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.target/aarch64/cond_op_imm_1.c | 99 ++++++++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/cond_op_imm_1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2fe062aeb45..5a7e44cf292 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2015-11-10 Kyrylo Tkachov + * config/aarch64/aarch64.md (cc): New define_expand. + * config/aarch64/iterators.md (NEG_NOT): New code iterator. + (neg_not_op): New code attribute. + +2015-11-10 Kyrylo Tkachov + * ifcvt.c (noce_try_inverse_constants): New function. (noce_process_if_block): Call it. * optabs.h (emit_conditional_neg_or_complement): Declare prototype. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 6b08850e9d0..1586256dd34 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -3102,6 +3102,24 @@ } ) +(define_expand "cc" + [(set (match_operand:GPI 0 "register_operand" "") + (if_then_else:GPI (match_operand 1 "aarch64_comparison_operator" "") + (NEG_NOT:GPI (match_operand:GPI 2 "register_operand" "")) + (match_operand:GPI 3 "register_operand" "")))] + "" + { + rtx ccreg; + enum rtx_code code = GET_CODE (operands[1]); + + if (code == UNEQ || code == LTGT) + FAIL; + + ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0), + XEXP (operands[1], 1)); + operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx); + } +) ;; CRC32 instructions. (define_insn "aarch64_" diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 6f35036b013..c4a1c9888ea 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -693,6 +693,9 @@ ;; Code iterator for logical operations whose :nlogical works on SIMD registers. (define_code_iterator NLOGICAL [and ior]) +;; Code iterator for unary negate and bitwise complement. +(define_code_iterator NEG_NOT [neg not]) + ;; Code iterator for sign/zero extension (define_code_iterator ANY_EXTEND [sign_extend zero_extend]) @@ -822,6 +825,9 @@ ;; Logical operator instruction mnemonics (define_code_attr logical [(and "and") (ior "orr") (xor "eor")]) +;; Operation names for negate and bitwise complement. +(define_code_attr neg_not_op [(neg "neg") (not "not")]) + ;; Similar, but when not(op) (define_code_attr nlogical [(and "bic") (ior "orn") (xor "eon")]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 22761beb2c6..5c258f4404e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-11-10 Kyrylo Tkachov + + * gcc.target/aarch64/cond_op_imm_1.c: New test. + 2015-11-10 Eric Botcazou * gfortran.dg/pr68251.f90: New test. diff --git a/gcc/testsuite/gcc.target/aarch64/cond_op_imm_1.c b/gcc/testsuite/gcc.target/aarch64/cond_op_imm_1.c new file mode 100644 index 00000000000..e93a69329c3 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cond_op_imm_1.c @@ -0,0 +1,99 @@ +/* { dg-do run } */ +/* { dg-options "-save-temps -O2 -fno-inline" } */ + +extern void abort (void); + +#define N 30 +#define M 25089992 + +int +foonegsi (int a) +{ + return a ? N : -N; +} + +/* { dg-final { scan-assembler "csneg\tw\[0-9\]*.*" } } */ + + +int +fooinvsi (int a) +{ + return a ? N : ~N; +} + +/* { dg-final { scan-assembler "csinv\tw\[0-9\]*.*" } } */ + + +long long +foonegdi (long long a) +{ + return a ? N : -N; +} + +long long +largefooneg (long long a) +{ + return a ? M : -M; +} + +/* { dg-final { scan-assembler "csneg\tx\[0-9\]*.*" } } */ + +long long +fooinvdi (long long a) +{ + return a ? N : ~N; +} + +long long +largefooinv (long long a) +{ + return a ? M : ~M; +} + +/* { dg-final { scan-assembler "csinv\tx\[0-9\]*.*" } } */ + + +int +main (void) +{ + if (foonegsi (1) != N) + abort (); + + if (foonegsi (0) != -N) + abort (); + + if (fooinvsi (1) != N) + abort (); + + if (fooinvsi (0) != ~N) + abort (); + + if (foonegdi (1) != N) + abort (); + + if (foonegdi (0) != -N) + abort (); + + if (fooinvdi (1) != N) + abort (); + + if (fooinvdi (0) != ~N) + abort (); + + if (largefooinv (0) != ~M) + abort (); + + if (largefooneg (0) != -M) + abort (); + + if (largefooinv (1) != M) + abort (); + + if (largefooneg (1) != M) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-not "csel\tx\[0-9\]*.*" } } */ +/* { dg-final { scan-assembler-not "csel\tw\[0-9\]*.*" } } */ -- 2.11.4.GIT