[clang] [llvm] Loop finalization (PR #214717)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 12:52:47 PDT 2026


================
@@ -10737,16 +10741,29 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
       }
 
       // Build final: IS.CounterVar = IS.Start + IS.NumIters * IS.Step
-      ExprResult Final =
-          buildCounterUpdate(SemaRef, CurScope, UpdLoc, CounterVar,
-                             IS.CounterInit, IS.NumIterations, IS.CounterStep,
-                             IS.Subtract, IS.IsNonRectangularLB, &Captures);
-      if (!Final.isUsable()) {
-        HasErrors = true;
-        break;
+      // For loop transformation directives with arithmetic counters, use
+      // (NumIters - 1) to get the value from the last iteration, not the loop
+      // exit value. For iterator-based loops (range-based for or explicit
+      // iterator loops), skip finalization entirely.
----------------
alexey-bataev wrote:

```suggestion
      // For iterator-based loops (range-based for or explicit
      // iterator loops) in loop transformation directives, skip
      // finalization entirely.
```

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


More information about the llvm-commits mailing list