0

I have this bytes in my YMM register (32-BYTE)

47 105 110 100 101 120 46 112 -1 104 112 -1 63 107 101 121 -1 49 61 118 97 108 117 101 49 38 107 101 121 50 61 118

There are three -1 bytes in this YMM register. I want to delete all -1 bytes and shift the next bytes 1 unit back to be something like this

47 105 110 100 101 120 46 112 104 112 63 107 101 121 49 61 118 97 108 117 101 49 38 107 101 121 50 61 118 0 0 0

I just want to delete all -1 and bring the next bytes 1 unit back ...

Is there any instruction for this action? How can i do this?

I can handle both C or assembly suggestion ....

Thank you.

HelloMachine
  • 355
  • 2
  • 8
  • Left-packing with byte granularity in a YMM register is very hard with AVX2 (and isn't much better with AVX512). Can you work in smaller chunks over a larger array or do you really need this for single YMM vectors? (Note that left-packing dwords efficiently is possible: [AVX2 what is the most efficient way to pack left based on a mask?](https://stackoverflow.com/q/36932240)) – Peter Cordes Sep 08 '20 at 20:39
  • Oh, but [Efficient sse shuffle mask generation for left-packing byte elements](https://stackoverflow.com/q/45506309) does have an AVX2 byte pack version using very different tricks. It produces four possibly-overlapping chunks of output, not a single vector result, though, because lane-crossing and element-crossing is hard. – Peter Cordes Sep 08 '20 at 20:42
  • Ok thank you .. Im reading those posts .... – HelloMachine Sep 08 '20 at 20:45

0 Answers0