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

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 15:23:53 PDT 2016


mkuper accepted this revision.
mkuper added a comment.
This revision is now accepted and ready to land.

Thanks, Matt.
This LGTM, except for some nits.


================
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;
----------------
The comment is slightly incorrect now ("last" vector lane).

================
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;
----------------
As long as you're touching this, maybe change the variable name? "Width" is weird.

================
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(
----------------
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.


https://reviews.llvm.org/D24275





More information about the llvm-commits mailing list