On Thu, 4 Sep 2025, Jakub Jelinek wrote:

> On Tue, Sep 02, 2025 at 04:51:37PM +0200, Jakub Jelinek wrote:
> > What about the following instead?
> > 
> > The first two hunks aren't strictly necessary, I'm just trying to
> > avoid calling build_qualified_type when it won't be needed.
> > 
> > At least on s390x-linux (tried cross) bitint-14.c doesn't ICE with it
> > anymore.
> 
> Now bootstrapped/regtested on x86_64-linux and i686-linux and tested
> on loongarch64-linux as well:
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694095.html
> 
> Ok for trunk?

OK.

> > 2025-09-02  Jakub Jelinek  <ja...@redhat.com>
> > 
> >     PR target/117599
> >     * gimple-lower-bitint.cc (bitint_large_huge::limb_access): Move
> >     build_qualified_type calls into the if/else if/else bodies, for
> >     the last one set ltype to m_limb_type first, drop limb_type_a
> >     and use ltype instead.
> > 
> > --- gcc/gimple-lower-bitint.cc.jj   2025-08-06 12:56:23.112250920 +0200
> > +++ gcc/gimple-lower-bitint.cc      2025-09-02 16:31:38.457160484 +0200
> > @@ -622,12 +622,12 @@ bitint_large_huge::limb_access (tree typ
> >    tree ltype = (bitint_extended && abi_load_p) ? atype : m_limb_type;
> >  
> >    addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (var));
> > -  if (as != TYPE_ADDR_SPACE (ltype))
> > -    ltype = build_qualified_type (ltype, TYPE_QUALS (ltype)
> > -                                    | ENCODE_QUAL_ADDR_SPACE (as));
> >    tree ret;
> >    if (DECL_P (var) && tree_fits_uhwi_p (idx))
> >      {
> > +      if (as != TYPE_ADDR_SPACE (ltype))
> > +   ltype = build_qualified_type (ltype, TYPE_QUALS (ltype)
> > +                                 | ENCODE_QUAL_ADDR_SPACE (as));
> >        tree ptype = build_pointer_type (strip_array_types (TREE_TYPE 
> > (var)));
> >        unsigned HOST_WIDE_INT off = tree_to_uhwi (idx) * m_limb_size;
> >        ret = build2 (MEM_REF, ltype,
> > @@ -638,6 +638,9 @@ bitint_large_huge::limb_access (tree typ
> >      }
> >    else if (TREE_CODE (var) == MEM_REF && tree_fits_uhwi_p (idx))
> >      {
> > +      if (as != TYPE_ADDR_SPACE (ltype))
> > +   ltype = build_qualified_type (ltype, TYPE_QUALS (ltype)
> > +                                 | ENCODE_QUAL_ADDR_SPACE (as));
> >        ret
> >     = build2 (MEM_REF, ltype, unshare_expr (TREE_OPERAND (var, 0)),
> >               size_binop (PLUS_EXPR, TREE_OPERAND (var, 1),
> > @@ -650,6 +653,10 @@ bitint_large_huge::limb_access (tree typ
> >      }
> >    else
> >      {
> > +      ltype = m_limb_type;
> > +      if (as != TYPE_ADDR_SPACE (ltype))
> > +   ltype = build_qualified_type (ltype, TYPE_QUALS (ltype)
> > +                                 | ENCODE_QUAL_ADDR_SPACE (as));
> >        var = unshare_expr (var);
> >        if (TREE_CODE (TREE_TYPE (var)) != ARRAY_TYPE
> >       || !useless_type_conversion_p (m_limb_type,
> > @@ -657,16 +664,7 @@ bitint_large_huge::limb_access (tree typ
> >     {
> >       unsigned HOST_WIDE_INT nelts
> >         = CEIL (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var))), limb_prec);
> > -
> > -     /* Build the array type with m_limb_type from the right address
> > -        space.  */
> > -     tree limb_type_a = m_limb_type;
> > -     if (as != TYPE_ADDR_SPACE (m_limb_type))
> > -       limb_type_a = build_qualified_type (m_limb_type,
> > -                                           TYPE_QUALS (m_limb_type)
> > -                                           | ENCODE_QUAL_ADDR_SPACE (as));
> > -
> > -     tree atype = build_array_type_nelts (limb_type_a, nelts);
> > +     tree atype = build_array_type_nelts (ltype, nelts);
> >       var = build1 (VIEW_CONVERT_EXPR, atype, var);
> >     }
> >        ret = build4 (ARRAY_REF, ltype, var, idx, NULL_TREE, NULL_TREE);
> > 
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to