git: dbbaf77801a8 - main - Apply llvm fix for hanging gcc builds on 32-bit arm

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 19 Jun 2023 18:33:51 UTC
The branch main has been updated by dim:

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

commit dbbaf77801a8f30e49731395e85757f339f345bf
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-19 18:33:33 +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
---
 .../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);
       }
     }