[clang] [openmp] [OpenMP] Assign lastprivate loop counter init on empty worksharing loops (PR #243086)
Michael Kruse via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 25 06:52:20 PST 2026
================
@@ -4075,14 +4063,25 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
// whole loop.
bool CondConstant;
llvm::BasicBlock *ContBlock = nullptr;
+ const Expr *EmptyLoopInit = getEmptyLoopLastprivateInit(S);
if (ConstantFoldsToSimpleInteger(S.getPreCond(), CondConstant)) {
- if (!CondConstant)
+ if (!CondConstant) {
+ if (EmptyLoopInit)
+ EmitIgnoredExpr(EmptyLoopInit);
return false;
+ }
} else {
llvm::BasicBlock *ThenBlock = createBasicBlock("omp.precond.then");
ContBlock = createBasicBlock("omp.precond.end");
- emitPreCond(*this, S, S.getPreCond(), ThenBlock, ContBlock,
+ llvm::BasicBlock *EmptyBlock =
----------------
Meinersbur wrote:
It contains the `emitPreCond` twice, but it has lower control-flow complexity. It's a trade-off, your call which you prefer. But I find it hard to see that the two conditions `EmptyLoopInit` and `FalseBlock != ContBlock` are not independent. I'd prefer reusing the same condition both both of them.
https://github.com/llvm/llvm-project/pull/243086
More information about the cfe-commits
mailing list