https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106322

--- Comment #39 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Comment on attachment 53428
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53428
untested patch

>diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
>index d666ccccf67..7d8b4ac2200 100644
>--- a/gcc/internal-fn.cc
>+++ b/gcc/internal-fn.cc
>@@ -3750,7 +3750,12 @@ static bool
> direct_optab_supported_p (direct_optab optab, tree_pair types,
>                         optimization_type opt_type)
> {
>-  machine_mode mode = TYPE_MODE (types.first);
>+  tree type = types.first;
>+  machine_mode mode = TYPE_MODE (type);
>+  /* Scalar mode optab can't work for vector type, return false if
>+     the given type is vector type but the mode isn't vector mode.  */
>+  if (VECTOR_TYPE_P (type) != VECTOR_MODE_P (mode))
>+    return false;

There are a few which scalar mode and vector types can differ and still work:
IOR, XOR, and AND. I wonder if those should be special cased here or somewhere
else.

>   gcc_checking_assert (mode == TYPE_MODE (types.second));
>   return direct_optab_handler (optab, mode, opt_type) != CODE_FOR_nothing;
> }
>@@ -3763,6 +3768,12 @@ static bool
> convert_optab_supported_p (convert_optab optab, tree_pair types,
>                          optimization_type opt_type)
> {
>+  tree type = types.first;
>+  machine_mode mode = TYPE_MODE (type);
>+  /* Scalar mode optab can't work for vector type, return false if
>+     the given type is vector type but the mode isn't vector mode.  */
>+  if (VECTOR_TYPE_P (type) != VECTOR_MODE_P (mode))
>+    return false;
>   return (convert_optab_handler (optab, TYPE_MODE (types.first),
>                                TYPE_MODE (types.second), opt_type)
>         != CODE_FOR_nothing);
>@@ -3778,6 +3789,7 @@ multi_vector_optab_supported_p (convert_optab optab, 
>tree_pair types,
>   gcc_assert (TREE_CODE (types.first) == ARRAY_TYPE);
>   machine_mode imode = TYPE_MODE (types.first);
>   machine_mode vmode = TYPE_MODE (TREE_TYPE (types.first));
>+  gcc_assert (VECTOR_MODE_P (vmode));
>   return (convert_optab_handler (optab, imode, vmode, opt_type)
>         != CODE_FOR_nothing);
> }

Reply via email to