From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5726F3891B6A; Sat, 17 Dec 2022 23:47:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5726F3891B6A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671320849; bh=EeJGQ9tvImWCwv+sDvfo6dclDSoq66s2+P2Gs7SSvnk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qEPeo0m4hmQOaQ8QH0T4Y8gMAf408dvwWvfqWr3iK/phKTDh/fEs9co7x8FveC6AC 6DWLFqxPpWgcHyAOY0w2UO9rvS0an9jP+ncxxnFIOC0zR2lWiuOfclAYmtKvo9Olz7 8VeHGdw9fbf92cIP7lJYouvzMAPvlDpWuoS23oHA= From: "levo.delellis at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108162] Missed optimization opportunity. Complex function that starts with if (param == 0) return 0; Date: Sat, 17 Dec 2022 23:47:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: levo.delellis at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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=3D108162 --- Comment #3 from Levo DeLellis --- (In reply to Andrew Pinski from comment #2) > Round 4 is because of this heuriheuristics. Name the function something > besides main and try again. I couldn't reproduce. fn has more than xor eax/ret. godbolt shows the same. x86-64 12.2 https://gcc.godbolt.org/z/WdacrE788 #include int fn() { std::vector v; v.push_back(1000); return 0; } int main(int argc, char *argv[]) { fn(); } 0000000000001160 <_Z2fnv>: 1160: 48 83 ec 08 sub rsp,0x8 1164: bf 04 00 00 00 mov edi,0x4 1169: e8 c2 fe ff ff call 1030 <_Znwm@plt> 116e: be 04 00 00 00 mov esi,0x4 1173: 48 89 c7 mov rdi,rax 1176: c7 00 e8 03 00 00 mov DWORD PTR [rax],0x3e8 117c: e8 bf fe ff ff call 1040 <_ZdlPvm@plt> 1181: 31 c0 xor eax,eax 1183: 48 83 c4 08 add rsp,0x8 1187: c3 ret=