From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 81DC73858D3C; Wed, 29 Dec 2021 20:30:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81DC73858D3C From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/103860] [9/10/11/12 Regression] wrong code at -O3 with -fPIC on x86_64-linux-gnu Date: Wed, 29 Dec 2021 20:30:41 +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.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: segher 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: 9.5 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 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, 29 Dec 2021 20:30:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103860 --- Comment #7 from Segher Boessenkool --- (In reply to Jakub Jelinek from comment #6) > Created attachment 52089 [details] > gcc12-pr103860.patch >=20 > Not sure I understand what you'd like to see. Exactly what you did :-) Well, I didn't see you could fold it all up like that, wow. > But, thinking more about it, we can easily avoid all the code duplication= by > moving the vec.is_empty () test out of the while loop condition, right > before we pop from the stack. That way this can_get_prologue check is do= ne > on pro not just before we pop something from the stack, but also after the > last iteration > when there is nothing further on the stack. Yup. > If we wanted to avoid calling can_get_prologue that often (if pro doesn't > change we call it again and again already before my patch), we could also > add a var to hold the last pro we've successfully checked and only do this > checking if we get a new pro. How can pro not change? It is important that can_get_prologue is called at most once for every block, so that this is O(n) for every function (in numb= er of edges in this case). All of this is linear, I'd like to keep it that wa= y!=