On Wed, Jul 30, 2025 at 03:44:16PM +0800, Yang Yujie wrote:
> On Wed, Jul 30, 2025 at 09:29:49AM GMT, Jakub Jelinek wrote:
> > On Fri, Jul 25, 2025 at 10:53:37AM +0800, Yang Yujie wrote:
> > > +
> > >    addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (var));
> > >    if (as != TYPE_ADDR_SPACE (ltype))
> > >      ltype = build_qualified_type (ltype, TYPE_QUALS (ltype)
> > > @@ -651,12 +655,12 @@ bitint_large_huge::limb_access (tree type, tree 
> > > var, tree idx, bool write_p)
> > >   {
> > >     unsigned HOST_WIDE_INT nelts
> > >       = CEIL (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var))), limb_prec);
> > > -   tree atype = build_array_type_nelts (ltype, nelts);
> > > +   tree atype = build_array_type_nelts (m_limb_type, nelts);
> > 
> > This looks wrong.  It needs to be from the right address space, see above
> >   if (as != TYPE_ADDR_SPACE (ltype))
> >     ltype = build_qualified_type ...
> > 
> > >     var = build1 (VIEW_CONVERT_EXPR, atype, var);
> > >   }
> > >        ret = build4 (ARRAY_REF, ltype, var, idx, NULL_TREE, NULL_TREE);
> > >      }
> > > -  if (!write_p && !useless_type_conversion_p (atype, m_limb_type))
> > > +  if (!write_p && !useless_type_conversion_p (atype, ltype))
> > 
> > Again, this looks wrong for non-standard address spaces.
> > 
> >     Jakub
> 
> 
> Thanks for the quick review.
> 
> So is it OK if I replace these references to LTYPE with the LTYPE before being
> processed by build_qualified_type?

Dunno, probably you need to keep the original ltype in another automatic var
and in that second hunk use ltype as before if original_ltype ==
m_limb_type, use m_limb_type if original_ltype == ltype and otherwise
add another build_qualified_type call.
For the last hunk, seems like for the original_ltype != m_limb_type case
you simply don't want the condition to be ever true - doing
useless_type_conversion_p (atype, atype).  So perhaps add a check for that.

        Jakub

Reply via email to