pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Apply auto-vectorization to the inner loop of div_var_fast().
Date: Sun, 27 Feb 2022 10:19:06 +0000
Message-ID: <E1nOGdt-0007wP-Bh@gemulon.postgresql.org> (raw)

Apply auto-vectorization to the inner loop of div_var_fast().

This loop is basically the same as the inner loop of mul_var(), which
was auto-vectorized in commit 8870917623, but the compiler will only
consider auto-vectorizing the div_var_fast() loop if the assignment
target div[qi + i] is replaced by div_qi[i], where div_qi = &div[qi].

Additionally, since the compiler doesn't know that qdigit is
guaranteed to fit in a 16-bit NumericDigit, cast it to NumericDigit
before multiplying to make the resulting auto-vectorized code more
efficient (avoiding unnecessary multiplication of the high 16 bits).

While at it, per suggestion from Tom Lane, change var1digit in
mul_var() to be a NumericDigit rather than an int for the same
reason. This actually makes no difference with modern gcc, but it
might help other compilers generate more efficient assembly.

Dean Rasheed, reviewed by Tom Lane.

Discussion: https://postgr.es/m/CAEZATCVwsBi-ND-t82Cuuh1=8ee6jdOpzsmGN+CUZB6yjLg9jw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e3d41d08a17549fdc60a8b9450c0511c11d666d7

Modified Files
--------------
src/backend/utils/adt/numeric.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)



view thread (2+ messages)

Message-ID: <E1nOGdt-0007wP-Bh@gemulon.postgresql.org>
Permalink:  ../E1nOGdt-0007wP-Bh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nOGdt-0007wP-Bh@gemulon.postgresql.org

 · 

reply

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: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Apply auto-vectorization to the inner loop of div_var_fast().
  In-Reply-To: <E1nOGdt-0007wP-Bh@gemulon.postgresql.org>
  References: <E1nOGdt-0007wP-Bh@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