diff options
author | Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> | 2018-11-09 06:39:25 +0000 |
---|---|---|
committer | Prathamesh Kulkarni <prathamesh3492@gcc.gnu.org> | 2018-11-09 06:39:25 +0000 |
commit | 536ecfc44b1fd2db67f669e9bb4c388b13d12045 (patch) | |
tree | ca9ede50c30e6165eea043525144b0a495c3452d /gcc | |
parent | 41f8d1fc011e0da012bd00624fd2668da83d9f31 (diff) | |
download | gcc-536ecfc44b1fd2db67f669e9bb4c388b13d12045.zip gcc-536ecfc44b1fd2db67f669e9bb4c388b13d12045.tar.gz gcc-536ecfc44b1fd2db67f669e9bb4c388b13d12045.tar.bz2 |
neon.md (div<mode>3): New pattern.
2018-11-09 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* config/arm/neon.md (div<mode>3): New pattern.
testsuite/
* gcc.target/arm/neon-vect-div-1.c: New test.
* gcc.target/arm/neon-vect-div-2.c: Likewise.
From-SVN: r265948
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/config/arm/neon.md | 32 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/neon-vect-div-1.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/neon-vect-div-2.c | 16 |
5 files changed, 73 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8961e80..800a115 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-11-09 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + + * config/arm/neon.md (div<mode>3): New pattern. + 2018-11-08 Andi Kleen <ak@linux.intel.com> * common/config/i386/i386-common.c (OPTION_MASK_ISA_PTWRITE_SET): New. diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md index 5aeee4b..07572e4 100644 --- a/gcc/config/arm/neon.md +++ b/gcc/config/arm/neon.md @@ -620,6 +620,38 @@ (const_string "neon_mul_<V_elem_ch><q>")))] ) +/* Perform division using multiply-by-reciprocal. + Reciprocal is calculated using Newton-Raphson method. + Enabled with -funsafe-math-optimizations -freciprocal-math + and disabled for -Os since it increases code size . */ + +(define_expand "div<mode>3" + [(set (match_operand:VCVTF 0 "s_register_operand" "=w") + (div:VCVTF (match_operand:VCVTF 1 "s_register_operand" "w") + (match_operand:VCVTF 2 "s_register_operand" "w")))] + "TARGET_NEON && !optimize_size + && flag_reciprocal_math" + { + rtx rec = gen_reg_rtx (<MODE>mode); + rtx vrecps_temp = gen_reg_rtx (<MODE>mode); + + /* Reciprocal estimate. */ + emit_insn (gen_neon_vrecpe<mode> (rec, operands[2])); + + /* Perform 2 iterations of newton-raphson method. */ + for (int i = 0; i < 2; i++) + { + emit_insn (gen_neon_vrecps<mode> (vrecps_temp, rec, operands[2])); + emit_insn (gen_mul<mode>3 (rec, rec, vrecps_temp)); + } + + /* We now have reciprocal in rec, perform operands[0] = operands[1] * rec. */ + emit_insn (gen_mul<mode>3 (operands[0], operands[1], rec)); + DONE; + } +) + + (define_insn "mul<mode>3add<mode>_neon" [(set (match_operand:VDQW 0 "s_register_operand" "=w") (plus:VDQW (mult:VDQW (match_operand:VDQW 2 "s_register_operand" "w") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e5641fe..aa79847 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-09 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + + * gcc.target/arm/neon-vect-div-1.c: New test. + * gcc.target/arm/neon-vect-div-2.c: Likewise. + 2018-11-08 Andi Kleen <ak@linux.intel.com> * gcc.target/i386/ptwrite1.c: New test. diff --git a/gcc/testsuite/gcc.target/arm/neon-vect-div-1.c b/gcc/testsuite/gcc.target/arm/neon-vect-div-1.c new file mode 100644 index 0000000..50d04b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/neon-vect-div-1.c @@ -0,0 +1,16 @@ +/* Test pattern div<mode>3. */ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-require-effective-target vect_hw_misalign } */ +/* { dg-options "-O2 -ftree-vectorize -funsafe-math-optimizations -fdump-tree-vect-details" } */ +/* { dg-add-options arm_neon } */ + +void +foo (int len, float * __restrict p, float *__restrict x) +{ + len = len & ~31; + for (int i = 0; i < len; i++) + p[i] = p[i] / x[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.target/arm/neon-vect-div-2.c b/gcc/testsuite/gcc.target/arm/neon-vect-div-2.c new file mode 100644 index 0000000..606f54b --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/neon-vect-div-2.c @@ -0,0 +1,16 @@ +/* Test pattern div<mode>3. */ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-require-effective-target vect_hw_misalign } */ +/* { dg-options "-O3 -ftree-vectorize -funsafe-math-optimizations -fdump-tree-vect-details -fno-reciprocal-math" } */ +/* { dg-add-options arm_neon } */ + +void +foo (int len, float * __restrict p, float *__restrict x) +{ + len = len & ~31; + for (int i = 0; i < len; i++) + p[i] = p[i] / x[i]; +} + +/* { dg-final { scan-tree-dump-not "vectorized 1 loops" "vect" } } */ |