From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id A99C43858D3C for ; Wed, 9 Feb 2022 00:07:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A99C43858D3C Received: by mail-pj1-x102f.google.com with SMTP id t4-20020a17090a510400b001b8c4a6cd5dso566649pjh.5 for ; Tue, 08 Feb 2022 16:07:36 -0800 (PST) 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=hNhMCqWxS2mz8+SwUvrechwNbIQMu9yWIL1O6D0Eg0Y=; b=Hj576lqN7JyGgviYbOSZefz2j8g9gARCXBebg4ES4NPqj6d5zemU/1AZxNmNaf8koO P8e3XWBMWiIzPe/rpiQtg9+Ons7jbcSzBdtFs07Q9QX4iHtNEmSfFOFJB089WM8Kvm/G Bt8BtaXqjt9doi8O79G71IJuJ+9gfJy7m3PPcBYg/A6osWaOa7CyJuMKSYh8vd/crf9A 5Wq6PsF9Lzn/w7Rh4cq6/HAHGb7/cfV/eVdautTAfATb7vimIPUCcY2WB7Jvl/xJy36W tAsxTOwGmuWq7hCFPIF0edP4TamCVNs7WUW3fDiYJKJR0dC+JbCCmd1babqMlFeA9LK7 tOiA== X-Gm-Message-State: AOAM532tV9tpfrzS5luiNC4JkueMQStpZab/cJ4wTcIi6I/P5wgRgHWG VB2CgaSc0QxdDerc7CsULIs49pMlm0LmQf47e9Y= X-Google-Smtp-Source: ABdhPJzbkcDM66xBrLcUyS2lHq77KH4t+12P72GbvfvNW1x0LSlu8wC9Nc4R7KAHbDuPzazQo4Kj9e77wVCLS6HV+PM= X-Received: by 2002:a17:902:ec81:: with SMTP id x1mr6696135plg.109.1644365255607; Tue, 08 Feb 2022 16:07:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Noah Goldstein Date: Tue, 8 Feb 2022 18:07:24 -0600 Message-ID: Subject: Re: [PATCH] elf: Replace memcmp with __memcmpeq for variable size To: Adhemerval Zanella Cc: Wilco Dijkstra , "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, T_SCC_BODY_TEXT_LINE 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: Wed, 09 Feb 2022 00:07:38 -0000 On Tue, Feb 8, 2022 at 5:00 PM Adhemerval Zanella via Libc-alpha wrote: > > > > On 08/02/2022 19:30, Wilco Dijkstra via Libc-alpha wrote: > > Hi, > > > >>> My understanding is this optimization would eventually be implemented by > >> > >> What kinds of codes should compilers generate? For glibc internal > >> usage, we can write codes in such a way that the generated codes > >> are very similar to what compilers should generate. > >> > >>> the compiler, so maybe it would be better to let it optimize if suitable > >>> (similar to what we are aiming for math code). > > > > I agree with Joseph that these kind of micro-optimizations are generally counter productive - > > we've removed many similar hacks from math libraries resulting in good speedups (they > > almost always work against you, blocking compiler optimizations such as inlining, constant > > propagation etc). It's much better to improve code via algorithm or implementation > > optimizations rather than focus on these micro-optimizations. > > > > As mentioned, codesize will increase since many applications now use both memcmp and > > __memcmpeq, and the extra I-cache misses may wipe out any savings. I think the I-cache usage increase is only when '__memcmpeq' is partially implemented. In many applications 'memcmp' can be entirely replaced with '__memcmpeq' and '__memcmpeq' has a lower I-cache footprint than 'memcmp'. Although agree its best to get this into GCC. > > This was also mine and Florian's view on this specific optimization back > on Monday's call.