pgsql: Frob numeric.c loop so that clang will auto-vectorize it too.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Frob numeric.c loop so that clang will auto-vectorize it too.
Date: 2020-09-07 16:03:09
Message-ID: E1kFJbp-0002kt-AS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Frob numeric.c loop so that clang will auto-vectorize it too.

Experimentation shows that clang will auto-vectorize the critical
multiplication loop if the termination condition is written "i2 < limit"
rather than "i2 <= limit". This seems unbelievably stupid, but I've
reproduced it on both clang 9.0.1 (RHEL8) and 11.0.3 (macOS Catalina).
gcc doesn't care, so tweak the code to do it that way.

Discussion: https://postgr.es/m/CAJ3gD9evtA_vBo+WMYMyT-u=keHX7-r8p2w7OSRfXf42LTwCZQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9c79e646c6f0f8df06d966c536d0c6aa33bf1b06

Modified Files
--------------
src/backend/utils/adt/numeric.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Pavel Stehule 2020-09-07 16:34:02 Re: pgsql: Refactor pg_get_line() to expose an alternative StringInfo-based
Previous Message Tom Lane 2020-09-07 14:48:46 Re: pgsql: Refactor pg_get_line() to expose an alternative StringInfo-based