From b989ffb2937ba4b87423bf43ebe0666dd4b08cea Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Oct 2017 14:11:11 +0200 Subject: [PATCH] genrecog.c (validate_pattern): For VEC_SELECT verify that CONST_INT selectors are 0 to GET_MODE_NUNITS (imode) - 1. * genrecog.c (validate_pattern): For VEC_SELECT verify that CONST_INT selectors are 0 to GET_MODE_NUNITS (imode) - 1. From-SVN: r253676 --- gcc/ChangeLog | 5 +++++ gcc/genrecog.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f632f6ba1cf..a7468efa748 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-10-12 Jakub Jelinek + + * genrecog.c (validate_pattern): For VEC_SELECT verify that + CONST_INT selectors are 0 to GET_MODE_NUNITS (imode) - 1. + 2017-10-12 Aldy Hernandez * Makefile.in (TAGS): Merge all the *.def files into one pattern. diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 902762fbc57..b3d02d755eb 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -751,6 +751,21 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code) 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 " -- 2.30.2