[clang] [llvm] [clang][OpenMP] Add no-loop SPMD kernel promotion (PR #224041)

Dhruva Chakrabarti via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 23:14:35 PDT 2026


================
@@ -3691,6 +3711,22 @@ static void emitDistributeParallelForDistributeInnerBoundParams(
   CapturedVars.push_back(UBCast);
 }
 
+static void emitLoopIterationspaceVars(CodeGenFunction &CGF,
+                                       const OMPLoopDirective &S) {
+  // Emit the loop iteration variable.
+  const auto *IVExpr = cast<DeclRefExpr>(S.getIterationVariable());
+  CGF.EmitVarDecl(*cast<VarDecl>(IVExpr->getDecl()));
+
+  // Emit the iterations count variable.
+  // If it is not a variable, Sema decided to calculate iterations count on each
+  // iteration (e.g., it is foldable into a constant).
+  if (const auto *LIExpr = dyn_cast<DeclRefExpr>(S.getLastIteration())) {
----------------
dhruvachak wrote:

Your tests have constant upper bounds, e.g. 1024. This path is never tested.

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


More information about the llvm-commits mailing list