git: 1706d72e36a0 - stable/13 - Apply llvm fix for hanging gcc builds on 32-bit arm

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

URL: https://cgit.FreeBSD.org/src/commit/?id=1706d72e36a03da4e5c2bd166362dabf8f2b1d6a

commit 1706d72e36a03da4e5c2bd166362dabf8f2b1d6a
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-28 17:59:58 +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 5fd4e45d80fb..9d95cb25efa0 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4627,11 +4627,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.
@@ -4679,8 +4685,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);
       }
     }