diff options
author | Richard Biener <rguenther@suse.de> | 2023-08-18 09:41:56 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-08-18 10:23:47 +0200 |
commit | f5f47cc1ce75b00427756939a2dab94d3d125f6a (patch) | |
tree | 6439af120281d1983d60d5942c6298a9b28e1f59 /gcc/fold-const.cc | |
parent | 68f7cb6cf9e8b9f2254855507f3b479552adda5f (diff) | |
download | gcc-f5f47cc1ce75b00427756939a2dab94d3d125f6a.zip gcc-f5f47cc1ce75b00427756939a2dab94d3d125f6a.tar.gz gcc-f5f47cc1ce75b00427756939a2dab94d3d125f6a.tar.bz2 |
tree-optimization/111048 - avoid flawed logic in fold_vec_perm
The following avoids running into somehow flawed logic in fold_vec_perm
for non-VLA vectors.
PR tree-optimization/111048
* fold-const.cc (fold_vec_perm_cst): Check for non-VLA
vectors first.
* gcc.dg/torture/pr111048.c: New testcase.
Diffstat (limited to 'gcc/fold-const.cc')
-rw-r--r-- | gcc/fold-const.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index c6fb083..08530b6 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -10625,6 +10625,11 @@ fold_vec_perm_cst (tree type, tree arg0, tree arg1, const vec_perm_indices &sel, unsigned res_npatterns, res_nelts_per_pattern; unsigned HOST_WIDE_INT res_nelts; + if (TYPE_VECTOR_SUBPARTS (type).is_constant (&res_nelts)) + { + res_npatterns = res_nelts; + res_nelts_per_pattern = 1; + } /* (1) If SEL is a suitable mask as determined by valid_mask_for_fold_vec_perm_cst_p, then: res_npatterns = max of npatterns between ARG0, ARG1, and SEL @@ -10634,7 +10639,7 @@ fold_vec_perm_cst (tree type, tree arg0, tree arg1, const vec_perm_indices &sel, res_npatterns = nelts in result vector. res_nelts_per_pattern = 1. This exception is made so that VLS ARG0, ARG1 and SEL work as before. */ - if (valid_mask_for_fold_vec_perm_cst_p (arg0, arg1, sel, reason)) + else if (valid_mask_for_fold_vec_perm_cst_p (arg0, arg1, sel, reason)) { res_npatterns = std::max (VECTOR_CST_NPATTERNS (arg0), @@ -10648,11 +10653,6 @@ fold_vec_perm_cst (tree type, tree arg0, tree arg1, const vec_perm_indices &sel, res_nelts = res_npatterns * res_nelts_per_pattern; } - else if (TYPE_VECTOR_SUBPARTS (type).is_constant (&res_nelts)) - { - res_npatterns = res_nelts; - res_nelts_per_pattern = 1; - } else return NULL_TREE; |