Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1850204pxp; Thu, 17 Mar 2022 19:15:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkJL7hUs5BIa41ViLzgPsLO5mjoCnZeF2UM9aJyq2WW0HvlPkdpNzludzNFsN952OIvwiA X-Received: by 2002:a17:903:110d:b0:14d:85b2:4b36 with SMTP id n13-20020a170903110d00b0014d85b24b36mr7963996plh.75.1647569704363; Thu, 17 Mar 2022 19:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647569704; cv=none; d=google.com; s=arc-20160816; b=woui5poEvFBJnLTMjOpeFmdJO60SGP/+YkM4feGIZ4A0B/hnmjp1rQAvtOCVJtgn0a TEVx7sofaTzdOycInhirdMRjwa3khxGBLgxSc9o3TzVXRqXujnbnLL65p5MODtRiqERT 0Ppj8uh3Z74Dx2U9MIqCp+iUbA11tswnwokvvXr8d5S4ZAjQ7AyeFIfwOG0LYp4apOcR R+xn3NqXhQoXtYszSwCS6lb6mj/ss3i+9xQmlV0QsmvrH9VA4HsUA0l8Eq67NcJH3G18 jOjEONW+gk4guf9P8LibuE27MosU8oY+26PC9AfYcMXzy5AyqD0I+jm6cIkQgk0yjyfT Kt0A== 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=b/pNbzgcdYJjSh+ACj0n1pQjCDJGCCGjloF/JdGNGSo=; b=TX57IMAt0l9GAY8jmmrDW0EYMDy3/5uXpWhT7uOY8NJ27bxVNjK1K7GKen1q34y2sW FgeivW2jn+/yer9Fd7Hh3HW4otycXppcWJxHYZQdn5X99oy6hIL/u/pca+AApzrhQ05p Dtc+SjXgnT9GdZCtZJrV8wix7A2X/7aRUTo36tvDnWKobFoF2goMCCqRHxO9AOuOgpA4 MxDC2DsKgJFU8e5a6HvDJJ+/4C2GivFX7AzEnqRZZasQiWZ0/0pYhs/xVhJM2kWr/Pz2 r2b+rHzIxJxmGiU340lPq9ZyNLvbKixGoc/xxjnxXm9X6U5iHRLA8ILVCOK5c6cS7PQp uImA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dTK+uo+J; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a1709029f8800b00153b2d1661csi742158plq.548.2022.03.17.19.14.50; Thu, 17 Mar 2022 19:15:04 -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=@linux-foundation.org header.s=google header.b=dTK+uo+J; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbiCRBXG (ORCPT + 99 others); Thu, 17 Mar 2022 21:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbiCRBXF (ORCPT ); Thu, 17 Mar 2022 21:23:05 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F8902A4564 for ; Thu, 17 Mar 2022 18:21:47 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id s25so9513713lji.5 for ; Thu, 17 Mar 2022 18:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b/pNbzgcdYJjSh+ACj0n1pQjCDJGCCGjloF/JdGNGSo=; b=dTK+uo+Jz568eICd2gFrkZaobtquyTLeKqTZIsWeFh8G+SUpzTGAJXhBoZXX4qGMFK OeEsQc3mooLTyuDiZs/fiz3l75SR99l/LHN+ZhVgwUnB9r+RMj/zfPEEFAsUtSaKjGEx 7NDWm4uqPJjO5ZFjWHOgeB/nPhAXtIogQJuf0= 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=b/pNbzgcdYJjSh+ACj0n1pQjCDJGCCGjloF/JdGNGSo=; b=F07oB85iP270Y+DOUONdiHq28TLp7wT6rjxYYcPNZdZwYju0X7n7yvIuKsoTwhul/1 /7IkgU5wwjxpKtTwpXILpNXWMwTyKSfCAXJ0O0CTrMv7LM/JlSou2po5uheJGvNsGTLw 40ZkTSDWbaGGJ0PnXwpqXbB0Mc5ZD1bW7cj52RGEdm8gf6KyFttpHXti7OLhk8a6Dhx+ w7k53ETSC7NmmSqEEmfwe4RqzI6mArLMKOrfIwYsSN5h2o4Tex/hzVEk6lMMWNSpXiqu 2Br27SqAF4/u3rFscbG7jD+4W/ByekAwpfWjQqJxZVdOCw1wsvt9/pabhj+ZQvXTOVQ6 f30w== X-Gm-Message-State: AOAM530SvFDS0uDG4hYY0NRRE5srC6kCJ4wvMI1xgOjn2yzWYAHa7JtL WdcEyBXFnbx7J7Sm59E0DlkCiBKepN2XhrbF2sQ= X-Received: by 2002:a2e:2a45:0:b0:246:430d:805 with SMTP id q66-20020a2e2a45000000b00246430d0805mr4732594ljq.439.1647566505647; Thu, 17 Mar 2022 18:21:45 -0700 (PDT) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com. [209.85.208.175]) by smtp.gmail.com with ESMTPSA id i4-20020a2ea224000000b002496423e49asm335663ljm.95.2022.03.17.18.21.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 18:21:44 -0700 (PDT) Received: by mail-lj1-f175.google.com with SMTP id c15so9483616ljr.9 for ; Thu, 17 Mar 2022 18:21:42 -0700 (PDT) X-Received: by 2002:a2e:9b10:0:b0:247:f28c:ffd3 with SMTP id u16-20020a2e9b10000000b00247f28cffd3mr4728907lji.152.1647566502600; Thu, 17 Mar 2022 18:21:42 -0700 (PDT) MIME-Version: 1.0 References: <20220210223134.233757-1-morbo@google.com> <20220301201903.4113977-1-morbo@google.com> <878rt8gwxa.fsf@oldenburg.str.redhat.com> <20220318002555.GP614@gate.crashing.org> In-Reply-To: <20220318002555.GP614@gate.crashing.org> From: Linus Torvalds Date: Thu, 17 Mar 2022 18:21:26 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] x86: use builtins to read eflags To: Segher Boessenkool Cc: Florian Weimer , Nick Desaulniers , "H. Peter Anvin" , Bill Wendling , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Nathan Chancellor , Juergen Gross , Peter Zijlstra , Andy Lutomirski , llvm@lists.linux.dev, LKML , linux-toolchains Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Mar 17, 2022 at 5:31 PM Segher Boessenkool wrote: > > On Thu, Mar 17, 2022 at 01:36:19PM -0700, Linus Torvalds wrote: > > > > So yes, a builtin can improve code generation. > > Yes, and they are much easier to write, and can be written correctly by > lookenspeepers who just *have* to twist every knob that they can -- more > easily than inline asm anyway, which is unforgiving to the extreme. What? They aren't easier for the user: they are entirely undocumented, they can't be fvound anywhere sane, and even if you do find them, you don't actually have a clue which compiler version implements them. If you know about the name - and how would you? - one of the first google hits when you try to figure out what it does is the gcc bugzilla about how they are undocumented: https://gcc.gnu.org/bugzilla//show_bug.cgi?id=92137 and then when you look at that bugzilla, the reply to the "it's undocumented" is _literally_ "You shouldn't use those, they are for internal use only. That's the reason they are not documented" so I call BS on them being "easier to write". I also call BS on the "can be written correctly", since the actual gcc built-in is not just undocumented, it is also (a) badly defined in that there is no chance in hell it can ever do anything sane thanks to missing serialization definitions, and (b) clearly seriously buggy and generates completely bogus code as Andrew Cooper found out. Now, compare that to just using inline asm: it's trivial, and we've used it basically unchanged for three decades. So seriously: when I say "yes, a builtin can improve code generation", I mean it purely in the theoretical sense. Because in the *practical* sense that actually takes reality into account, I can unequivocally say that the built-in is pure and utter garbage, should never be used, and should actively be deleted from the gcc source base because it's so fundamentally broken. Do you really want to make arguments that are counter-factual when the facts are *this* clear? Linus