1

For example, copying the sign from 40 into-104.2 must produce 104.2

I tried:

__mm256 currVal = _mm256_set1_ps(-104.2f);
__m256 takeMySign = _mm256_set1_ps(40);
_mm256_blend_ps(currVal, takeMySign, 1<<31);

But it's not working :(

Kari
  • 1,244
  • 1
  • 13
  • 27

1 Answers1

1

This was already solved for AVX and AVX2, for both single (float) and double precision (double)

https://stackoverflow.com/a/57872652/9007125

Kari
  • 1,244
  • 1
  • 13
  • 27
  • 2
    When you find a duplicate and don't have anything more to add to adapt an answer for details of the question, please flag the question as a duplicate instead of posting an answer with just the link. I think on your own questions, you can single-handedly close as duplicate, like how gold-badge holders can. – Peter Cordes Jan 06 '21 at 20:13
  • 1
    @PeterCordes: That was my initial reaction, but this points to a specific answer in a related, but by no means duplicate, question. (Which is why I upvoted it.) – Bathsheba Jan 07 '21 at 08:16
  • @Bathsheba: If you need to specify which answer on a duplicate is the most useful, a comment under the question is usually adequate. (or possibly an edit to the question, although normally questions shouldn't contain answers.) But in this case, it's just linking to the top answer, and both answers are very similar. If anything, I'd have linked to Bee's simpler answer which leaves it up to the compiler to not do anything stupid with the vector constant. (It's trivial to port it between ps and pd) – Peter Cordes Jan 07 '21 at 08:33