Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnMEC-005kyG-2t for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Feb 2026 19:38:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnME9-0075ZA-34 for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Feb 2026 19:38:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnME9-0075Z1-0D for pgsql-hackers@lists.postgresql.org; Tue, 03 Feb 2026 19:38:21 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vnME5-00000000uCA-3OJL for pgsql-hackers@postgresql.org; Tue, 03 Feb 2026 19:38:20 +0000 Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfout.phl.internal (Postfix) with ESMTP id 88C17EC0587; Tue, 3 Feb 2026 14:38:14 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Tue, 03 Feb 2026 14:38:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1770147494; x=1770233894; bh=CGw1Kz78Rijf8JvTXq2pIvixrjDjZCP/U6aY8MtomMY=; b= a5Zq6wNLWPpFOB0/6j7EY0BlpBr/7RWr8ISq0wq7f/ZMUDLg/qxUFxZbAkXFreGr Pwt0BPyDAYAjQ++HD8XHPRipawZnJg17RyWVIiUFoSl6RqIbpR9MEv81n/txLYC+ d3DCj3I9U0is8pKfhBUtW9gxVpgPEyPdMBWhOX/9w/2AqPQGtWcrE/UuSAxqQET4 PWq37ujrhAEX4HZQlE+EFpkn/hVdndeVvBRkdC7pE/t+ISeYWbsqX9RSs34rzyhD k+blXtDsWjTO09wRUzSqAjNX17j1ODs+A7wD0QQdY2VGEXUjrUT1Xm+jpRtwJY0I FrMce0P1byjj8xIUbSrCOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1770147494; x= 1770233894; bh=CGw1Kz78Rijf8JvTXq2pIvixrjDjZCP/U6aY8MtomMY=; b=k 2coLKTi7+elznDwoAnJWcawWg+86mhrec7V5eboICYIbGl9rwD0O5h1b9e2tYFDs 0moT06RAIBYjdkBm8HC04+HAbHetYka6gUsUJAbmibJ6yCXG+mszxLX+PuXNMkFz xpLah5QgXsB2l5Pq80hie89tDB3PoxssTHcxH3cH0ClprVrxgJyQl2pTApWRqEh6 7+jJoRZjEJBGmk5MypjinFkQotu3DZ2G/0zxv9SE/L1ui/YiDrzMPT7PxXOeXD2I VgWbCTClSXS6s4t+PerIryr3kdTzLlJLLBxLTT+5TulZLCPFpdXGG5LQ5Dj6rKxg wlLh+YX1caur1isj+CxHw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukedtledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevkfgjfhfuofggtgfgugesthejmhdtredtjeenucfhrhhomhepifhrvghg uceuuhhrugcuoehgrhgvghessghurhgurdhmvgeqnecuggftrfgrthhtvghrnhepgedvff dtledvkeetleejvdeludeuvedugfegtedugfdujedtieektdevgfelgfeinecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsegsuhhrug drmhgvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehnrghthhgrnhgusghoshhsrghrthesghhmrghilhdrtghomhdprhgtphhtthhopehjoh hhnhgtnhgrhihlohhrlhhssehgmhgrihhlrdgtohhmpdhrtghpthhtohephhhlihhnnhgr khgrsehikhhirdhfihdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsth hgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Feb 2026 14:38:14 -0500 (EST) Date: Tue, 3 Feb 2026 14:38:11 -0500 From: Greg Burd To: Nathan Bossart Cc: John Naylor , Heikki Linnakangas , pgsql-hackers Message-ID: In-Reply-To: References: Subject: Re: refactor architecture-specific popcount code X-Mailer: Mailspring MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Feb 3 2026, at 12:41 pm, Nathan Bossart wrote: > On Tue, Feb 03, 2026 at 12:19:48PM -0500, Greg Burd wrote: >> Thanks for the focus on this area of the code. I've been looking into >> what to do with popcnt when building Win11/ARM64/MSVC. I know that when >> _MSC_VER and _M_ARM64 are defined we can make use of the >> __popcnt(unsigned int) and __popcnt64(unsigned __int64) intrinsics which >> have been available since VS 2022 17.11+. I thought I'd check that combo >> out and it turns out that it is identical to clang/gcc on that platform >> [0]. >> >> I'll wait for your work to land before proposing a patch to add these >> unless it is really easy to fit it and you feel like giving it a go. :) > > We should probably just add something like > > #ifdef _MSC_VER > return __popcnt(word); Right, it seemed to me after reviewing the patch to fit right in. > for the new inlined versions of pg_popcount{32,64}. We're already doing > that today for x86-64, and the AArch64-specific versions use intrinsics > that in theory compile to the same thing. Plus, popcnt is required for > Windows these days. > > I'm working on polishing/benchmarking these patches at the moment, so I > will work this change in. Thanks! Not a problem, thank you! > -- > nathan -greg