[PATCH] Fix PR19657 : SLP vectorization doesn't combine scalar load to vector loads

Karthik Bhat kv.bhat at samsung.com
Tue May 27 23:21:28 PDT 2014


Hi Nadav, I have a quick question. In case of commutative operation like the one we are handling here is it guaranteed that that right subtree height >= left subtree height always?
It seems so. I tried few examples -

  void foo(double *x) {
    x[0] = x[0] * x[0] + x[0];
    x[1] = x[1] * x[1] + x[1];
    x[2] = x[2] * x[2] + x[2];
    x[3] = x[3] * x[3] + x[3];
  }

and 
  void foo(double *x) {
    x[0] = x[0] + x[0] * x[0];
    x[1] = x[1] + x[1] * x[1];
    x[2] = x[2] + x[2] * x[2];
    x[3] = x[3] + x[3] * x[3];
  }

The IR in both these cases are same and it seems we are reordering the IR so that the instructions for which the larger subtree will be constructed will always be on right side in case of commutative operations. 
If this is guaranteed to do so we might be able to skip the getLastIndex check as well and directly call -
  buildTree_rec(Right, Depth + 1);
  buildTree_rec(Left, Depth + 1);

Thanks for the clarification.
Regards
Karthik Bhat

http://reviews.llvm.org/D3800






More information about the llvm-commits mailing list