[PATCH] D24833: [LoopDataPrefetch/AArch64] Allow selective prefetching of symbolic strided accesses

Balaram Makam via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 03:20:38 PDT 2016


bmakam added inline comments.

================
Comment at: lib/Transforms/Scalar/LoopDataPrefetch.cpp:178-201
@@ -163,1 +177,26 @@
 
+bool LoopDataPrefetch::isSymbolicStride(const SCEV *V, Loop *L) {
+  const auto *M = dyn_cast<SCEVMulExpr>(V);
+  if (!M)
+    return false;
+  // Check if the step value is a non-unit constant.
+  V = M->getOperand(0);
+  if (V->getSCEVType() != scConstant)
+    return false;
+
+  if (V->isOne() || V->isAllOnesValue())
+    return false;
+
+  V = M->getOperand(1);
+
+  // Strip off casts.
+  while (const auto *C = dyn_cast<SCEVCastExpr>(V))
+    V = C->getOperand();
+
+  const auto *U = dyn_cast<SCEVUnknown>(V);
+  if (!U)
+    return false;
+
+  return (L->isLoopInvariant(U->getValue()));
+}
+
----------------
mssimpso wrote:
> bmakam wrote:
> > mssimpso wrote:
> > > Would it be possible to reuse llvm::getStrideFromPointer instead of re-implementing some of the logic here?
> > It seems like llvm::getStrideFromPointer is not suitable for reuse here, especially it somehow assumes that the PtrAccessSize is always 1 and returns null when PtrAccessSize != StepVal. For all the interesting cases this scheme targets the stepval is a non-unit constant.
> That's just for the non-gep case, though, right? For example, if the pointer operand of a load/store is a pointer induction variable instead of a gep. In that case it checks that the pointer operand is an addrec like Ptr + V, where V is non-constant. Shouldn't that work?
Sometimes GEP is a pointer but not an index, for example in mcf's case the Access Ptr is:
%128 = getelementptr inbounds %struct.arc, %struct.arc* %111, i64 0, i32 0

and the SCEV is:
{((64 * %105)<nsw> + %1)<nsw>,+,(64 * %100)<nsw>}<nw><%108>

Here 64 is the size of %struct.arc and is a non-unit constant. I have added a test case to show where this won't work with llvm::getStrideFromPointer


https://reviews.llvm.org/D24833





More information about the llvm-commits mailing list