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 >