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

Nicole Aschenbrenner via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 02:26:10 PDT 2026


================
@@ -1145,6 +1150,19 @@ bool CGOpenMPRuntimeGPU::isDelayedVariableLengthDecl(CodeGenFunction &CGF,
   return llvm::is_contained(I->getSecond().DelayedVariableLengthDecls, VD);
 }
 
+bool CGOpenMPRuntimeGPU::canPromoteToNoLoop(
+    const OMPExecutableDirective &D) const {
+  OpenMPDirectiveKind DKind = D.getDirectiveKind();
+  const LangOptions &LangOpts = CGM.getLangOpts();
+  return (DKind == OMPD_target_teams_distribute_parallel_for ||
+          DKind == OMPD_target_teams_distribute_parallel_for_simd) &&
+         LangOpts.OpenMPTeamSubscription && LangOpts.OpenMPThreadSubscription &&
+         !D.hasClausesOfKind<OMPNumTeamsClause>() &&
+         !D.hasClausesOfKind<OMPReductionClause>() &&
+         !D.hasClausesOfKind<OMPLastprivateClause>() &&
+         !D.hasClausesOfKind<OMPLinearClause>();
+}
----------------
nicebert wrote:

Sema currently rejects the ordered clause on `target teams distribute parallel for` (and the simd form) with `unexpected OpenMP clause 'ordered'`, so this filter would never trigger.

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


More information about the llvm-commits mailing list