[PATCH] D15815: [SLP] Truncate expressions to minimum required bit width

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 6 14:51:06 PST 2016


mssimpso added inline comments.

================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:3260
@@ +3259,3 @@
+
+  // If there are no external uses, the expression tree must be rooted by a
+  // store. We can't demote in-memory values, so there is nothing to do here.
----------------
This work is a little more limited than what you've done in the loop vectorizer. Because we're working with expression trees, I thought it would be simpler to only truncate the roots of single-use chains. If the tree has no external users, it should be rooted by stores, which obviously can't be truncated. So we give up in that case. I've tried to explain my reasoning a little better in the comments, but I haven't yet thought much about the more general case.

In particular, the current patch doesn't do anything useful for the single-use chains ending in stores that have unnecessary extends and truncations in them that prevent us from getting past the cost model. Even though the extends and truncations in those chains may be removed by InstCombine after vectorization, they will currently still be counted by the model. I was thinking of adding this functionality as a follow-on, but I can add it to this patch if you like. What do you think?

================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:3303
@@ +3302,3 @@
+      // Get a representative value for the vectorizable bundle. All values in
+      // Entry.Scalars should be isomorphic.
+      auto *Scalar = Entry.Scalars[0];
----------------
My first inclination was to try and reuse the DemandedBits analysis you added to VectorUtils. However, demanded bits alone didn't help the case I was most interested in: the index computation of GEPs, which is promoted to 64 bits, all of them being demanded. Since all the bits are demanded by the GEP, we have to look at the number of leading sign bits instead. But I've updated the patch to also consider the demanded bits of the roots since they are all we truncate.


http://reviews.llvm.org/D15815





More information about the llvm-commits mailing list