Re: [PATCH, rs6000] Add vec_nabs builtin support
Hi Carl, On Fri, Jan 13, 2017 at 10:27:59AM -0800, Carl E. Love wrote: > * config/rs6000/altivec.md: Add define to expand nabs2 types * config/rs6000/altivec.md (nabs2): New define_expand. > * doc/extend.texi (section 6.60.22 PowerPC AltiVec Built-in Functions): > Update the documentation file for the new built-in functions. Section numbers aren't stable (or in the source file at all), just remove it here. > 2017-01-08 Carl Love> > * gcc.target/powerpc/builtins-3.c: Add tests for the new built-ins > to the test suite file. > * gcc.target/powerpc/builtins-3-p8.c: Add tests for the new built-ins > to the test suite file. Just say "New.", "New testcase.", or "New file.". New is much easier to write changelog entries for than modified ;-) Okay for trunk with those changes. Thanks! Segher
Re: [PATCH, rs6000] Add vec_nabs builtin support
Segar: The issues you pointed out below have been addressed in the following updated patch. Please let me know if the changes are acceptable. Thanks for your help and feedback. Carl Love > rs6000-c.c > > > vector signed char vec_nabs (vector signed char) > > vector signed short vec_nabs (vector signed short) > > vector signed int vec_nabs (vector signed int) > > vector signed long long vec_nabs (vector signed long long) > > vector float vec_nabs (vector float) > > vector double vec_nabs (vector double) > > You should mention the name of the function or data etc. you modified here: > rs6000-c.c (altivec_overloaded_builtins): Blabla. > > or something like that. > > > * config/rs6000/rs6000-builtin.def: Add definitions for NABS functions > > and NABS overload. > > * config/rs6000/altivec.md: Add define to expand nabs2 types > > * config/rs6000/altivec.h: Add define for vec_nabs built-in function. > > * doc/extend.texi: Update the built-in documentation file for the > > new built-in functions. > > Here, too. > > > + int i, n_elt = GET_MODE_NUNITS (mode); > > Two lines for this please, two separate declarations. I realise you just > copied this code ;-) -- gcc/ChangeLog: 2017-01-08 Carl Love* config/rs6000/rs6000-c (altivec_overloaded_builtins): Add support for built-in functions vector signed char vec_nabs (vector signed char) vector signed short vec_nabs (vector signed short) vector signed int vec_nabs (vector signed int) vector signed long long vec_nabs (vector signed long long) vector float vec_nabs (vector float) vector double vec_nabs (vector double) * config/rs6000/rs6000-builtin.def: Add definitions for NABS functions and NABS overload. * config/rs6000/altivec.md: Add define to expand nabs2 types * config/rs6000/altivec.h: Add define for vec_nabs built-in function. * doc/extend.texi (section 6.60.22 PowerPC AltiVec Built-in Functions): Update the documentation file for the new built-in functions. gcc/testsuite/ChangeLog: 2017-01-08 Carl Love * gcc.target/powerpc/builtins-3.c: Add tests for the new built-ins to the test suite file. * gcc.target/powerpc/builtins-3-p8.c: Add tests for the new built-ins to the test suite file. --- gcc/config/rs6000/altivec.h | 1 + gcc/config/rs6000/altivec.md | 27 ++ gcc/config/rs6000/rs6000-builtin.def | 9 + gcc/config/rs6000/rs6000-c.c | 12 ++ gcc/doc/extend.texi | 8 gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c | 12 +- gcc/testsuite/gcc.target/powerpc/builtins-3.c| 47 +++- 7 files changed, 114 insertions(+), 2 deletions(-) diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h index 73567ff..17bc33e 100644 --- a/gcc/config/rs6000/altivec.h +++ b/gcc/config/rs6000/altivec.h @@ -189,6 +189,7 @@ #define vec_vupklsh __builtin_vec_vupklsh #define vec_vupklsb __builtin_vec_vupklsb #define vec_abs __builtin_vec_abs +#define vec_nabs __builtin_vec_nabs #define vec_abss __builtin_vec_abss #define vec_add __builtin_vec_add #define vec_adds __builtin_vec_adds diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index c2063d5..2a26007 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -2741,6 +2741,33 @@ }) ;; Generate +;;vspltisw SCRATCH1,0 +;;vsubu?m SCRATCH2,SCRATCH1,%1 +;;vmins? %0,%1,SCRATCH2" +(define_expand "nabs2" + [(set (match_dup 2) (match_dup 3)) + (set (match_dup 4) +(minus:VI2 (match_dup 2) + (match_operand:VI2 1 "register_operand" "v"))) + (set (match_operand:VI2 0 "register_operand" "=v") +(smin:VI2 (match_dup 1) (match_dup 4)))] + "" +{ + int i; + int n_elt = GET_MODE_NUNITS (mode); + + rtvec v = rtvec_alloc (n_elt); + + /* Create an all 0 constant. */ + for (i = 0; i < n_elt; ++i) +RTVEC_ELT (v, i) = const0_rtx; + + operands[2] = gen_reg_rtx (mode); + operands[3] = gen_rtx_CONST_VECTOR (mode, v); + operands[4] = gen_reg_rtx (mode); +}) + +;; Generate ;;vspltisw SCRATCH1,-1 ;;vslw SCRATCH2,SCRATCH1,SCRATCH1 ;;vandc %0,%1,SCRATCH2 diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 2329c1f..1cdf9a8 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -1129,6 +1129,14 @@ BU_ALTIVEC_A (ABSS_V4SI, "abss_v4si", SAT, altivec_abss_v4si) BU_ALTIVEC_A (ABSS_V8HI, "abss_v8hi", SAT,altivec_abss_v8hi) BU_ALTIVEC_A (ABSS_V16QI, "abss_v16qi",SAT,altivec_abss_v16qi) +/*
Re: [PATCH, rs6000] Add vec_nabs builtin support
Hi Carl, On Mon, Jan 09, 2017 at 10:02:40AM -0800, Carl E. Love wrote: > * config/rs6000/rs6000-c: Add support for built-in functions rs6000-c.c > vector signed char vec_nabs (vector signed char) > vector signed short vec_nabs (vector signed short) > vector signed int vec_nabs (vector signed int) > vector signed long long vec_nabs (vector signed long long) > vector float vec_nabs (vector float) > vector double vec_nabs (vector double) You should mention the name of the function or data etc. you modified here: rs6000-c.c (altivec_overloaded_builtins): Blabla. or something like that. > * config/rs6000/rs6000-builtin.def: Add definitions for NABS functions > and NABS overload. > * config/rs6000/altivec.md: Add define to expand nabs2 types > * config/rs6000/altivec.h: Add define for vec_nabs built-in function. > * doc/extend.texi: Update the built-in documentation file for the > new built-in functions. Here, too. > + int i, n_elt = GET_MODE_NUNITS (mode); Two lines for this please, two separate declarations. I realise you just copied this code ;-) Segher
Re: [PATCH, rs6000] Add vec_nabs builtin support
Oops, accidentally hit send. Was trying to insert file. On Mon, 2017-01-09 at 09:58 -0800, Carl E. Love wrote: > GCC maintainers: > > The following patch adds two more built-ins that are missing. > Specifically: > > vector signed char vec_nabs (vector signed char) > vector signed short vec_nabs (vector signed short) > vector signed int vec_nabs (vector signed int) > vector signed long long vec_nabs (vector signed long long) > vector float vec_nabs (vector float) > vector double vec_nabs (vector double) > > > The patch has been boot strapped and tested on > powerpc64le-unknown-linux-gnu (Power 8 LE) and on > powerpc64-unknown-linux-gnu (Power 8 BE 64-bit, 32-bit) and on > powerpc64-unknown-linux-gnu (Power 7 64-bit, 32-bit) with no > regressions. > > Is this OK for trunk? > > Carl Love > > > --- gcc/ChangeLog: 2017-01-09 Carl Love* config/rs6000/rs6000-c: Add support for built-in functions vector signed char vec_nabs (vector signed char) vector signed short vec_nabs (vector signed short) vector signed int vec_nabs (vector signed int) vector signed long long vec_nabs (vector signed long long) vector float vec_nabs (vector float) vector double vec_nabs (vector double) * config/rs6000/rs6000-builtin.def: Add definitions for NABS functions and NABS overload. * config/rs6000/altivec.md: Add define to expand nabs2 types * config/rs6000/altivec.h: Add define for vec_nabs built-in function. * doc/extend.texi: Update the built-in documentation file for the new built-in functions. gcc/testsuite/ChangeLog: 2017-01-09 Carl Love * gcc.target/powerpc/builtins-3.c: Add tests for the new built-ins to the test suite file. * gcc.target/powerpc/builtins-3-p8.c: Add tests for the new built-ins to the test suite file. --- gcc/config/rs6000/altivec.h | 1 + gcc/config/rs6000/altivec.md | 25 + gcc/config/rs6000/rs6000-builtin.def | 9 + gcc/config/rs6000/rs6000-c.c | 12 ++ gcc/doc/extend.texi | 8 gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c | 12 +- gcc/testsuite/gcc.target/powerpc/builtins-3.c| 47 +++- 7 files changed, 112 insertions(+), 2 deletions(-) diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h index 73567ff..17bc33e 100644 --- a/gcc/config/rs6000/altivec.h +++ b/gcc/config/rs6000/altivec.h @@ -189,6 +189,7 @@ #define vec_vupklsh __builtin_vec_vupklsh #define vec_vupklsb __builtin_vec_vupklsb #define vec_abs __builtin_vec_abs +#define vec_nabs __builtin_vec_nabs #define vec_abss __builtin_vec_abss #define vec_add __builtin_vec_add #define vec_adds __builtin_vec_adds diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index c2063d5..2c8d20b 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -2741,6 +2741,31 @@ }) ;; Generate +;;vspltisw SCRATCH1,0 +;;vsubu?m SCRATCH2,SCRATCH1,%1 +;;vmins? %0,%1,SCRATCH2" +(define_expand "nabs2" + [(set (match_dup 2) (match_dup 3)) + (set (match_dup 4) +(minus:VI2 (match_dup 2) + (match_operand:VI2 1 "register_operand" "v"))) + (set (match_operand:VI2 0 "register_operand" "=v") +(smin:VI2 (match_dup 1) (match_dup 4)))] + "" +{ + int i, n_elt = GET_MODE_NUNITS (mode); + rtvec v = rtvec_alloc (n_elt); + + /* Create an all 0 constant. */ + for (i = 0; i < n_elt; ++i) +RTVEC_ELT (v, i) = const0_rtx; + + operands[2] = gen_reg_rtx (mode); + operands[3] = gen_rtx_CONST_VECTOR (mode, v); + operands[4] = gen_reg_rtx (mode); +}) + +;; Generate ;;vspltisw SCRATCH1,-1 ;;vslw SCRATCH2,SCRATCH1,SCRATCH1 ;;vandc %0,%1,SCRATCH2 diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 2329c1f..1cdf9a8 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -1129,6 +1129,14 @@ BU_ALTIVEC_A (ABSS_V4SI, "abss_v4si", SAT, altivec_abss_v4si) BU_ALTIVEC_A (ABSS_V8HI, "abss_v8hi", SAT,altivec_abss_v8hi) BU_ALTIVEC_A (ABSS_V16QI, "abss_v16qi",SAT,altivec_abss_v16qi) +/* Altivec NABS functions. */ +BU_ALTIVEC_A (NABS_V2DI, "nabs_v2di", CONST, nabsv2di2) +BU_ALTIVEC_A (NABS_V4SI, "nabs_v4si", CONST, nabsv4si2) +BU_ALTIVEC_A (NABS_V8HI, "nabs_v8hi", CONST, nabsv8hi2) +BU_ALTIVEC_A (NABS_V16QI, "nabs_v16qi",CONST, nabsv16qi2) +BU_ALTIVEC_A (NABS_V4SF, "nabs_v4sf", CONST, vsx_nabsv4sf2) +BU_ALTIVEC_A (NABS_V2DF, "nabs_v2df", CONST, vsx_nabsv2df2) + /* 1 argument Altivec builtin
[PATCH, rs6000] Add vec_nabs builtin support
GCC maintainers: The following patch adds two more built-ins that are missing. Specifically: vector signed char vec_nabs (vector signed char) vector signed short vec_nabs (vector signed short) vector signed int vec_nabs (vector signed int) vector signed long long vec_nabs (vector signed long long) vector float vec_nabs (vector float) vector double vec_nabs (vector double) The patch has been boot strapped and tested on powerpc64le-unknown-linux-gnu (Power 8 LE) and on powerpc64-unknown-linux-gnu (Power 8 BE 64-bit, 32-bit) and on powerpc64-unknown-linux-gnu (Power 7 64-bit, 32-bit) with no regressions. Is this OK for trunk? Carl Love ---