/// Check if the parallel directive has an 'if' clause with non-constant or
/// false condition.
static bool hasParallelIfClause(ASTContext &Ctx,
- const OMPExecutableDirective &D) {
+ const OMPExecutableDirective &D,
+ bool StandaloneParallel) {
for (const auto *C : D.getClausesOfKind<OMPIfClause>()) {
OpenMPDirectiveKind NameModifier = C->getNameModifier();
- if (NameModifier != OMPD_parallel && NameModifier != OMPD_unknown)
+ if (NameModifier != OMPD_parallel &&
+ (!StandaloneParallel || NameModifier != OMPD_unknown))
continue;
const Expr *Cond = C->getCondition();
bool Result;
switch (D.getDirectiveKind()) {
case OMPD_target:
if (isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NestedDir))
+ !hasParallelIfClause(Ctx, *NestedDir, /*StandaloneParallel=*/true))
return true;
if (DKind == OMPD_teams) {
Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers(
dyn_cast_or_null<OMPExecutableDirective>(ChildStmt)) {
DKind = NND->getDirectiveKind();
if (isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NND))
+ !hasParallelIfClause(Ctx, *NND, /*StandaloneParallel=*/true))
return true;
}
}
return false;
case OMPD_target_teams:
return isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NestedDir);
+ !hasParallelIfClause(Ctx, *NestedDir, /*StandaloneParallel=*/true);
case OMPD_target_simd:
case OMPD_target_parallel:
case OMPD_target_parallel_for:
case OMPD_target_parallel_for_simd:
case OMPD_target_teams_distribute_parallel_for:
case OMPD_target_teams_distribute_parallel_for_simd:
- return !hasParallelIfClause(Ctx, D);
+ return !hasParallelIfClause(Ctx, D, /*StandaloneParallel=*/false);
case OMPD_target_simd:
case OMPD_target_teams_distribute:
case OMPD_target_teams_distribute_simd:
#ifndef HEADER
#define HEADER
+int a;
+
// CHECK-NOT: @__omp_offloading_{{.+}}_exec_mode = weak constant i8 1
// CHECK-DAG: [[DISTR_LIGHT:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2050, i32 3, i32 0, i8* getelementptr inbounds
// CHECK-DAG: [[FOR_LIGHT:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 514, i32 3, i32 0, i8* getelementptr inbounds
// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1, i16 {{.+}})
// CHECK-DAG: [[DISTR_FULL]]
// CHECK-DAG: [[FULL]]
-#pragma omp target teams distribute parallel for simd
+#pragma omp target teams distribute parallel for simd if(a)
for (int i = 0; i < 10; ++i)
;
#pragma omp target teams distribute parallel for simd schedule(static)
// CHECK-DAG: [[FULL]]
// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1, i16 {{.+}})
// CHECK-DAG: [[FULL]]
-#pragma omp target parallel for
+#pragma omp target parallel for if(a)
for (int i = 0; i < 10; ++i)
;
#pragma omp target parallel for schedule(static)
// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1, i16 {{.+}})
// CHECK-DAG: [[FULL]]
// CHECK-DAG: [[BAR_FULL]]
-#pragma omp target parallel
+#pragma omp target parallel if(a)
#pragma omp for simd
for (int i = 0; i < 10; ++i)
;