[PATCH] D24275: [LV] Don't emit unused scalars for uniform instructions

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 15:48:51 PDT 2016


mssimpso added a comment.

Thanks, Michael! I'll address your comments before committing.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2364
@@ -2343,2 +2363,3 @@
     // Get the last scalarized instruction. This corresponds to the instruction
     // we created for the last vector lane on the last unroll iteration.
+    unsigned LastLane = Legal->isUniformAfterVectorization(I) ? 0 : VF - 1;
----------------
mkuper wrote:
> The comment is slightly incorrect now ("last" vector lane).
True. I'll update the comment here.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2379
@@ -2357,2 +2378,3 @@
       Value *Insert = UndefValue::get(VectorType::get(V->getType(), VF));
-      for (unsigned Width = 0; Width < VF; ++Width)
+      for (unsigned Width = 0; Width < VF; ++Width) {
+        unsigned Lane = Legal->isUniformAfterVectorization(I) ? 0 : Width;
----------------
mkuper wrote:
> As long as you're touching this, maybe change the variable name? "Width" is weird.
I agree. I'll change this to "Lane" like we have in other places.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2380
@@ -2359,1 +2379,3 @@
+      for (unsigned Width = 0; Width < VF; ++Width) {
+        unsigned Lane = Legal->isUniformAfterVectorization(I) ? 0 : Width;
         Insert = Builder.CreateInsertElement(
----------------
mkuper wrote:
> Maybe just build a splat (one insert + shuffle) directly?
> InstCombine will clean this up, but IIUC the whole point of this patch is to generate cleaner code pre-instcombine.
Good point!


https://reviews.llvm.org/D24275





More information about the llvm-commits mailing list