remove switch statement in vector8_shift_{left,right}

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

In commit ec8719ccbf, I added a switch statement with all expected shift
counts for vector8_shift_{left,right} because AArch64's vshlq_n_u32 and
vshrq_n_u32 require an integer literal. I discovered that we can use
vshlq_u32 instead for both cases, which avoids the need for the switch
statement and compiles to the same machine code on recent gcc/clang.

--
nathan

Attachments:

v1-0001-remove-switch-statement-in-vector8_shift_-left-ri.patchtext/plain; charset=us-asciiDownload+3-27
#2John Naylor
johncnaylorls@gmail.com
In reply to: Nathan Bossart (#1)
Re: remove switch statement in vector8_shift_{left,right}

On Thu, Jul 2, 2026 at 7:32 AM Nathan Bossart <nathandbossart@gmail.com> wrote:

In commit ec8719ccbf, I added a switch statement with all expected shift
counts for vector8_shift_{left,right} because AArch64's vshlq_n_u32 and
vshrq_n_u32 require an integer literal. I discovered that we can use
vshlq_u32 instead for both cases, which avoids the need for the switch
statement and compiles to the same machine code on recent gcc/clang.

Hmm! +1

--
John Naylor
Amazon Web Services

#3Nathan Bossart
nathandbossart@gmail.com
In reply to: John Naylor (#2)
Re: remove switch statement in vector8_shift_{left,right}

Committed.

--
nathan