Horizontal running diff and conditional update using SIMD/SSE?

Viewed 280

I would like to vectorize the following operation:

V[i+1] = max(V[i] - c, V[i+1]) for i=1 to n-1 (V[0] = 0)

The corresponding naive pseudo-code is:

for (i=0; i < n; i++) {
  if (V[i]-c > V[i+1]) V[i+1] = V[i]-c
}

Which SIMD instructions could be useful ?

1 Answers
Related