[llvm] [RISCV] Improve performCONCAT_VECTORCombine stride matching (PR #68726)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 14 10:22:56 PDT 2023
================
@@ -13821,6 +13822,56 @@ static SDValue performCONCAT_VECTORSCombine(SDNode *N, SelectionDAG &DAG,
Align = std::min(Align, Ld->getAlign());
}
+ // If the load ptrs can be decomposed into a common (Base + Index) with a
+ // common constant stride, then return the constant stride. This matcher
+ // enables some additional optimization since BaseIndexOffset is capable of
+ // decomposing the load ptrs to (add (add Base, Index), Stride) instead of
+ // (add LastPtr, Stride) or (add NextPtr, Stride) that matchForwardStrided and
+ // matchReverseStrided use respectively.
+ auto matchConstantStride = [&DAG, &N](ArrayRef<SDUse> Loads) {
+ // Initialize match constraints based on the first load. Initialize
+ // ConstStride by taking the difference between the offset of the first two
+ // loads.
+ if (Loads.size() < 2)
+ return SDValue();
+ BaseIndexOffset BaseLdBIO =
----------------
lukel97 wrote:
I pulled out getPtrDiff myself when trying wrap my head around this, hope this doesn't step on anyones toes: #69068
We should be able to extend it to check BaseIndexOffsets and return `DAG.getConstant` like we do here if they match
https://github.com/llvm/llvm-project/pull/68726
More information about the llvm-commits
mailing list