modify and return in macro/define?

I'm calling _mm256_srli_si256 and it has 2 problems. The first is I MUST pass an int literal otherwise I get an error (here's an example)

inline __m256i srli_si(__m256i a, const int b) { return _mm256_srli_si256(a, b); }

error: argument to '__builtin_ia32_psrldqi256_byteshift' must be a constant integer

The other problem is _mm256_srli_si256 requires some fixup because the high 128bits won't shift into the low (result[1] |= a[2] & 255 ? 0xFF00000000000000 : 0)

Now my next problem is in one place I assign the value to a variable auto myval = srli_si(inp, 1) and another place I do the same but as a function param. I have NO IDEA how the heck I can use the function while making it look like normal code. I almost want to give one and have it as an all caps macro where the first param is a variable name

Is it possible to write a define where I can modify an element of a variable and return the whole var?

Read more here:

Content Attribution

This content was originally published by Eric Stotch at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: