Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu0tI-0003bs-Fr for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Feb 2019 20:12:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gu0tH-0003M8-5L for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Feb 2019 20:12:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu0tG-0003K1-Nu for pgsql-hackers@lists.postgresql.org; Wed, 13 Feb 2019 20:12:18 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu0tD-0000Uj-9S for pgsql-hackers@lists.postgresql.org; Wed, 13 Feb 2019 20:12:17 +0000 Received: by mail-qt1-x841.google.com with SMTP id j36so4181201qta.7 for ; Wed, 13 Feb 2019 12:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=BFIBPbnB3iWHxWo2ArmV1+RSwJLyxAYoLYswfMVdIxw=; b=y4rnoxO6HXTVoh5yOYJkoIQycWjnIYKLoPFbX6huXtuRgG51eZUCe1r3u1jbR9OvAN XXiT2TGI/EeE1epaYlmTBvXUywsE84FqJT/fgzVB46XpXEzFbgwHla/v2lxGi9oYNLm1 GKfUa/8973cfDP1TOVAqPzoRKrSWoP0suaRGKkkTa3JcetSuJggicEuQqdCWGwyvgKnS oCj/PYyKd6mVWRr7A13Lrn+zyIsURw//SzD9eY6tVP5KuNx5+B+W/+EYMlzSU1zOYR+r rO3LIkt/GKFf5t6nbdjX6mlLk4lbx3/WQ/qj0fcPxpV2BK2201E/Pf8JBncGphqDpdiP gmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=BFIBPbnB3iWHxWo2ArmV1+RSwJLyxAYoLYswfMVdIxw=; b=HYt4SFFpmMZIWujphAidmVp3MrnQFKXmlhv/gUH/rf8+SsbBP4AHYR7OuSTd7Dl1Cm nmTN5MpwxIGa0e/c8h9H0Er3LF35ATUOk08CsExAdckQ4P8uOwyvaJ0f6Mc3m72bEUHO YSBzSt6GdR8zDQK3RRfJOrBuqyaUlyDXUP8rO/valRbO/8rcKP/pnrxaLEudGo3VLYLM 1b1CylH5TolzDL6P2UYwdu0GV9CHRhET2+TfRM46r55sMRU59BO4Ew3bG2U4sXy7t6em Q3h29/e2I7MUxt/iyS8KbPCx0v6dZ2sQHCOiwmYCY4sYr1B0yy4w+FSFh1PYhmt0QosP SKpA== X-Gm-Message-State: AHQUAuYL57T8h0ksfxsbaMHsiMt0GUalCGLLXTYc2gndN3In/2KA10fE Wy9Lr4w0CgnIEAWeapy8lCBPSg== X-Google-Smtp-Source: AHgI3Ia7UvouwIEmsSEQWuJw9ZH5s+hoQ0SDo9+IKiNs0gFjG8ZKS5SmOQHEiCFHVqnbun3XoBZJtg== X-Received: by 2002:a0c:ea4e:: with SMTP id u14mr1843380qvp.222.1550088734145; Wed, 13 Feb 2019 12:12:14 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id l129sm146750qkb.44.2019.02.13.12.12.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 12:12:13 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 92F5212459B; Wed, 13 Feb 2019 17:12:11 -0300 (-03) Date: Wed, 13 Feb 2019 17:12:11 -0300 From: Alvaro Herrera To: Andres Freund Cc: pgsql-hackers@lists.postgresql.org, Tom Lane , Andrew Gierth , David Rowley , Thomas Munro Subject: Re: Using POPCNT and other advanced bit manipulation instructions Message-ID: <20190213201211.GA5800@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2F6CDF3B-08B9-4A15-ABDF-55D7F82AB76E@anarazel.de> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Feb-13, Andres Freund wrote: > Hi, > > On February 13, 2019 8:40:14 PM GMT+01:00, Tom Lane wrote: > >Alvaro Herrera writes: > >> I've pushed this now. Let's see what the buildfarm has to say about > >it. > > > >It's likely to be hard to tell, given the amount of pink from the Ryu > >patch. If Andrew is not planning to clean that up PDQ, I'd suggest > >reverting that patch pending having some repairs for it. > > I'd assume that breaking bit counting would cause distinct enough > damage (compile time or crashes). I was a bit surprised to find out that the assembly generated by compiling the code in test for __builtin_foo() does not actually include the calls being tested ... (they're only used to generate the value for a static variable, and that gets optimized away); but then the comment for the test does say that we're only testing that the compiler understands the construct, so I suppose that's fine. Also, we already do that for bswap. This "compiler explorer" tool is nice: https://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,source:'int+main(int+argc+,+char**+argv)%0A%7B%0A%0A++return++__builtin_popcountll((unsigned)argc)%3B%0A%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:45.01119572686435,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g447,filters:(b:'0',commentOnly:'0',directives:'0',intel:'0'),libs:!(),options:'-Wall+-O3+-msse4.2',source:1),l:'5',n:'0',o:'x86-64+gcc+4.4.7+(Editor+%231,+Compiler+%231)',t:'0')),k:54.98880427313565,l:'4',m:100,n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4 -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services