This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, RFC, rs6000, v3] enable early gimple-folding of vec_splat
- From: Will Schmidt <will_schmidt at vnet dot ibm dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: Bill Schmidt <wschmidt at linux dot ibm dot com>, Richard Biener <richard dot guenther at gmail dot com>, Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>, David Edelsohn <dje dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 18 Sep 2018 10:52:17 -0500
- Subject: Re: [PATCH, RFC, rs6000, v3] enable early gimple-folding of vec_splat
- References: <1533669927.4452.14.camel@brimstone.rchland.ibm.com> <6E9306D6-B8A1-42F6-90E9-0E6CC7AC66FA@linux.ibm.com> <1534434645.18801.8.camel@brimstone.rchland.ibm.com> <20180816205117.GA24439@gate.crashing.org> <1534801470.26070.20.camel@brimstone.rchland.ibm.com> <20180912132339.GK23155@gate.crashing.org>
- Reply-to: will_schmidt at vnet dot ibm dot com
On Wed, 2018-09-12 at 08:23 -0500, Segher Boessenkool wrote:
> Hi!
> > + unsigned int n_elts = VECTOR_CST_NELTS (arg0);
> > + if (TREE_CODE (arg1) != INTEGER_CST
> > + || TREE_INT_CST_LOW (arg1) > (n_elts -1))
> > + return false;
>
> I think you should check lower bound 0 as well. Maybe use IN_RANGE?
I'm comparing the IN_RANGE usage here with elsewhere in rs6000.c.
Do I need the sext_hwi() adjustment for arg1 within the IN_RANGE check?
As reference, this is for the vec_splat intrinsic, where arg1 is defined
as 'const int', and we want to return false if arg1 is outside the range
of 0..#elements .
vector bool char vec_splat (vector bool char, const int);
So.. this?
unsigned int n_elts = VECTOR_CST_NELTS (arg0);
if (TREE_CODE (arg1) != INTEGER_CST
|| !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, (n_elts - 1))
return false;
OR something like this with sext_hwi(...) ?:
unsigned int n_elts = VECTOR_CST_NELTS (arg0);
if (TREE_CODE (arg1) != INTEGER_CST
|| !IN_RANGE (sext_hwi (TREE_INT_CST_LOW (arg1), n_elts),
0, (n_elts - 1)))
return false;
thanks
-Will
>
> The rest looks fine, thanks! Okay for trunk (with the trivialities fixed).
>
>
> Segher
>