From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 000C93858C62 for ; Thu, 8 Jun 2023 09:14:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 000C93858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686215645; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=5/wnvr2mexDyt5r/x4WrXcS0d29NoOu2F8SoucpG1Xc=; b=G5DKF9K5LJDY8+35xm2LxZeNxru6tgPGTvulTZBtisr/Dqh1pII7EwElLMNx7Q10lUYLUF Wn79aD7A6MndAxCM0Sd7PgECzkHOs8nu3B2aVzaSaCnHi4j+NN/ICOmqAL3/iltTId6Rhj RnVNpQYbPcnuvUpuaVj2/8SI8FoieTw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-5-WSF5dEDuPW2CDfVwchjSHA-1; Thu, 08 Jun 2023 05:14:04 -0400 X-MC-Unique: WSF5dEDuPW2CDfVwchjSHA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFE8B1C07563; Thu, 8 Jun 2023 09:14:03 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 717869E8D; Thu, 8 Jun 2023 09:14:03 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3589E04B3608506 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 8 Jun 2023 11:14:00 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3589DxIN3608505; Thu, 8 Jun 2023 11:13:59 +0200 Date: Thu, 8 Jun 2023 11:13:59 +0200 From: Jakub Jelinek To: Jonathan Wakely , Jan Hubicka Cc: Maxim Kuvyrkov , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Fix code size regressions in std::vector [PR110060] Message-ID: Reply-To: Jakub Jelinek References: <20230601150958.268109-1-jwakely@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Jun 08, 2023 at 10:05:43AM +0100, Jonathan Wakely via Gcc-patches wrote: > > Looking at assembly, one of the differences I see is that the "after" > > version has calls to realloc_insert(), while "before" version seems to have > > them inlined [2]. > > > > [1] > > https://git.linaro.org/toolchain/ci/interesting-commits.git/tree/gcc/sha1/b7b255e77a271974479c34d1db3daafc04b920bc/tcwg_bmk-code_size-cpu2017fast/status.txt > > > > > I find it annoying that adding `if (n < sz) __builtin_unreachable()` seems > to affect the size estimates for the function, and so perturbs inlining > decisions. That code shouldn't add any actual instructions, so shouldn't > affect size estimates. > > I mentioned this in a meeting last week and Jason suggested checking > whether using __builtin_assume has the same undesirable consequences, so I We don't support __builtin_assume (intentionally), if you mean [[assume(n>=sz)]], then because n >= sz doesn't have side-effects, it will be lowered to exactly that if (n < sz) __builtin_unreachable(); - you can look at -fdump-tree-all to confirm that. I agree that the inliner should ignore if (comparison) __builtin_unreachable(); from costs estimation. And inliner should ignore what we emit for [[assume()]] if there are side-effects. CCing Honza. Jakub