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 1gu35x-0007JS-Fy for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Feb 2019 22:33:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gu35v-0002so-Kk for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Feb 2019 22:33:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu35v-0002sh-Dh for pgsql-hackers@lists.postgresql.org; Wed, 13 Feb 2019 22:33:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu35s-0006tK-JJ for pgsql-hackers@lists.postgresql.org; Wed, 13 Feb 2019 22:33:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x1DMXMr2026999; Wed, 13 Feb 2019 17:33:22 -0500 From: Tom Lane To: Alvaro Herrera cc: Andrew Gierth , David Rowley , PostgreSQL Hackers , Thomas Munro Subject: Re: Using POPCNT and other advanced bit manipulation instructions In-reply-to: <20190213221719.GA15976@alvherre.pgsql> References: <20190213221719.GA15976@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 13 Feb 2019 19:17:19 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26997.1550097202.1@sss.pgh.pa.us> Date: Wed, 13 Feb 2019 17:33:22 -0500 Message-ID: <26998.1550097202@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > and we have defined pg_popcount64() like this: > static int > pg_popcount64_sse42(uint64 word) > { > return __builtin_popcountl(word); > } That is clearly completely broken. > If that's correct, then I think we need something like this patch. But > it makes me wonder whether we need a configure test for > __builtin_popcountll() and friends. I wonder if there's any compiler > that implements __builtin_popcountl() but not __builtin_popcountll() ... > and if not, then the test for __builtin_popcountl() should be removed, > and have everything rely on the one for __builtin_popcount(). AFAICS, this is a gcc-ism, and it looks like they've probably had all width variants for the same amount of time. I'd take out the test for __builtin_popcountl(), and assume that testing for __builtin_popcount() is sufficient until proven differently. regards, tom lane