Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp768160iob; Thu, 12 May 2022 04:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw6W9I7LFRG8XaE+qH1MA/40xA1QTQ+YNJjN5p1Zfz7ObHK83JBxNmA2MauWzoOEzOYW1+ X-Received: by 2002:a17:907:72c5:b0:6f4:678:8742 with SMTP id du5-20020a17090772c500b006f406788742mr29952043ejc.607.1652354569725; Thu, 12 May 2022 04:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652354569; cv=none; d=google.com; s=arc-20160816; b=ZJS8MzmIv6DDid1dOBHsgRkOlCVcOdB3UPNSR3oV8iFxYnEY6qT2WsCyEM+vx8JqUq pVeDSLUuF3hZCIoUPa+B8AHQqC68XAi4nYpVrRDa5WCfc3PshsHnw/bIZ1pBVUpt/D0X iR24hWzlSUkq+UjhzK5WIgwm/rOU+dXT1KuRfHhI9QRSgIsnF6WVTbiGWbsNzLpK1+/N flalL4nwHfYK8hyq0OV0IdFz+KmuwGHERXlMQWAWOXrbrhIHX86/KnwLxDSg064pCvtY ah5BbiirH3pV9iy63E1RkV4yN97pw1hSdGUdgkNt5KeBS4EZu/fv1wfmlBNus7Gy7f5c Kqzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=c2ws23UBcUn/cg2bNLq1AZlNJZpHLdEd3cBqMWxwPHE=; b=Pr77kVGh+xXMag7G6Wsbs1aLwF2zRWMj/Ou+CDgi7ITNiePFfLT70eYk38gBzccfcz Jqt8JsNeocURkLUy6yjfC0eSJKWbahR1K+gk0FyZse17X1d0BByx5Kg6qBqjfmU/mO1u yvSgQR3YrxMgNuK+VkaJPdFwFaAX9C6udxuZp8Ku3wAGuksupsqn95N80Mty/CwlskVs L1BcrfHYTvqTl+xmDczVsSTBLODJESbzGFSZ8tYq2uoZET6QLpzhkUqK6CDql5e6Y+EQ HeXjFzENjAgMlGE8pszmovbiAXANjTzWH4bL3TZF73DERodOZ1VtUlmCei0Prgh55M1I j9eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ImISWlaf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du13-20020a17090772cd00b006f4da4e73e9si6432496ejc.490.2022.05.12.04.22.23; Thu, 12 May 2022 04:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ImISWlaf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349647AbiELA2W (ORCPT + 99 others); Wed, 11 May 2022 20:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349641AbiELA2V (ORCPT ); Wed, 11 May 2022 20:28:21 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1A4F18C06D for ; Wed, 11 May 2022 17:28:20 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id p10so6271356lfa.12 for ; Wed, 11 May 2022 17:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c2ws23UBcUn/cg2bNLq1AZlNJZpHLdEd3cBqMWxwPHE=; b=ImISWlaf/fsowhzZ+LUJhuc8wWq73oxuQdC8Jg+B/b6IgYMhQ+3HwaaCLhndMaU1x7 EuPSVxwcUYtxvoBKntk8Y2fvl4eouOdlxJiJMNqn8wY4VRZQ6OUOYpvY+t0N9xeqONMh KNJ+Tlr63HkniBbjUvrauMRJxeLp/M/HN/hyFZCgFxYcwFWXO7/GPoCvm166Eqg/xygR 3o7vQxh9/hgWog03zMK4N+VacdMrpJ8oqnjmQS3Y+b5uuxIl806in1JBQRCIBenaKuV6 lp7MArZYE5UiHGzCLgLeUxhVrq8O7wFXBKuvFuhER5KXbI1LYd5DY/gh+zzz3O7hVges 0gmg== 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=c2ws23UBcUn/cg2bNLq1AZlNJZpHLdEd3cBqMWxwPHE=; b=WddMhxVad7XRHQO1XOZeUj7rnw1GHiTsRiW2qSV9P57z+M/zsk5gzMzW8tQCEm4WvJ P6dJR1Km8f/VbGRHBmhQ+Hfm8xZQgaEAmy8nRLb1b7OkaV3Ui68948C295EYNDaHBfP1 RaVS7+LnqFh3DwUdpr7kTtun57/E+I4RbzXzh4hhOZawQSgZE+gyTDmum8ABwdj97s14 7kx5/uc2f8zn+7sBWs2CD7r3zwBlLNITw9lYA3wUfDg2Kf5PynnvAU5k/5OOphxpsBpy xQxPci8nWP8M4qazte+IMVLa6j/ncqUoVXajnmyWc9zCuf9rh6EaO/AUspevKmeoZ0oR fjew== X-Gm-Message-State: AOAM530Ucv1gr4Iu9olt2OnwqFJZx6UTZ27/69yTvTmv39fNYQ1tYVqo OCS/7U6sFWJtHac4ah8t4qhLlhCEFHvaeeJRogptJg== X-Received: by 2002:ac2:5e86:0:b0:473:d044:60f5 with SMTP id b6-20020ac25e86000000b00473d04460f5mr22047290lfq.87.1652315298341; Wed, 11 May 2022 17:28:18 -0700 (PDT) MIME-Version: 1.0 References: <20220511160319.1045812-1-mailhol.vincent@wanadoo.fr> <20220512000340.1171988-1-mailhol.vincent@wanadoo.fr> <20220512000340.1171988-2-mailhol.vincent@wanadoo.fr> In-Reply-To: <20220512000340.1171988-2-mailhol.vincent@wanadoo.fr> From: Nick Desaulniers Date: Wed, 11 May 2022 17:28:06 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] x86/asm/bitops: ffs: use __builtin_ffs to evaluate constant expressions To: Vincent Mailhol Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Nathan Chancellor , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, David Howells , Jan Beulich Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 11, 2022 at 5:04 PM Vincent Mailhol wrote: > > And finally, Nick Desaulniers pointed out in [2] that this also fixes > a constant propagation missed-optimization in clang. > > [2] https://lore.kernel.org/all/CAKwvOdnH_gYv4qRN9pKY7jNTQK95xNeH1w1KZJJmvCkh8xJLBg@mail.gmail.com/ Regarding https://github.com/llvm/llvm-project/issues/55394 it seems that functions with static linkage cannot be considered library functions, so libcall optimization will not run on calls to them. So the compiler might be able to do a better job for constants if ffs() and friends indeed were not defined in a header as static inline. But that relies on the compiler knowing these tricks; I think the kernel's approach is just fine (better in fact, because we should inline these tiny functions, regardless of LTO), but like this series shows, there may be room for improvement for other functions within the kernel that are defined as static inline in headers that are normally found in a libc. So I no longer think there's a missed optimization here, but at this point, it's not worth a respin of the series IMO to just let sleeping dogs lie. Unless the x86 maintainers wouldn't mind dropping that line and link when applying? -- Thanks, ~Nick Desaulniers