auto-vectorize varbit bitwise operators

Started by Nathan Bossart3 months ago4 messageshackers
Jump to latest
#1Nathan Bossart
nathandbossart@gmail.com

After adding -ftree-vectorize and moving the loop boundary computations to
outside the loops, popular compilers will auto-vectorize bit_and(),
bit_or(), bitxor(), and bitnot(). My testing indicates this produces some
nice speedups, but I haven't yet done anything scientific enough to share.

--
nathan

Attachments:

t253650_1
v1-0001-Auto-vectorize-the-varbit-bitwise-operators.patchtext/plain; charset=us-asciiDownload+23-15
#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Nathan Bossart (#1)
Re: auto-vectorize varbit bitwise operators

On 02/09/2026 21:57, Nathan Bossart wrote:

After adding -ftree-vectorize and moving the loop boundary computations to
outside the loops, popular compilers will auto-vectorize bit_and(),
bit_or(), bitxor(), and bitnot(). My testing indicates this produces some
nice speedups, but I haven't yet done anything scientific enough to share.

Dunno if these are particularly worth optimizing, but regardless of
performance, I think the loop code looks better with these changes anyway.

- Heikki

#3Chao Li
li.evan.chao@gmail.com
In reply to: Nathan Bossart (#1)
Re: auto-vectorize varbit bitwise operators

On Sep 3, 2026, at 02:57, Nathan Bossart <nathandbossart@gmail.com> wrote:

After adding -ftree-vectorize and moving the loop boundary computations to
outside the loops, popular compilers will auto-vectorize bit_and(),
bit_or(), bitxor(), and bitnot(). My testing indicates this produces some
nice speedups, but I haven't yet done anything scientific enough to share.

--
nathan
<v1-0001-Auto-vectorize-the-varbit-bitwise-operators.patch>

I think this should improve performance on CPUs with SIMD support. It also improves code readability.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Chao Li (#3)
Re: auto-vectorize varbit bitwise operators

Committed, thanks for looking!

--
nathan