From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E418A3858438; Tue, 27 Sep 2022 19:53:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E418A3858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664308424; bh=jxkui+sbvfhrVB7sa2nfpjZkQ1Ir+C/mpKw51vZ5weI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gpsfLDrokgMYIBy9QPxaUWaGHQzf/fmxM0f+35X203u7qA3LwkPJ+z70k8j5cxHlY +SWxn13U2YYg7bdtvw8GV5aVxccPkET6poNIfm3QfAHH8Wx9nKYbbyWBUs3u56H3r+ MfBfpNHF/eQ1baVaHWqcPwmBuCFKJOeDmRgH9DGo= From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/107050] duplicate load of return value when facing multiple branches Date: Tue, 27 Sep 2022 19:53:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: segher at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107050 --- Comment #2 from Segher Boessenkool --- Splitting blocks in shrink-wrap will cause degraded performance compared to the status quo, on average. If I understand what will be split how, that is? It certainly can be good to move more code, much much more than prepare_shrink_wrap does, but that is a good trade-off most of the time only because it makes the fast path faster, makes less code executed when there is an early return: just randomly moving code to be executed later makes code *slower*. Where shrink-wrapping duplicates code here only one copy is executed, ever. The question seems to really be why at -O1 global variable accesses are not optimised very well? The answer to that is this is -O1, if you want good optimisation you should use -O2!=