[flang-commits] [flang] [flang] Improve disjoint/identical slices recognition in opt-bufferization. (PR #119780)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Fri Dec 13 06:15:14 PST 2024


================
@@ -159,28 +159,162 @@ containsReadOrWriteEffectOn(const mlir::MemoryEffects::EffectInstance &effect,
   return mlir::AliasResult::NoAlias;
 }
 
-// Returns true if the given array references represent identical
-// or completely disjoint array slices. The callers may use this
-// method when the alias analysis reports an alias of some kind,
-// so that we can run Fortran specific analysis on the array slices
-// to see if they are identical or disjoint. Note that the alias
-// analysis are not able to give such an answer about the references.
-static bool areIdenticalOrDisjointSlices(mlir::Value ref1, mlir::Value ref2) {
+// Helper class for analyzing two array slices represented
+// by two hlfir.designate operations.
+class ArraySectionAnalyzer {
+public:
+  // The result of the analyzis is one of the values below.
+  enum class SlicesOverlapKind {
+    // Slices overlap is unknown.
+    Unknown,
+    // Slices are definitely disjoint.
+    DefinitelyIdentical,
+    // Slices are definitely identical.
----------------
tblah wrote:

```suggestion
    // Slices are definitely identical.
    DefinitelyIdentical,
    // Slices are definitely disjoint.
```

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


More information about the flang-commits mailing list