Received: by 10.213.65.68 with SMTP id h4csp2392536imn; Thu, 5 Apr 2018 14:15:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx49exHOCN8bTZREPwS+RF5BkReYZoWQnInAJZPqR1OyjyAzr9/2sHsPM6HrNVufh0AOTNdfz X-Received: by 10.98.214.218 with SMTP id a87mr18437957pfl.124.1522962924717; Thu, 05 Apr 2018 14:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522962924; cv=none; d=google.com; s=arc-20160816; b=sb7oL6kNOX85LCOS+BUNiGQXvvnNpq1exRYtxllq9/hCN+Ru7zTAQAj4aW4vQOAF0R 7pasw8p0OekJxTTVLuqX2XEpxU2HfUDgW3XPMjhtYaAUw5wyG/bTO+g7xBdP/OSMtdzu 4Zsy+tWDhSS/q7Qt5duamzBjgNxV6zcumdK34+dgKlEOR7iuGnMSNLzyZB8n18ofOb0K qWNd54rTfz0oAay0XKWy4HdL+R5d+3SQ88DdcZ6j57ve4AYvm/y0brBOVgC8vCg5JR6X awa65JABySvIJpd20Z8UJMioy5I8aSQXnRvLIKCBjAyEUzpZFFh3NN5WjGjaZIsHmIIj XVQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=jmScqC1fsWiKnfnDdIrF8ef3DocZ+Z0QNqXKRB+xzuo=; b=xax9NM/gsH/7L5BbRWrrHK9lPw+5Rsqy3dPfghhVoL1F2fEGcMtw/JnCmUeU9fs5DD HvvC61sj/g3QfWnKDEjoV/0JsWfD+k/wpmeI6e7J1ZPmn8pTCb4z1kA88i13CgaGMqCM whDHwgWk3z8X9sWC/ohro3Tsr3TXJWTYkeXNq3R/GsZr2daORBYT4gsrKQKe6Y2A2cET HlC2f4aiyPkCU+n7hhVyO7WPK85ky362+HmaWtjHnpAv8MKjdNTBxBUWGQIjzF5Mkb0v hH5WSXhmowEdEEyavtxUkRTvrTO+ZATbhXYy3vibpcum3+V8nDq3QojUtYzpipfmL+TR CSww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=u808vdmc; dkim=fail header.i=@linux-foundation.org header.s=google header.b=B5wybUn4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si1629389pgc.303.2018.04.05.14.15.10; Thu, 05 Apr 2018 14:15:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=u808vdmc; dkim=fail header.i=@linux-foundation.org header.s=google header.b=B5wybUn4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbeDEVNc (ORCPT + 99 others); Thu, 5 Apr 2018 17:13:32 -0400 Received: from mail-it0-f51.google.com ([209.85.214.51]:51802 "EHLO mail-it0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750726AbeDEVNb (ORCPT ); Thu, 5 Apr 2018 17:13:31 -0400 Received: by mail-it0-f51.google.com with SMTP id b5-v6so4367612itj.1 for ; Thu, 05 Apr 2018 14:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=jmScqC1fsWiKnfnDdIrF8ef3DocZ+Z0QNqXKRB+xzuo=; b=u808vdmcnTTk8qlPnRcNH8Yw8MNk8pzad/RkUNQV40JMB4l+mPVleB3Rb/ri3ne+X+ ZaRXEOmPHdbrOrESroEmnUFiQj9RaCOPXBBQjLls53cn42Xyq20hMn9cOlZcq4K+U+8P MDlNGj1M7IcrOjFTwHOZFURHE36M4QedySw6F3v0T6c6aRhDS92rgnwPeQZiFhO+Xjwi oRior4/UCJv9DutVFSZpJPAxyDflRHYXlolQ+S1yKJA0ItCpynmoV9yAHMHnFL0Tiyvq Qr1LEiJTBs698Fbf6JgjK6v+kBmgd8ZtFV3m2z8MqnHdTnlOy/WYZU5ngFBJZTeSyTAi UB3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=jmScqC1fsWiKnfnDdIrF8ef3DocZ+Z0QNqXKRB+xzuo=; b=B5wybUn4AzNkr60FdHEIaP6R2ifNqLFy2jXtjziZ87bNvCmDJ4iMUcbWr467ieDToO u0yVbluugAJcuzvYQdsRoV+derPKPpD51NOTdGNK7Rd7F27PR5tQYVVeOLeis91GNmmf YSggJLel5ZIABiMGN5gp6coBfj/9oE4BBeFzU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=jmScqC1fsWiKnfnDdIrF8ef3DocZ+Z0QNqXKRB+xzuo=; b=CLn71YOnID32Ni/YQaveCf0vp6CN5ALRwEhWtu/j0vyvNw2rBWVSAisASNlHBTSvlz O+L7nxf18aCV/8WfmgqJqXYlw3ZAjOgBIl8exFSjE9Ghtnm4TcwWrZbZO2GKXL2zGhw1 QHDAddpxlXoQpg27vcX+XVibeR/NnnBGxcVBndx1bqyVIUw9+7moYcxUKVjms+BvRMR8 MHod4udxWD01isTP4/6SwIRQlE8hSXaQgbsd5O/QhVtLMYMpY1cIi9Mu45WUa/kEaqu1 ArS0Bi83Fs981GS/x5Tb1F2fAXt94FTAfMniBkEMwRsotVrRvkFQXGm1qigX1PMoWSvf fleg== X-Gm-Message-State: ALQs6tDs5PbT43+ntHcvphoF21Frlpuqp6FkXZurN0AVm/45lRBiX/nU FqQWycjYHHg0mnhpffsDLQ4cISBB12eZcDroHA8= X-Received: by 2002:a24:5852:: with SMTP id f79-v6mr15706141itb.108.1522962810044; Thu, 05 Apr 2018 14:13:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Thu, 5 Apr 2018 14:13:29 -0700 (PDT) In-Reply-To: References: <20180404093007.GI4082@hirez.programming.kicks-ass.net> <20180404191724.GF87376@google.com> <20180404205848.GG87376@google.com> <20180404214639.GH87376@google.com> <20180404221744.GI87376@google.com> <20180404233111.GJ87376@google.com> <20180405072017.GN4043@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Thu, 5 Apr 2018 14:13:29 -0700 X-Google-Sender-Auth: MwXyxIFgRJCTi2O3eOWli31EboY Message-ID: Subject: Re: [GIT PULL] x86/build changes for v4.17 To: James Y Knight Cc: Peter Zijlstra , Matthias Kaehlcke , Arnd Bergmann , Ingo Molnar , Linux Kernel Mailing List , Thomas Gleixner , Andrew Morton , Chandler Carruth , Stephen Hines , Nick Desaulniers , Kees Cook , Guenter Roeck , Greg Hackmann , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 5, 2018 at 1:51 PM, James Y Knight wrote: > > I had actually meant that the __builtin_constant_p **itself** had to be a > constant expression, not that its *argument* must be an I-C-E for > __builtin_constant_p to return true. I actually really wish that were true, and that it would always be considered an ICE. But it's not, as you also found out. This exact problem is why we had to come up with that crazy alternative test for an actual integer constant expression. > Which means that __builtin_constant_p(v) was _not_ evaluated as an integer > constant expression by GCC. Instead, it was left as an expression. And, the > stack frame being only 24 bytes indicates that the __bcp eventually > evaluated to true. Yeah. The best of all worlds would be that __builtin_constant_p() would itself always evaluate as an integer constant expression, but the expression inside of it could be expanded as if it was not. I realize that that can be very inconvenient for a compiler, since the two are basically done at different points in the evaluation, but it's the nicest semantics for the user. But since gcc doesn't actually provide those semantics, clearly clang doesn't have to either. I claim that it *could* be done right, though, if you happened to care about giving the best possible quality end result to the user. Instead of doing the integer constant expression testing early (before inlining etc), you do it later, but you carry along a bit in the expression that says "was this expression actually _syntactically_ an I-C-E?" And btw, I hate how stupid gcc is about "constant size arrays but acts as a VLA because it wasn't an integer-constant-expression size" things. Your code generation example really is a sad sad example of it. A good optimizer should have generated the same code even if the stupid array again syntactically was VLA, because it damn well isn't in reality. So if you get really excited about this, and decide that clang can do much better than gcc, I can only salute you! Linus