https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111754
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> --- > Am 10.10.2023 um 16:07 schrieb prathamesh3492 at gcc dot gnu.org > <gcc-bugzi...@gcc.gnu.org>: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111754 > > --- Comment #6 from prathamesh3492 at gcc dot gnu.org --- > (In reply to rguent...@suse.de from comment #4) >>> On Tue, 10 Oct 2023, prathamesh3492 at gcc dot gnu.org wrote: >>> >>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111754 >>> >>> --- Comment #3 from prathamesh3492 at gcc dot gnu.org --- >>> The issue is that we only support integral vector types in >>> fold_vec_perm_cst, >>> but fail to check for the same before calling it from fold_vec_perm. >>> The following tweak fixes the ICE: >>> >>> diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc >>> index 4f8561509ff..a29a8af6d2f 100644 >>> --- a/gcc/fold-const.cc >>> +++ b/gcc/fold-const.cc >>> @@ -10801,7 +10801,8 @@ fold_vec_perm (tree type, tree arg0, tree arg1, >>> const >>> vec_perm_indices &sel) >>> return NULL_TREE; >>> >>> if (TREE_CODE (arg0) == VECTOR_CST >>> - && TREE_CODE (arg1) == VECTOR_CST) >>> + && TREE_CODE (arg1) == VECTOR_CST >>> + && INTEGRAL_TYPE_P (TREE_TYPE (type))) >>> return fold_vec_perm_cst (type, arg0, arg1, sel); >> >> Huh, that looks wrong. I fail to see how the element type matters >> at all. > > IIUC, the element type matters for VLA folding when sel has a stepped sequence > because in that case we need to derive elements from the encoding using > vector_cst_elt / vector_cst_int_elt, and it gets enforced for VLS vectors too > because they are handled in unified manner in fold_vec_perm_cst. > > Another possible approach is to use "VLS exception" in fold_vec_perm_cst to > encode all the elements: > res_npatterns = res_nelts; > res_nelts_per_patterns = 1 > just like we do if valid_mask_for_fold_vec_perm_cst_p returns false. > > Does the following fix look OK instead ? I think so, the important part is to fold for VLS types. I defer to Richard S. For whether we can do better for VLA here > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > index 4f8561509ff..356eb052fbc 100644 > --- a/gcc/fold-const.cc > +++ b/gcc/fold-const.cc > @@ -10642,6 +10642,11 @@ valid_mask_for_fold_vec_perm_cst_p (tree arg0, tree > arg1, > if (sel_nelts_per_pattern < 3) > return true; > > + /* If SEL contains stepped sequence, ensure that we are dealing with > + integral vector_cst. */ > + if (!INTEGRAL_TYPE_P (TREE_TYPE (arg0))) > + return false; > + > for (unsigned pattern = 0; pattern < sel_npatterns; pattern++) > { > poly_uint64 a1 = sel[pattern + sel_npatterns]; > > -- > You are receiving this mail because: > You are on the CC list for the bug.