Status: New
Owner: ----

New issue 2228 by [email protected]: Generate SIMD instructions for SIMD-like code patterns
http://code.google.com/p/v8/issues/detail?id=2228

Turning typed arrays code like


function add_ps(a, b) {
  a[0] += b[0];
  a[1] += b[1];
  a[2] += b[2];
  a[3] += b[3];
}

function mul_ps(a, b) {
  a[0] *= b[0];
  a[1] *= b[1];
  a[2] *= b[2];
  a[3] *= b[3];
}

var vectors = new Float32Array(400000);
var adds = new Float32Array(4000);

for (var i=0; i<vectors.length; i+=4) {
  var a = new Float32Array(vectors.buffer, i*4, 4);
  for (var j=0; j<adds.length; j+=4) {
    var b = new Float32Array(adds.buffer, j*4, 4);
    add_ps(a, b);
    mul_ps(a, b);
  }
}


into something like the following C snippet


float *vectors;
float *adds;

// ... initialize vectors and adds

__m128 a, b;

for (int i=0; i<vectors_length; i+=4) {
  a = _mm_load_ps(vectors+i);
  for (int j=0; j<adds_length; j+=4) {
    b = _mm_load_ps(adds+j);
    a = _mm_add_ps(a, b);
    a = _mm_mul_ps(a, b);
  }
  _mm_store_ps(vectors+i, a);
}


would be nice.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to