public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Roger Sayle" <roger@nextmovesoftware.com>
To: "'Rainer Orth'" <ro@CeBiTec.Uni-Bielefeld.DE>
Cc: "'Andreas Schwab'" <schwab@linux-m68k.org>, <gcc-patches@gcc.gnu.org>
Subject: RE: [PING] PR middle-end/95126: Expand small const structs as immediate constants
Date: Mon, 6 Jun 2022 13:29:50 +0100	[thread overview]
Message-ID: <056b01d879a1$1fdccfd0$5f966f70$@nextmovesoftware.com> (raw)
In-Reply-To: <yddr142ypbd.fsf@CeBiTec.Uni-Bielefeld.DE>


Hi Rainer,

> > The one experiment I'd like to be able to try, to investigate the
> > cause/cure of this, is:
> >
> > diff --git a/gcc/calls.cc b/gcc/calls.cc index a4336c1..05fdd24 100644
> > --- a/gcc/calls.cc
> > +++ b/gcc/calls.cc
> > @@ -2177,7 +2177,7 @@ load_register_parameters (struct arg_data *args,
> > int num_a
> >              VAR_DECL with a simple constructor, expand that constructor
> >              via a pseudo rather than read from (possibly misaligned)
> >              memory.  PR middle-end/95126.  */
> > -         else if (nregs == 1
> > +         else if (0 && nregs == 1
> >                    && partial == 0
> >                    && !args[i].pass_on_stack
> >                    && VAR_P (tree_value)
> >
> > My "small const structs" patch affected code generation in three
> > places, and identifying which of these is causing the miscompilation
> > issue for gnat will help narrow down the problem, or worst case allow
> > reverting less of the problematic patch.
> 
> I just tried this on i386-pc-solaris2.11: unfortunately, it made no
difference.

Awesome!  Very many thanks for trying this.  Alas it confirms that the patch
I'm currently spinning won't have any affect.  So by a process of
elimination,
the miscompilation must be triggered by one of the other two changes:

diff --git a/gcc/expr.cc b/gcc/expr.cc
index fb062dc..37f1405 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -4871,7 +4871,7 @@ emit_push_insn (rtx x, machine_mode mode, tree type,
rtx s
          /* If source is a constant VAR_DECL with a simple constructor,
              store the constructor to the stack instead of moving it.  */
          const_tree decl;
-         if (partial == 0
+         if (0 && partial == 0
              && MEM_P (xinner)
              && SYMBOL_REF_P (XEXP (xinner, 0))
              && (decl = SYMBOL_REF_DECL (XEXP (xinner, 0))) != NULL_TREE
@@ -10603,7 +10603,7 @@ expand_expr_real_1 (tree exp, rtx target,
machine_mode t
        }
       /* Expand const VAR_DECLs with CONSTRUCTOR initializers that
         have scalar integer modes to a reg via store_constructor.  */
-      if (TREE_READONLY (exp)
+      if (0 && TREE_READONLY (exp)
          && !TREE_SIDE_EFFECTS (exp)
          && (modifier == EXPAND_NORMAL || modifier == EXPAND_STACK_PARM)
          && immediate_const_ctor_p (DECL_INITIAL (exp))


p.s.  I've just set up a build environment on another machine where I'm
using 
GNAT 11.3.1 20220421 (Red Hat 11.3.1-2)
as the bootstrap compiler, but it'll be a few hours before I'm investigating
in
gdb.

Many thanks again for your help.  Sorry again for the
breakage/inconvenience.

Roger
==



  reply	other threads:[~2022-06-06 12:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21 10:49 Roger Sayle
2022-06-05 17:53 ` Andreas Schwab
2022-06-05 20:31   ` Rainer Orth
2022-06-06  8:43     ` Roger Sayle
2022-06-06 11:16       ` Andreas Schwab
2022-06-06 11:23         ` Roger Sayle
2022-06-06 11:44           ` Andreas Schwab
2022-06-06 12:01         ` Rainer Orth
2022-06-06 12:00       ` Rainer Orth
2022-06-06 12:29         ` Roger Sayle [this message]
2022-06-06 15:52           ` Rainer Orth

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='056b01d879a1$1fdccfd0$5f966f70$@nextmovesoftware.com' \
    --to=roger@nextmovesoftware.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    --cc=schwab@linux-m68k.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).