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);

   /* For fall back case, we want to ensure we have VLS vectors

and results in the following .optimized dump:
F bar (F a, F b)
{
  F c;

  <bb 2> [local count: 1073741824]:
  c_2 = VEC_PERM_EXPR <a_1(D), a_1(D), { 1, 0, 1, 2 }>;
  __builtin_logbl (0.0);
  return c_2;

}

F foo ()
{
  <bb 2> [local count: 1073741824]:
  __builtin_logbl (0.0);
  return { 0.0, 9.0e+0, 0.0, 0.0 };

}

Reply via email to