From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 7CF613858283 for ; Mon, 6 Jun 2022 12:29:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CF613858283 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:In-Reply-To:References:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UOsDPIA+QXHgh5VRPXnCuznB+gyKe/AyCYFNj4/Udz4=; b=frSJ94koeTuEhnPyOm7d4kayTP 8Uys8rfSeG9WjItIbbqUovur6qc4PVOk5hQZZN7OccqTgKEFkLeMbqFz5nDkgXa+S4wPkiFpMKg8B iU24uNzGQLRTHe6Jq1H0mxDbEDhUYZOGNY/g37Ty5XCTHDI+BpgHz94pxG17aksgBSi3Qd1J0XhT6 UzguDU7rxnLRy9JkdMsP43UlLnGIm8HW/90hEWiB4tr8MNa8fEdFqdL1F2j8Pbly62pnhHIOHUBL5 ND1LyWqcfmX9FBKk4qIBTFOcga3eSRzCkn1+RJbtzTYyGyyoU61hKPO39f/b8dMU6wxxI5smTll5m 8btxh01Q==; Received: from host109-154-46-241.range109-154.btcentralplus.com ([109.154.46.241]:61449 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyBrl-0003jV-Rs; Mon, 06 Jun 2022 08:29:54 -0400 From: "Roger Sayle" To: "'Rainer Orth'" Cc: "'Andreas Schwab'" , References: <006d01d86d00$777e67b0$667b3710$@nextmovesoftware.com> <87czfnf148.fsf@igel.home> <036701d87981$91cc3150$b56493f0$@nextmovesoftware.com> In-Reply-To: Subject: RE: [PING] PR middle-end/95126: Expand small const structs as immediate constants Date: Mon, 6 Jun 2022 13:29:50 +0100 Message-ID: <056b01d879a1$1fdccfd0$5f966f70$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQFKZNjlC43PO33zIc40lF+0g/eoaAFx8oHTAjXHSaQCVMGoawI06EgyrhzqSTA= Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2022 12:29:55 -0000 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 ==