From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 07AFC3858C33 for ; Thu, 25 Aug 2022 05:52:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07AFC3858C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr Received: by mail-lj1-x236.google.com with SMTP id x10so18400259ljq.4 for ; Wed, 24 Aug 2022 22:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=Ask8e745a4LZp3RGEPfiM+QHUaCkGoz5LZ/lJJQjBwg=; b=3YHaw1uDAPLMXGYSD+NJ6Og3DKqyLbJJ+Rx/zLzGpVbw5EFvwq0t4qLZ4nGxAdDQKA rWAN/WRTGxfc7R4E9Ld3Y4cf5NJ6yEm9PAEdvqkDYYF+A5lalg2SuePzvNGhljyYTsCS dmQUxDVPSXaAGZNlPP3APD8XLxlC4UKCTinWa3BqJd0PQ7OO45DvVZF/2Q+rMaWjBDGf 0eJDxvAqHjXzyUWahVhlRhIrN3vy1BYqcYgCKNFj1azbdMWrFZC8gTeuyKUusyyMFCs4 br6r/pr+a3XSAZbhbeiQdsXBdsr2q9FadBi5QfFTu6ct2S1vwA4MBcfN2prxmK7tfOa+ 9O2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=Ask8e745a4LZp3RGEPfiM+QHUaCkGoz5LZ/lJJQjBwg=; b=YjD9MIsPqZtvvitfIMk5OcHKRG+V9NcBq3A59gFDhxzZSZbzYNkteqIEcrZ0xwx+T8 fzLWn2w/PRg7zf6RouCR3Qcb8NrBBIUWOhH4226DUuGqZU6PKqCkdjmOmmNslKoAsIL7 qBDXm4yaB9LphcrvYBFKv6aNs6C6rFqmp7+kW8lfR2spkgCgLuPY9wJXZch2KQ9W8mHR M4xLvsUq6sCIkZ8knqX//X1TU8g6XUqk4e9UoM4eeNypICnQy4EMwULGR4FV3+st+2nk j6+R/mJi/kVxcNhgqUyD78Rid2cwotHnPGZCQ7euXVGMDbennBTK0O4hzCYNJx+gUqQP geXw== X-Gm-Message-State: ACgBeo09NiJLbgVQgzt0auY4DeY74G+bkZBw2gxMxzDjavwyN1Mv012w YaHK8Ycdj6VMhTSv+OkDMqWP+g7vgiDiCW93uAr2BA== X-Google-Smtp-Source: AA6agR4G/HFqeuHLBFfbgDZWH0/d5jhEga1wxHVVuRG0jOw5nb1RUP4TzasQqjIxn7Fkh4QQVFrHNla7WhDBavD1a2g= X-Received: by 2002:a2e:a4b6:0:b0:261:e290:257d with SMTP id g22-20020a2ea4b6000000b00261e290257dmr566584ljm.140.1661406739468; Wed, 24 Aug 2022 22:52:19 -0700 (PDT) MIME-Version: 1.0 References: <20220822181509.1032874-2-whh8b@obs.cr> <20220824061648.1119635-1-whh8b@obs.cr> <20220824061648.1119635-2-whh8b@obs.cr> In-Reply-To: From: Will Hawkins Date: Thu, 25 Aug 2022 01:52:08 -0400 Message-ID: Subject: Re: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally To: Jonathan Wakely Cc: Alexandre Oliva , Jonathan Wakely via Gcc-patches , libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,KAM_SHORT,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 Wed, Aug 24, 2022 at 7:03 PM Jonathan Wakely wrote: > > On Wed, 24 Aug 2022 at 23:47, Jonathan Wakely wrote: > > > > On Wed, 24 Aug 2022 at 23:39, Alexandre Oliva wrote: > > > > > > On Aug 24, 2022, Jonathan Wakely via Gcc-patches wrote: > > > > > > > * include/bits/basic_string.h (operator+(const string&, > > > > const char*)): > > > > Remove naive implementation. > > > > * include/bits/basic_string.tcc (operator+(const string&, > > > > const char*)): > > > > Add single-allocation implementation. > > > > > > ISTM this requires the following additional tweak: > > > > > > diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc > > > index bfae6d902a1dd..2ec0e9d85f947 100644 > > > --- a/libstdc++-v3/src/c++11/string-inst.cc > > > +++ b/libstdc++-v3/src/c++11/string-inst.cc > > > @@ -58,6 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > > > > > template class basic_string; > > > template S operator+(const C*, const S&); > > > + template S operator+(const S&, const C*); > > > template S operator+(C, const S&); > > > template S operator+(const S&, const S&); > > > I realize that I should have noticed that asymmetry as well. Sorry! > > > > > > Without this, I'm getting undefined references to this specialization in > > > libstdc++.so, that I tracked down to a std::system_error ctor in > > > cxx11-ios_failure.o. I got this while testing another patch that might > > > be the reason why the template instantiation doesn't get inlined, but... > > > we can't depend on its being inlined, can we? > > > > Right. But adding that will cause another symbol to be exported, > > probably with the wrong symbol version. > > Oh, but those symbols aren't exported ... they're just needed because > we compile with -fno-implicit-templatesand other symbols in > libstdc++.so require them. > > So that probably is the right fix. I have another change for operator+ > in mind now anyway, which optimizes operator(const string&, char) the > same way, and removes the duplication in those five operator+ > overloads. Let me know if/how I can help. Will > > > > > To fix https://gcc.gnu.org/PR106735 I'm just going to revert it for > > now, and revisit in the morning. >