[OPENMP50]Codegen for scan directives in parallel for simd regions.
Summary:
Added codegen for scan directives in parallel for simd regions.
Emits the code for the directive with inscan reductions.
Original code:
```
#pragma omp parallel for simd reduction(inscan, op : ...)
for() {
<input phase>;
#pragma omp scan (in)exclusive(...)
<scan phase>
}
```
is transformed to something:
```
#pragma omp parallel
{
size num_iters = <num_iters>;
<type> buffer[num_iters];
#pragma omp for simd
for (i: 0..<num_iters>) {
<input phase>;
buffer[i] = red;
}
#pragma omp barrier
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
#pragma omp for simd
for (0..<num_iters>) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
<scan phase>;
}
}
```
Reviewers: jdoerfert
Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82115
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a3677bf..b380143 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3627,13 +3627,12 @@
// directives: 'parallel' with 'for' directive.
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
Action.Enter(CGF);
- CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(), emitForLoopBounds,
- emitDispatchForLoopBounds);
+ (void)emitWorksharingDirective(CGF, S, /*HasCancel=*/false);
};
{
auto LPCRegion =
CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
- emitCommonOMPParallelDirective(*this, S, OMPD_simd, CodeGen,
+ emitCommonOMPParallelDirective(*this, S, OMPD_for_simd, CodeGen,
emitEmptyBoundParameters);
}
// Check for outer lastprivate conditional update.