[llvm] [LSV] Merge contiguous chains across scalar types (PR #154069)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 08:09:40 PDT 2025


================
@@ -424,6 +432,20 @@ PreservedAnalyses LoadStoreVectorizerPass::run(Function &F,
   return Changed ? PA : PreservedAnalyses::all();
 }
 
+static const Value *getUnderlyingPtrObject(const Value *Ptr) {
+  const Value *ObjPtr = llvm::getUnderlyingObject(Ptr);
+  if (const auto *Sel = dyn_cast<SelectInst>(ObjPtr)) {
+    // The select's themselves are distinct instructions even if they share
+    // the same condition and evaluate to consecutive pointers for true and
+    // false values of the condition. Therefore using the select's themselves
+    // for grouping instructions would put consecutive accesses into different
+    // lists and they won't be even checked for being consecutive, and won't
+    // be vectorized.
+    return Sel->getCondition();
+  }
+  return ObjPtr;
+}
----------------
arsenm wrote:

I don't understand this function, and don't really follow the comment. 

"PtrObject" sounds like it's supposed to return a pointer to an object, which it does, unless it's a select, in which case it returns a boolean value? Plus what happens if the pointer is a select of 2 pointers derived from the same base object? 

https://github.com/llvm/llvm-project/pull/154069


More information about the llvm-commits mailing list