From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2947D385802E; Wed, 3 Nov 2021 18:25:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2947D385802E From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102876] GCC fails to use constant initialization even when it knows the value to initialize Date: Wed, 03 Nov 2021 18:25:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to bug_status attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2021 18:25:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102876 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gn= u.org Status|NEW |ASSIGNED --- Comment #15 from Jakub Jelinek --- Created attachment 51731 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51731&action=3Dedit gcc12-pr102876.patch Untested implementation of the optimization. So far a little bit limited, either it handles initialization of the whole = var at once (usually scalar vars), or uses native_{encode,interpret}* infrastructure and in that case it can't handle unions or anything that needs relocations = in the initializers. I guess in some cases it could be improved, but especial= ly unions can be harder or very hard if the access path is not visible in the stores.=