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

--- Comment #8 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to qinzhao from comment #7)
> (In reply to Peter Bergner from comment #3)
> > (In reply to Andrew Pinski from comment #1)
> > > The types are OPAQUE_TYPE.
> > [snip]
> > > So if I understand this correctly and PR 98872 correctly. We should not
> > > expand a DEFERRED_INIT for this type.
> > 
> > So something like this?  Ie, it's ok to just skip this altogether?  It does
> > fix this particular ICE.
> 
> not sure whether this is too conservative or not.
> if a OPAQUE_TYPE variable is in memory, we might be able to initialize it
> with memset. 
> however, when it is in register, we might need to skip the initialization. 
> > 
> > 
> > diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
> > index 9e10da0ad5c..200d14337d7 100644
> > --- a/gcc/internal-fn.c
> > +++ b/gcc/internal-fn.c
> > @@ -3041,6 +3041,9 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
> >    tree var_type = TREE_TYPE (lhs);
> >    gcc_assert (init_type > AUTO_INIT_UNINITIALIZED);
> >  
> > +  if (OPAQUE_TYPE_P (var_type))
> > +    return;
> > +
> >    if (TREE_CODE (lhs) == SSA_NAME)
> >      reg_lhs = true;
> >    else

So this then?

diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 9e10da0ad5c..783781aed6a 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3070,6 +3070,9 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
     }
   else
     {
+      if (OPAQUE_TYPE_P (var_type))
+       return;
+
       /* If this variable is in a register use expand_assignment.  */
       tree init;
       if (tree_fits_uhwi_p (var_size)

This also fixes the ICE and generates a memset when the test case looks like:

void
foo (__vector_quad *dst)
{
  __vector_quad acc[16];
  *dst = acc[0];
}

Reply via email to