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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> ---
The failure exposed one special case: there is one stmt 

# VUSE <.MEM_404>
_15 = *_14;

its STMT_VINFO_STRIDED_P (stmt_info) is set, memory_access_type is
VMAT_ELEMENTWISE and alignment_support_scheme is dr_unaligned_supported, its
vector type is "vector(1) long int", so in the handling it's taken as:

      /* Load vector(1) scalar_type if it's 1 element-wise vectype.  */
      else if (nloads == 1)
        ltype = vectype;

as its ltype is vector type, we cost it with 

                  if (VECTOR_TYPE_P (ltype))
                    vect_get_load_cost (vinfo, stmt_info, 1,
                                        alignment_support_scheme, misalignment,
                                        false, &inside_cost, nullptr, cost_vec,
                                        cost_vec, true);

as it's dr_unaligned_supported, it's costed as unaligned_load then causes the
ICE. One idea is to teach rs6000_builtin_vectorization_cost about one single
lane vector unaligned load as scalar_load. But I think it's simple to treat
single lane vector load as scalar_load, as I expect veclower will lower it
later.

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 4622d6a04ef..bdf4c12cd03 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -9985,7 +9985,9 @@ vectorizable_load (vec_info *vinfo,
             {
               if (costing_p)
                 {
-                  if (VECTOR_TYPE_P (ltype))
+                  /* For a single lane vector type, we should cost it as
+                     scalar_load to avoid ICE, see PR110776.  */
+                  if (VECTOR_TYPE_P (ltype) && lnel > 1)
                     vect_get_load_cost (vinfo, stmt_info, 1,
                                         alignment_support_scheme,
misalignment,
                                         false, &inside_cost, nullptr,
cost_vec,

Hi Richi, what do you think of this?

Reply via email to