On Thu, 27 Nov 2025, Jakub Jelinek wrote: > Hi! > > The bitint_extended changes in limb_access broke bitint_big_endian. > As we sometimes (for bitint_extended) access the MEM_REFs using > atype rather than m_limb_type, for big-endian we need to adjust > the MEM_REFs offset if atype has smaller TYPE_SIZE_UNIT than m_limb_size. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk if Stefan's testing on s390x-linux succeeds?
OK. > 2025-11-27 Jakub Jelinek <[email protected]> > > PR target/122714 > * gimple-lower-bitint.cc (bitint_large_huge::limb_access): Adjust > MEM_REFs offset for bitint_big_endian if ltype doesn't have the > same byte size as m_limb_type. > > --- gcc/gimple-lower-bitint.cc.jj 2025-09-30 13:37:48.364854566 +0200 > +++ gcc/gimple-lower-bitint.cc 2025-11-26 17:03:51.815649841 +0100 > @@ -630,6 +630,8 @@ bitint_large_huge::limb_access (tree typ > | 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; > + if (bitint_big_endian) > + off += m_limb_size - tree_to_uhwi (TYPE_SIZE_UNIT (ltype)); > ret = build2 (MEM_REF, ltype, > build_fold_addr_expr (var), > build_int_cst (ptype, off)); > @@ -641,12 +643,14 @@ bitint_large_huge::limb_access (tree typ > if (as != TYPE_ADDR_SPACE (ltype)) > ltype = build_qualified_type (ltype, TYPE_QUALS (ltype) > | ENCODE_QUAL_ADDR_SPACE (as)); > + unsigned HOST_WIDE_INT off = tree_to_uhwi (idx) * m_limb_size; > + if (bitint_big_endian) > + off += m_limb_size - tree_to_uhwi (TYPE_SIZE_UNIT (ltype)); > ret > = build2 (MEM_REF, ltype, unshare_expr (TREE_OPERAND (var, 0)), > size_binop (PLUS_EXPR, TREE_OPERAND (var, 1), > build_int_cst (TREE_TYPE (TREE_OPERAND (var, 1)), > - tree_to_uhwi (idx) > - * m_limb_size))); > + off))); > TREE_THIS_VOLATILE (ret) = TREE_THIS_VOLATILE (var); > TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (var); > TREE_THIS_NOTRAP (ret) = TREE_THIS_NOTRAP (var); > > Jakub > > -- Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
