Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22465

Is there a simd instruction/intrinsic/builtin for partial shift of elements?

$
0
0

A minimal example would be more beneficial:

Say I have a sorted 8 ints = {10, 20, 30, 40, 50, 60, 70, 80} (My use case is for sorted integers but i am not sure if that information is valuable considering vector instruction act on the entire dataset)

There are few operations required:

  1. Insert and shift.

-> insert 25 at it's sorted location. -> becomes insert 25 at index 2 and shift rest.

10, 20, 30, 40, 50, 60, 70, 80 becomes: 10, 20, 25, 30, 40, 50, 60, 70

  1. Remove and shift

-> remove 20 from the array 10, 20, 30, 40, 50, 60, 70, 80 becomes 10, 30, 40, 50, 60, 70, 0

Or would a set of instructions make it work?

I am trying the insert and shift part with multiple steps for a descending sorted array. https://godbolt.org/z/_WCxkW


Viewing all articles
Browse latest Browse all 22465


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>