[llvm-branch-commits] [flang] [flang][OpenMP] Track reachable metadirective replacements (PR #219014)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 18 23:19:08 PDT 2026


================
@@ -313,16 +333,27 @@ bool llvm::omp::isVariantApplicableInContext(
 static APInt getVariantMatchScore(const VariantMatchInfo &VMI,
                                   const OMPContext &Ctx,
                                   SmallVectorImpl<unsigned> &ConstructMatches) {
-  APInt Score(64, 1);
+  APInt Score(1, 1);
+
+  // A sum of valid scores can exceed the width of any individual score.
+  // Retain all active bits and allow one more bit for each addition's carry.
+  auto AddScore = [&](const APInt &Value) {
+    unsigned Width = std::max(Score.getActiveBits(), Value.getActiveBits()) + 1;
+    Score = Score.zextOrTrunc(Width);
+    Score += Value.zextOrTrunc(Width);
+  };
+  auto AddPowerOfTwo = [&](unsigned Exponent) {
+    AddScore(APInt::getOneBitSet(Exponent + 1, Exponent));
+  };
 
-  unsigned NoConstructTraits = VMI.ConstructTraits.size();
+  unsigned NoConstructTraits = Ctx.ConstructTraits.size();
----------------
MattPD wrote:

Fixed by https://github.com/llvm/llvm-project/pull/224431: With the outer PARALLEL, `check_target` calls `scored_variant` at 7f8fa534, as at the merge base.

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


More information about the llvm-branch-commits mailing list