1

I want to increment the value of a VSX register by one. But there is no instruction in Open power ISA to add immediate to a VSX register. Does anybody have an idea?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
shb8086
  • 31
  • 5
  • 2
    Have you tried looking at compiler asm output for something like `uint8x16_p foo;` / `foo += 1;`? IDK if GCC or clang would compile that efficiently, but GNU C vector extensions do allow vector-with-scalar with implicit broadcast. – Peter Cordes Apr 21 '22 at 12:57
  • 1
    If asm, a common trick on x86 (which doesn't have any mov-immediate to vector instructions) is to materialize an all-ones register by comparing a register against itself. That's 2's complement `-1`, so you can subtract that from another vector to increment each element, with your choice of element width. I have no idea if that's the most efficient way to do things with VSX. – Peter Cordes Apr 21 '22 at 12:57
  • 1
    Can you clarify your question? A VSX register can hold different representations of constituent elements (a single 128-bit value, 2 64-bit values, ... integer, floating-point). Perhaps an example which what you have and what you want. I'd agree with @PeterCordes, though, that letting the compiler do what you want is generally the best option. Recent compiler versions are preferred, as they are always improving. – ThinkOpenly Apr 22 '22 at 14:22

0 Answers0