[polly] [Polly] Data flow reduction detection to cover more cases (PR #84901)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 08:21:40 PDT 2024


================
@@ -2571,47 +2581,208 @@ bool checkCandidatePairAccesses(MemoryAccess *LoadMA, MemoryAccess *StoreMA,
     AllAccsRel = AllAccsRel.intersect_domain(Domain);
     isl::set AllAccs = AllAccsRel.range();
     Valid = !hasIntersectingAccesses(AllAccs, LoadMA, StoreMA, Domain, MemAccs);
-
     POLLY_DEBUG(dbgs() << " == The accessed memory is " << (Valid ? "not " : "")
                        << "accessed by other instructions!\n");
   }
+
   return Valid;
 }
 
+// Perform a data flow analysis on the current scop statement to propagate the
+// uses of loaded values. Then check and mark the memory accesses which are
+// part of reduction like chains.
+//
+// NOTE: This assumes independent scop statements and breaks otherwise.
 void ScopBuilder::checkForReductions(ScopStmt &Stmt) {
----------------
Meinersbur wrote:

```suggestion
void ScopBuilder::checkForReductions(ScopStmt &Stmt) {
// Perform a data flow analysis on the current scop statement to propagate the
// uses of loaded values. Then check and mark the memory accesses which are
// part of reduction like chains.
//
// NOTE: This assumes independent scop statements and breaks otherwise.

```
Since this explains the algorithm it should go into the function body.

Comments explaining the interface/purpose of the function would go to the declaration in `ScopBuilder.h` as doxygen comment.

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


More information about the llvm-commits mailing list