From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Simplify the inner loop of numeric division in div_var(). |
Date: | 2022-02-27 10:42:48 |
Message-ID: | E1nOH0p-00086N-JS@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Simplify the inner loop of numeric division in div_var().
In the standard numeric division algorithm, the inner loop multiplies
the divisor by the next quotient digit and subtracts that from the
working dividend. As suggested by the original code comment, the
separate "carry" and "borrow" variables (from the multiplication and
subtraction steps respectively) can be folded together into a single
variable. Doing so significantly improves performance, as well as
simplifying the code.
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/d996d648f333b04ae3da3c5853120f6f37601fb2
Modified Files
--------------
src/backend/utils/adt/numeric.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Rasheed | 2022-02-27 11:14:20 | pgsql: Optimise numeric division for one and two base-NBASE digit divis |
Previous Message | Dean Rasheed | 2022-02-27 10:19:06 | pgsql: Apply auto-vectorization to the inner loop of div_var_fast(). |