Hi! On Tue, Feb 25, 2020 at 12:15:52PM -0600, will schmidt wrote: > Adds some logic in altivec_resolve_overloaded_builtin() to handle the > scenario where const <foo>* arguments are passed in to the vec_xl_len() > builtin. > The existing logic to remove const from pointers does not kick in since > the return type is not itself a pointer type.
> 2020-02-24: Will Schmidt <will_schm...@vnet.ibm.com> No colon here. > gcc/ > PR target/90763 > * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Add > clause to handle P9V_BUILTIN_VEC_LXVL with const arguments. > > testsuite/ > PR target/90763 > * gcc.target/powerpc/pr90763: New. (That is not the actual filename, please fix). > > diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c > index 37c74cf..9ad8309 100644 > --- a/gcc/config/rs6000/rs6000-c.c > +++ b/gcc/config/rs6000/rs6000-c.c > @@ -1636,10 +1636,24 @@ altivec_resolve_overloaded_builtin (location_t loc, > tree fndecl, > type = build_pointer_type (build_qualified_type (TREE_TYPE (type), > 0)); > arg = fold_convert (type, arg); > } > > + /* For P9V_BUILTIN_VEC_LXVL, convert any const * to its non constant > + equivalent to simplify the overload matching below. */ > + if (fcode == P9V_BUILTIN_VEC_LXVL) > + { > + if (POINTER_TYPE_P (type) > + && (TYPE_QUALS (TREE_TYPE (type)) != 0) > + && TYPE_READONLY (TREE_TYPE (type))) The test for TYPE_QUALS is superfluous, you test for TYPE_READONLY anyway. > + { > + type = build_pointer_type (build_qualified_type ( > + TREE_TYPE (type),0)); > + arg = fold_convert (type, arg); > + } > + } > + > args[n] = arg; > types[n] = type; > } > > /* If the number of arguments did not match the prototype, return NULL > diff --git a/gcc/testsuite/gcc.target/powerpc/pr90763.c > b/gcc/testsuite/gcc.target/powerpc/pr90763.c > new file mode 100644 > index 0000000..ec0e56e > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr90763.c > @@ -0,0 +1,87 @@ > +/* { dg-require-effective-target powerpc_p9vector_ok } */ > +/* { dg-options "-mcpu=power9" } */ Add -O2 as well? Okay for trunk with those tweaks. Does this need backports as well? Thanks! Segher