git: 2846052cd44e - stable/12 - Apply llvm fix for hanging gcc builds on 32-bit arm

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 28 Jun 2023 18:15:22 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=2846052cd44ec28a99af774127f578d626d6f368

commit 2846052cd44ec28a99af774127f578d626d6f368
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-28 18:00:06 +0000

    Apply llvm fix for hanging gcc builds on 32-bit arm
    
    Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):
    
      [LV] Don't consider pointer as uniform if it is also stored.
    
      Update isVectorizedMemAccessUse to also check if the pointer is stored.
      This prevents LV to incorrectly consider a pointer as uniform if it is
      used as both pointer and stored by the same StoreInst.
    
      Fixes #61396.
    
    PR:             271992
    Reported by:    John F. Carr <jfc@mit.edu>
    MFC after:      3 days
    
    (cherry picked from commit dbbaf77801a8f30e49731395e85757f339f345bf)
---
 .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp      | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 671bc6b5212b..d131f48a7af3 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5415,11 +5415,17 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
             WideningDecision == CM_Interleave);
   };
 
-
   // Returns true if Ptr is the pointer operand of a memory access instruction
-  // I, and I is known to not require scalarization.
+  // I, I is known to not require scalarization, and the pointer is not also
+  // stored.
   auto isVectorizedMemAccessUse = [&](Instruction *I, Value *Ptr) -> bool {
-    return getLoadStorePointerOperand(I) == Ptr && isUniformDecision(I, VF);
+    auto GetStoredValue = [I]() -> Value * {
+      if (!isa<StoreInst>(I))
+        return nullptr;
+      return I->getOperand(0);
+    };
+    return getLoadStorePointerOperand(I) == Ptr && isUniformDecision(I, VF) &&
+           GetStoredValue() != Ptr;
   };
 
   // Holds a list of values which are known to have at least one uniform use.
@@ -5458,8 +5464,8 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
       if (isa<LoadInst>(I) && Legal->isUniformMemOp(I))
         addToWorklistIfAllowed(&I);
 
-      if (isUniformDecision(&I, VF)) {
-        assert(isVectorizedMemAccessUse(&I, Ptr) && "consistency check");
+      if (isVectorizedMemAccessUse(&I, Ptr)) {
+        assert(isUniformDecision(&I, VF) && "consistency check");
         HasUniformUse.insert(Ptr);
       }
     }