public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/113395] RTL expansion drops MEM_EXPR
Date: Mon, 15 Jan 2024 11:54:20 +0000	[thread overview]
Message-ID: <bug-113395-4-eKrsiNOjCM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113395-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Because of

#0  adjust_address_1 (memref=0x7ffff71e8db0, mode=E_HImode, offset=..., 
    validate=1, adjust_address=1, adjust_object=1, size=...)
    at /space/rguenther/src/gcc/gcc/emit-rtl.cc:2409
#1  0x00000000011459af in narrow_bit_field_mem (mem=0x7ffff71e8db0, 
    mode=HImode, bitsize=2, bitnum=7, new_bitnum=0x7fffffffc8c0)
    at /space/rguenther/src/gcc/gcc/expmed.cc:453
#2  0x0000000001145d1c in adjust_bit_field_mem_for_reg (pattern=EP_insv, 
    op0=0x7ffff71e8db0, bitsize=2, bitnum=7, bitregion_start=..., 
    bitregion_end=..., fieldmode=E_VOIDmode, new_bitnum=0x7fffffffc8c0)
    at /space/rguenther/src/gcc/gcc/expmed.cc:511
#3  0x00000000011483bb in store_integral_bit_field (op0=0x7ffff71e8db0, 
    op0_mode=SImode, bitsize=2, bitnum=7, bitregion_start=..., 
    bitregion_end=..., fieldmode=E_VOIDmode, value=0x7ffff70124a0, 
    reverse=false, fallback_p=true)
    at /space/rguenther/src/gcc/gcc/expmed.cc:1086
#4  0x00000000011476a0 in store_bit_field_1 (str_rtx=0x7ffff71e8db0, 
    bitsize=..., bitnum=..., bitregion_start=..., bitregion_end=..., 
    fieldmode=E_VOIDmode, value=0x7ffff70124a0, reverse=false, 
    fallback_p=true, undefined_p=false)
    at /space/rguenther/src/gcc/gcc/expmed.cc:887
#5  0x0000000001148c31 in store_bit_field (str_rtx=0x7ffff71e8db0, 
    bitsize=..., bitnum=..., bitregion_start=..., bitregion_end=..., 
    fieldmode=E_VOIDmode, value=0x7ffff70124a0, reverse=false, 
--Type <RET> for more, q to quit, c to continue without paging--
    ) at /space/rguenther/src/gcc/gcc/expmed.cc:1194
#6  0x000000000117dde0 in store_field (target=0x7ffff71e8db0, bitsize=..., 
    bitpos=..., bitregion_start=..., bitregion_end=..., mode=E_VOIDmode, 
    exp=<integer_cst 0x7ffff71c4ca8>, alias_set=1, nontemporal=false, 
    reverse=false) at /space/rguenther/src/gcc/gcc/expr.cc:8245
#7  0x0000000001174b21 in expand_assignment (
    to=<component_ref 0x7ffff71e07b0>, from=<integer_cst 0x7ffff71c4ca8>, 
    nontemporal=false) at /space/rguenther/src/gcc/gcc/expr.cc:6303

and we run into

  if (maybe_ne (size, 0))
    {
      /* Drop the object if the new right end is not within its bounds.  */
      if (adjust_object && maybe_gt (offset + size, attrs.size))
        {
          attrs.expr = NULL_TREE;
          attrs.alias = 0;
        }

as attrs.size is originally 1 and we are creating a two byte HImode access.

IMHO it's the fault of how we set up the initial memory attributes which
come via expand_assignment doing

      tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
                                 &unsignedp, &reversep, &volatilep);
..
      if (TREE_CODE (to) == COMPONENT_REF
          && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
        get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset);
..
      to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE);
..
          if (MEM_P (to_rtx))
            {
              /* If the field is at offset zero, we could have been given the
                 DECL_RTX of the parent struct.  Don't munge it.  */
              to_rtx = shallow_copy_rtx (to_rtx);
              set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos);
              if (volatilep)
                MEM_VOLATILE_P (to_rtx) = 1;

that's an unfortunate setup to eventually widen the setup.

RTL alias analysis then has to rely on find_base_term to perform it's
bogus optimistic points-to analysis.

  reply	other threads:[~2024-01-15 11:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 10:49 [Bug middle-end/113395] New: " rguenth at gcc dot gnu.org
2024-01-15 11:54 ` rguenth at gcc dot gnu.org [this message]
2024-01-15 11:57 ` [Bug middle-end/113395] RTL expansion of bitfield accesses " rguenth at gcc dot gnu.org
2024-01-15 22:55 ` pinskia at gcc dot gnu.org
2024-01-15 22:58 ` pinskia at gcc dot gnu.org
2024-01-16  9:27 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113395-4-eKrsiNOjCM@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).