[llvm] [IRSim] Fix overlap() (PR #92988)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 20:41:18 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Justin Fargnoli (justinfargnoli)

<details>
<summary>Changes</summary>

Ensure that the end of `A` comes before the beginning of `B`. Otherwise, `A` and `B` do not overlap.

---
Full diff: https://github.com/llvm/llvm-project/pull/92988.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/IRSimilarityIdentifier.cpp (+1-9) 


``````````diff
diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index ebe22f5c35d18..3c32682bb3de6 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -898,15 +898,7 @@ bool IRSimilarityCandidate::compareStructure(
 
 bool IRSimilarityCandidate::overlap(const IRSimilarityCandidate &A,
                                     const IRSimilarityCandidate &B) {
-  auto DoesOverlap = [](const IRSimilarityCandidate &X,
-                        const IRSimilarityCandidate &Y) {
-    // Check:
-    // XXXXXX        X starts before Y ends
-    //      YYYYYYY  Y starts after X starts
-    return X.StartIdx <= Y.getEndIdx() && Y.StartIdx >= X.StartIdx;
-  };
-
-  return DoesOverlap(A, B) || DoesOverlap(B, A);
+  return A.StartIdx <= B.getEndIdx() && B.StartIdx <= A.getEndIdx();
 }
 
 void IRSimilarityIdentifier::populateMapper(

``````````

</details>


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


More information about the llvm-commits mailing list