[llvm] e192974 - [LV] Check if value was already not uniform for previous VF.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 12:31:35 PDT 2023


Author: Florian Hahn
Date: 2023-06-04T20:31:01+01:00
New Revision: e19297471a09d01b8e5777f37b6efaa3f4c4f064

URL: https://github.com/llvm/llvm-project/commit/e19297471a09d01b8e5777f37b6efaa3f4c4f064
DIFF: https://github.com/llvm/llvm-project/commit/e19297471a09d01b8e5777f37b6efaa3f4c4f064.diff

LOG: [LV] Check if value was already not uniform for previous VF.

If the value was already known to not be uniform for the previous
(smaller VF), it cannot be uniform for the larger VF.

This slightly reduces compile-time, once uniformity checks are becoming
a bit more expensive due to using SCEV rewriting (D148841).

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D151658

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index a4cd4394697f3..02e77e1507463 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4672,9 +4672,17 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
   if (Cmp && TheLoop->contains(Cmp) && Cmp->hasOneUse())
     addToWorklistIfAllowed(Cmp);
 
+  auto PrevVF = VF.divideCoefficientBy(2);
   // Return true if all lanes perform the same memory operation, and we can
   // thus chose to execute only one.
   auto isUniformMemOpUse = [&](Instruction *I) {
+    // If the value was already known to not be uniform for the previous
+    // (smaller VF), it cannot be uniform for the larger VF.
+    if (PrevVF.isVector()) {
+      auto Iter = Uniforms.find(PrevVF);
+      if (Iter != Uniforms.end() && !Iter->second.contains(I))
+        return false;
+    }
     if (!Legal->isUniformMemOp(*I, VF))
       return false;
     if (isa<LoadInst>(I))


        


More information about the llvm-commits mailing list