Re: use CLZ instruction in AllocSetFreeIndex()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: John Naylor <john(dot)naylor(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: use CLZ instruction in AllocSetFreeIndex()
Date: 2019-12-27 16:43:18
Message-ID: 8398.1577464998@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> On 2019-Dec-27, Tom Lane wrote:
>> ... Perhaps what we really ought to be working on is
>> finding MSVC equivalents for __builtin_clz and friends.

> Apparently clz() can be written using _BitScanReverse(), per
> https://stackoverflow.com/a/20468180
> https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=vs-2015

Yeah, I found that too. It looks promising, but we need to look into
* portability to different MSVC versions? (I guess the buildfarm would
tell us)
* performance, does it actually generate comparable code?
* intrinsics for the other bit instructions we use?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2019-12-27 17:02:20 Re: [PATCH v1] pg_ls_tmpdir to show directories
Previous Message David Fetter 2019-12-27 16:37:28 Re: use CLZ instruction in AllocSetFreeIndex()