[llvm] 14e5f97 - [LV] Add SCEV workaround from 80e8025 to epilogue vector code path.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 07:15:23 PDT 2022


Author: Florian Hahn
Date: 2022-04-01T15:14:47+01:00
New Revision: 14e5f9785c9ccc0b0cc29a21f042b7b562a34a3b

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

LOG: [LV] Add SCEV workaround from 80e8025 to epilogue vector code path.

This was exposed by 14e3650f. The recommit of 14e3650f will hit the
problematic code path requiring the workaround.
test case that crashes without the workaround.

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 d1f6f5cb0f70b..0cfe64a5f0374 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7741,6 +7741,15 @@ Value *InnerLoopUnroller::getBroadcastInstrs(Value *V) { return V; }
 std::pair<BasicBlock *, Value *>
 EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton() {
   MDNode *OrigLoopID = OrigLoop->getLoopID();
+
+  // Workaround!  Compute the trip count of the original loop and cache it
+  // before we start modifying the CFG.  This code has a systemic problem
+  // wherein it tries to run analysis over partially constructed IR; this is
+  // wrong, and not simply for SCEV.  The trip count of the original loop
+  // simply happens to be prone to hitting this in practice.  In theory, we
+  // can hit the same issue for any SCEV, or ValueTracking query done during
+  // mutation.  See PR49900.
+  getOrCreateTripCount(OrigLoop->getLoopPreheader());
   Loop *Lp = createVectorLoopSkeleton("");
 
   // Generate the code to check the minimum iteration count of the vector


        


More information about the llvm-commits mailing list