From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use branchless comparisons in btint4cmp and btint8cmp, for speed
Date: Thu, 05 Nov 2026 11:58:11 +0000
Message-ID: <E1xOw6e-00000000IwW-0fv7@gemulon.postgresql.org> (raw)
Use branchless comparisons in btint4cmp and btint8cmp, for speed
The comment on pg_cmp_*() points out that the old form can produce
better code if the comparison is inlined, but that's not a concern
here because btint4cmp() and btint8cmp() are invoked through the
function manager and won't be inlined.
Author: David Geier <geidav.pg@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://www.postgresql.org/message-id/5d366878-2007-4d31-861e-19294b7a583b@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/41467b1d88303fbaea4ddd20c21ac4b8ce6b92d7
Modified Files
--------------
src/backend/access/nbtree/nbtcompare.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Use branchless comparisons in btint4cmp and btint8cmp, for speed
In-Reply-To: <E1xOw6e-00000000IwW-0fv7@gemulon.postgresql.org>
References: <E1xOw6e-00000000IwW-0fv7@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox