From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 9978E3858416 for ; Thu, 21 Oct 2021 23:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9978E3858416 Received: by mail-pf1-x42b.google.com with SMTP id f11so2026174pfc.12 for ; Thu, 21 Oct 2021 16:45:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cgUsKvTZh0WLLP66zOxvYAhvoY+zs/PneSge0q7DaXE=; b=LA+GoL533KLdMd3y48DHHGIeCYcS4S/lXKtJu6+iOQCVF2uy6eIttRvlw+QfDZcqtW DL1fT9ksHsEZs4pFoCnNN+mChWuLlZFbM81mNAbeu/SVEEorK61+3FqZ+yof+L5TVUy2 wBr47kNVQO8YX+HTc0rG0YnFCrXwpfbCb6LAaH8vNIbMNImcyWyGtKZd77Jrs/i4TBKC A2x2f4V+2YKT8G3w/bJFeGqiGuoXF16lKglZjtJdKqrgaVDIcz7xF1mTyGlr+J6dI8n1 YAMWXeFCbvHXzYv1jPPbXZyCOJxugl+H1cwQcI+XHwyiT9a1ikDX9nIrDwJ6a2CBsGh/ L7WA== X-Gm-Message-State: AOAM531jF5AM3ihPgvFBUJXzITFdPP1t22u98HdnA9UhX0HdW29V/Kry 0FcqW8DslL7oL0TOYF0npTGYoAlRnSGMZ3OYVZQ= X-Google-Smtp-Source: ABdhPJx8bWMC3ou+xGJaa6lTweYI8DoCTg1XiylZT3K+yt17BYjPysD+Jn8VHKSb8FatJiMjVnUkQxBrVp9mvZeUWQM= X-Received: by 2002:aa7:8b1a:0:b0:44d:37c7:dbb6 with SMTP id f26-20020aa78b1a000000b0044d37c7dbb6mr9226735pfd.11.1634859916785; Thu, 21 Oct 2021 16:45:16 -0700 (PDT) MIME-Version: 1.0 References: <20210927203827.2852935-1-goldstein.w.n@gmail.com> <20211021223850.415607-1-goldstein.w.n@gmail.com> <20211021223850.415607-2-goldstein.w.n@gmail.com> In-Reply-To: From: Noah Goldstein Date: Thu, 21 Oct 2021 18:45:06 -0500 Message-ID: Subject: Re: [PATCH v8 2/3] String: Add hidden defs for __memcmpeq() to enable internal usage To: Joseph Myers Cc: "H.J. Lu" , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2021 23:45:18 -0000 On Thu, Oct 21, 2021 at 6:39 PM Noah Goldstein wrote: > > On Thu, Oct 21, 2021 at 6:15 PM Joseph Myers wrote: > > > > On Thu, 21 Oct 2021, H.J. Lu via Libc-alpha wrote: > > > > > On Thu, Oct 21, 2021 at 4:08 PM Joseph Myers wrote: > > > > > > > > On Thu, 21 Oct 2021, H.J. Lu via Libc-alpha wrote: > > > > > > > > > There are many memcmp calls in ld.so. I think most, if not all, of them > > > > > can be changed to __memcmpeq. Can you make another patch to do > > > > > that? > > > > > > > > Rather than doing that micro-optimization in the glibc sources, I think > > > > it's better to add the relevant feature to GCC and let glibc get optimized > > > > when built with a new-enough compiler. > > > > > > Why not? We don't know when __memcmpeq will be supported by GCC > > > used by glibc developers. If we don't even use it in glibc, why bother? > > > > The point of this function is entirely for compilers to generate for calls > > from memcmp, not for humans to write direct calls to. > > > > The compiler knows other semantics of memcmp (it might sometimes expand a > > memcmp with a small fixed size inline, for example). So changing to a > > direct call to __memcmpeq by hand isn't even always an optimization; Will compilers not implement the same optimization for __memcmpeq? > it > > seems better to leave the semantics visible to the compiler. Note that in > > other cases we've generally moved *towards* relying on built-in functions > > rather than having our own local inline expansions of those or calls to > > internal names for those functions (we've done that for calls to various > > functions in libm, for example). > > I have gone through all non-test .c files in GLIBC and replaced memcmp > with __memcmpeq where it makes sense. I can post that as a separate > patchset and we can decide whether it's a good idea there. > > > > > -- > > Joseph S. Myers > > joseph@codesourcery.com