[clang] [flang] [llvm] [OpenMP][clang][flang] Compare tied context selectors with each other (PR #233905)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 14:53:28 PST 2026


================
@@ -414,22 +413,21 @@ int llvm::omp::getBestVariantMatchForContext(
     APInt Score = getVariantMatchScore(VMI, Ctx, ConstructMatches);
     if (Score.ult(BestScore))
       continue;
-    // Equal score need subset checks.
-    if (Score.eq(BestScore)) {
-      // Strict subset are never best.
-      if (isStrictSubset(VMI, *BestVMI))
-        continue;
-      // Same score and the current best is no strict subset so we keep it.
-      if (!isStrictSubset(*BestVMI, VMI))
-        continue;
+    if (Score.ugt(BestScore)) {
+      BestScore = Score;
+      BestVMIIdxs.clear();
     }
-    // New best found.
-    BestVMI = &VMI;
-    BestVMIIdx = u;
-    BestScore = Score;
+    BestVMIIdxs.push_back(u);
   }
 
-  return BestVMIIdx;
+  // A strict subset of another tied variant is never best; otherwise the first
+  // one wins.
+  for (unsigned Idx : BestVMIIdxs)
+    if (llvm::none_of(BestVMIIdxs, [&](unsigned OtherIdx) {
----------------
chichunchen wrote:

@MattPD, rather than fixing the performance issues in #231676, I included the changes from https://github.com/llvm/llvm-project/pull/233905/changes/8f954c55bbc085ce4954fe1b8d21c66edef890e1 in this PR.

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


More information about the cfe-commits mailing list