From c3eaf15aae68a4cc3e01a6ece4408188b73073ff Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Tue, 24 May 2016 23:19:08 +0000 Subject: [PATCH] altivec.md (VNEG iterator): New iterator for VNEGW/VNEGD instructions. [gcc] 2016-05-24 Michael Meissner * config/rs6000/altivec.md (VNEG iterator): New iterator for VNEGW/VNEGD instructions. (p9_neg2): New insns for ISA 3.0 VNEGW/VNEGD. (neg2): Add expander for V2DImode added in ISA 2.06, and support for ISA 3.0 VNEGW/VNEGD instructions. [gcc/testsuite] 2016-05-24 Michael Meissner * gcc.target/powerpc/p9-vneg.c: New test for ISA 3.0 VNEGW/VNEGD instructions. From-SVN: r236679 --- gcc/ChangeLog | 8 ++++++ gcc/config/rs6000/altivec.md | 33 ++++++++++++++-------- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.target/powerpc/p9-vneg.c | 12 ++++++++ 4 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/p9-vneg.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57e9ba14d4a..8b0a5043c95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-05-24 Michael Meissner + + * config/rs6000/altivec.md (VNEG iterator): New iterator for + VNEGW/VNEGD instructions. + (p9_neg2): New insns for ISA 3.0 VNEGW/VNEGD. + (neg2): Add expander for V2DImode added in ISA 2.06, and + support for ISA 3.0 VNEGW/VNEGD instructions. + 2016-05-24 Cesar Philippidis * gimplify.c (omp_notice_variable): Use zero-length arrays for data diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index 03ae1d94ce0..4397cbcb005 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -214,6 +214,9 @@ (define_mode_attr VP_small_lc [(V2DI "v4si") (V4SI "v8hi") (V8HI "v16qi")]) (define_mode_attr VU_char [(V2DI "w") (V4SI "h") (V8HI "b")]) +;; Vector negate +(define_mode_iterator VNEG [V4SI V2DI]) + ;; Vector move instructions. (define_insn "*altivec_mov" [(set (match_operand:VM2 0 "nonimmediate_operand" "=Z,v,v,*Y,*r,*r,v,v,*r") @@ -2761,20 +2764,28 @@ DONE; }) +(define_insn "*p9_neg2" + [(set (match_operand:VNEG 0 "altivec_register_operand" "=v") + (neg:VNEG (match_operand:VNEG 1 "altivec_register_operand" "v")))] + "TARGET_P9_VECTOR" + "vneg %0,%1" + [(set_attr "type" "vecsimple")]) + (define_expand "neg2" - [(use (match_operand:VI 0 "register_operand" "")) - (use (match_operand:VI 1 "register_operand" ""))] - "TARGET_ALTIVEC" - " + [(set (match_operand:VI2 0 "register_operand" "") + (neg:VI2 (match_operand:VI2 1 "register_operand" "")))] + "" { - rtx vzero; + if (!TARGET_P9_VECTOR || (mode != V4SImode && mode != V2DImode)) + { + rtx vzero; - vzero = gen_reg_rtx (GET_MODE (operands[0])); - emit_insn (gen_altivec_vspltis (vzero, const0_rtx)); - emit_insn (gen_sub3 (operands[0], vzero, operands[1])); - - DONE; -}") + vzero = gen_reg_rtx (GET_MODE (operands[0])); + emit_move_insn (vzero, CONST0_RTX (mode)); + emit_insn (gen_sub3 (operands[0], vzero, operands[1])); + DONE; + } +}) (define_expand "udot_prod" [(set (match_operand:V4SI 0 "register_operand" "=v") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bb082a177ce..c5c1e3b5772 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-24 Michael Meissner + + * gcc.target/powerpc/p9-vneg.c: New test for ISA 3.0 VNEGW/VNEGD + instructions. + 2016-05-24 Cesar Philippidis * c-c++-common/goacc/data-clause-duplicate-1.c: Adjust test. diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vneg.c b/gcc/testsuite/gcc.target/powerpc/p9-vneg.c new file mode 100644 index 00000000000..10041c94fae --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/p9-vneg.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-mcpu=power9 -O2" } */ + +/* Verify P9 vector negate instructions. */ + +vector long long v2di_neg (vector long long a) { return -a; } +vector int v4si_neg (vector int a) { return -a; } + +/* { dg-final { scan-assembler "vnegd" } } */ +/* { dg-final { scan-assembler "vnegw" } } */ -- 2.30.2