This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add further VEC_SELECT verification


On Wed, 11 Oct 2017, Jakub Jelinek wrote:

> Hi!
> 
> This patch adds verification that vec_select in *.md files
> doesn't have any out of bounds indices in the selector.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, tested
> by building cc1 of aarch64, arm, powerpc64le and s390x cross,
> and tested by hacking up sse.md to have an out of bounds access there,
> ok for trunk?

Ok.

Richard.

> 2017-10-11  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* genrecog.c (validate_pattern): For VEC_SELECT verify that
> 	CONST_INT selectors are 0 to GET_MODE_NUNITS (imode) - 1.
> 
> --- gcc/genrecog.c.jj	2017-09-01 09:25:40.000000000 +0200
> +++ gcc/genrecog.c	2017-10-11 17:53:20.107198630 +0200
> @@ -751,6 +751,21 @@ validate_pattern (rtx pattern, md_rtx_in
>  		error_at (info->loc,
>  			  "vec_select parallel with %d elements, expected %d",
>  			  XVECLEN (XEXP (pattern, 1), 0), expected);
> +	      else if (VECTOR_MODE_P (imode))
> +		{
> +		  unsigned int nelems = GET_MODE_NUNITS (imode);
> +		  int i;
> +		  for (i = 0; i < expected; ++i)
> +		    if (CONST_INT_P (XVECEXP (XEXP (pattern, 1), 0, i))
> +			&& (UINTVAL (XVECEXP (XEXP (pattern, 1), 0, i))
> +			    >= nelems))
> +		      error_at (info->loc,
> +				"out of bounds selector %u in vec_select, "
> +				"expected at most %u",
> +				(unsigned)
> +				UINTVAL (XVECEXP (XEXP (pattern, 1), 0, i)),
> +				nelems - 1);
> +		}
>  	    }
>  	  if (imode != VOIDmode && !VECTOR_MODE_P (imode))
>  	    error_at (info->loc, "%smode of first vec_select operand is not a "


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]