[PATCH] [SLPVectorizer] Reorder operands of shufflevector if it can result in a vectorized code.

Karthik Bhat kv.bhat at samsung.com
Tue Dec 16 01:49:42 PST 2014


Hi aschwaighofer, nadav,

Hi All,
The below code was not being vectorized in vector shuffle in SLPVectorizer.
  float fa[4],fb[4],fc[4];
  void fn() {
    fc[0] = fb[0]+fa[0];
    fc[1] = fa[1]-fb[1];
    fc[2] = fa[2]+fb[2];
    fc[3] = fa[3]-fb[3];
  }
This was because we were to take the operands in the given order fb[0] and fa[1] are not consecutive access. But since '+' is commutative for both float and int for which we handle Shuffle Vector. Hence we can reorder the addition fb[0] + fa[0] -> fa[0] + fb[0] in which case buildTree_rec will be able to conclude it as a consecutive load and vectorize the same.

In this patch we check if we can reorder commutative operations in AltShuffle which can result in vectorization if yes we reorder the operands of the commutative operation.

Please let me know if this is good to commit.

Thanks and Regards
Karthik Bhat

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6677

Files:
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/Transforms/SLPVectorizer/X86/addsub.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6677.17325.patch
Type: text/x-patch
Size: 8721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141216/9452409f/attachment.bin>


More information about the llvm-commits mailing list