vect: fix out-of-bound access in supports_vec_convert_optab_p [PR 104851]

Calling VECTOR_MODE_P with MAX_MACHINE_MODE has caused out-of-bound
access.

gcc/

	PR tree-optimization/104851
	* optabs-query.cc (supports_vec_convert_optab_p): Fix off-by-one
	error.
This commit is contained in:
Xi Ruoyao 2022-03-09 11:46:03 +08:00
parent a5c9b7c4f9
commit 1c7b110e1e
No known key found for this signature in database
GPG Key ID: D95E4716CCBB34DC
1 changed files with 1 additions and 1 deletions

View File

@ -720,7 +720,7 @@ static bool
supports_vec_convert_optab_p (optab op, machine_mode mode)
{
int start = mode == VOIDmode ? 0 : mode;
int end = mode == VOIDmode ? MAX_MACHINE_MODE : mode;
int end = mode == VOIDmode ? MAX_MACHINE_MODE - 1 : mode;
for (int i = start; i <= end; ++i)
if (VECTOR_MODE_P ((machine_mode) i))
for (int j = MIN_MODE_VECTOR_INT; j < MAX_MODE_VECTOR_INT; ++j)