From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0690A3858D33; Sun, 19 Nov 2023 15:14:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0690A3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700406881; bh=eEfLlYtRcVsUD8zoFgyAduc8A14XGHkWalzkehggfAk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s/VVr33/vLBXQgB48eOd4DqLz+cdrHRfVj5RLn2WmLqvI4zQNtAwpaJFQAVQUgdLc UCPWFOOKY23d8i9B6xuRiEXI2fLsv5i7XF8ZAxFr36X0zT67xD+0VA9yWqE46tUSD6 tZ9MEcBqzeHBaeOSGOh5Gbm7tZkI3Linshx3lQcA= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110287] _M_check_len is expensive Date: Sun, 19 Nov 2023 15:14:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org 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=3D110287 --- Comment #8 from Jan Hubicka --- With return value range propagation https://gcc.gnu.org/pipermail/gcc-patches/2023-November/637265.html reduces --param max-inline-insns-auto needed for _M_realloc_insert to be inlined on my testcase from 39 to 35. This is done by eliminating two unnecesary trow calls by propagating fact t= hat check_len does not return incredibly large values. Default inline limit at -O3 is 30, so we are not that far and I think we re= ally ought to solve this for next release since push_back is such a common case. Is it known that check_len can not return 0 in this situation? Adding=20 if (ret <=3D 0) __builtin_unreachable saves another 2 instructions because _M_realloc_insert otherwise contain a = code path for case that vector gets increased to 0 elements.=