@@ -2083,15 +2083,6 @@ void CodeGenFunction::EmitOMPSimdInit(const OMPLoopDirective &D,
2083
2083
if (const auto *C = D.getSingleClause <OMPOrderClause>())
2084
2084
if (C->getKind () == OMPC_ORDER_concurrent)
2085
2085
LoopStack.setParallel (/* Enable=*/ true );
2086
- if ((D.getDirectiveKind () == OMPD_simd ||
2087
- (getLangOpts ().OpenMPSimd &&
2088
- isOpenMPSimdDirective (D.getDirectiveKind ()))) &&
2089
- llvm::any_of (D.getClausesOfKind <OMPReductionClause>(),
2090
- [](const OMPReductionClause *C) {
2091
- return C->getModifier () == OMPC_REDUCTION_inscan;
2092
- }))
2093
- // Disable parallel access in case of prefix sum.
2094
- LoopStack.setParallel (/* Enable=*/ false );
2095
2086
}
2096
2087
2097
2088
void CodeGenFunction::EmitOMPSimdFinal (
@@ -2287,8 +2278,6 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const OMPLoopDirective &S,
2287
2278
}
2288
2279
2289
2280
void CodeGenFunction::EmitOMPSimdDirective (const OMPSimdDirective &S) {
2290
- ParentLoopDirectiveForScanRegion ScanRegion (*this , S);
2291
- OMPFirstScanLoop = true ;
2292
2281
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
2293
2282
emitOMPSimdRegion (CGF, S, Action);
2294
2283
};
@@ -4210,15 +4199,14 @@ void CodeGenFunction::EmitOMPDepobjDirective(const OMPDepobjDirective &S) {
4210
4199
}
4211
4200
4212
4201
void CodeGenFunction::EmitOMPScanDirective (const OMPScanDirective &S) {
4213
- if (!OMPParentLoopDirectiveForScan)
4202
+ // Do not emit code for non-simd directives in simd-only mode.
4203
+ if (getLangOpts ().OpenMPSimd && !OMPParentLoopDirectiveForScan)
4214
4204
return ;
4215
4205
const OMPExecutableDirective &ParentDir = *OMPParentLoopDirectiveForScan;
4216
- bool IsInclusive = S.hasClausesOfKind <OMPInclusiveClause>();
4217
4206
SmallVector<const Expr *, 4 > Shareds;
4218
4207
SmallVector<const Expr *, 4 > Privates;
4219
4208
SmallVector<const Expr *, 4 > LHSs;
4220
4209
SmallVector<const Expr *, 4 > RHSs;
4221
- SmallVector<const Expr *, 4 > ReductionOps;
4222
4210
SmallVector<const Expr *, 4 > CopyOps;
4223
4211
SmallVector<const Expr *, 4 > CopyArrayTemps;
4224
4212
SmallVector<const Expr *, 4 > CopyArrayElems;
@@ -4229,109 +4217,13 @@ void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) {
4229
4217
Privates.append (C->privates ().begin (), C->privates ().end ());
4230
4218
LHSs.append (C->lhs_exprs ().begin (), C->lhs_exprs ().end ());
4231
4219
RHSs.append (C->rhs_exprs ().begin (), C->rhs_exprs ().end ());
4232
- ReductionOps.append (C->reduction_ops ().begin (), C->reduction_ops ().end ());
4233
4220
CopyOps.append (C->copy_ops ().begin (), C->copy_ops ().end ());
4234
4221
CopyArrayTemps.append (C->copy_array_temps ().begin (),
4235
4222
C->copy_array_temps ().end ());
4236
4223
CopyArrayElems.append (C->copy_array_elems ().begin (),
4237
4224
C->copy_array_elems ().end ());
4238
4225
}
4239
- if (ParentDir.getDirectiveKind () == OMPD_simd ||
4240
- (getLangOpts ().OpenMPSimd &&
4241
- isOpenMPSimdDirective (ParentDir.getDirectiveKind ()))) {
4242
- // For simd directive and simd-based directives in simd only mode, use the
4243
- // following codegen:
4244
- // int x = 0;
4245
- // #pragma omp simd reduction(inscan, +: x)
4246
- // for (..) {
4247
- // <first part>
4248
- // #pragma omp scan inclusive(x)
4249
- // <second part>
4250
- // }
4251
- // is transformed to:
4252
- // int x = 0;
4253
- // for (..) {
4254
- // int x_priv = 0;
4255
- // <first part>
4256
- // x = x_priv + x;
4257
- // x_priv = x;
4258
- // <second part>
4259
- // }
4260
- // and
4261
- // int x = 0;
4262
- // #pragma omp simd reduction(inscan, +: x)
4263
- // for (..) {
4264
- // <first part>
4265
- // #pragma omp scan exclusive(x)
4266
- // <second part>
4267
- // }
4268
- // to
4269
- // int x = 0;
4270
- // for (..) {
4271
- // int x_priv = 0;
4272
- // <second part>
4273
- // int temp = x;
4274
- // x = x_priv + x;
4275
- // x_priv = temp;
4276
- // <first part>
4277
- // }
4278
- llvm::BasicBlock *OMPScanReduce = createBasicBlock (" omp.inscan.reduce" );
4279
- EmitBranch (IsInclusive
4280
- ? OMPScanReduce
4281
- : BreakContinueStack.back ().ContinueBlock .getBlock ());
4282
- EmitBlock (OMPScanDispatch);
4283
- {
4284
- // New scope for correct construction/destruction of temp variables for
4285
- // exclusive scan.
4286
- LexicalScope Scope (*this , S.getSourceRange ());
4287
- EmitBranch (IsInclusive ? OMPBeforeScanBlock : OMPAfterScanBlock);
4288
- EmitBlock (OMPScanReduce);
4289
- if (!IsInclusive) {
4290
- // Create temp var and copy LHS value to this temp value.
4291
- // TMP = LHS;
4292
- for (unsigned I = 0 , E = CopyArrayElems.size (); I < E; ++I) {
4293
- const Expr *PrivateExpr = Privates[I];
4294
- const Expr *TempExpr = CopyArrayTemps[I];
4295
- EmitAutoVarDecl (
4296
- *cast<VarDecl>(cast<DeclRefExpr>(TempExpr)->getDecl ()));
4297
- LValue DestLVal = EmitLValue (TempExpr);
4298
- LValue SrcLVal = EmitLValue (LHSs[I]);
4299
- EmitOMPCopy (PrivateExpr->getType (), DestLVal.getAddress (*this ),
4300
- SrcLVal.getAddress (*this ),
4301
- cast<VarDecl>(cast<DeclRefExpr>(LHSs[I])->getDecl ()),
4302
- cast<VarDecl>(cast<DeclRefExpr>(RHSs[I])->getDecl ()),
4303
- CopyOps[I]);
4304
- }
4305
- }
4306
- CGM.getOpenMPRuntime ().emitReduction (
4307
- *this , ParentDir.getEndLoc (), Privates, LHSs, RHSs, ReductionOps,
4308
- {/* WithNowait=*/ true , /* SimpleReduction=*/ true , OMPD_simd});
4309
- for (unsigned I = 0 , E = CopyArrayElems.size (); I < E; ++I) {
4310
- const Expr *PrivateExpr = Privates[I];
4311
- LValue DestLVal;
4312
- LValue SrcLVal;
4313
- if (IsInclusive) {
4314
- DestLVal = EmitLValue (RHSs[I]);
4315
- SrcLVal = EmitLValue (LHSs[I]);
4316
- } else {
4317
- const Expr *TempExpr = CopyArrayTemps[I];
4318
- DestLVal = EmitLValue (RHSs[I]);
4319
- SrcLVal = EmitLValue (TempExpr);
4320
- }
4321
- EmitOMPCopy (PrivateExpr->getType (), DestLVal.getAddress (*this ),
4322
- SrcLVal.getAddress (*this ),
4323
- cast<VarDecl>(cast<DeclRefExpr>(LHSs[I])->getDecl ()),
4324
- cast<VarDecl>(cast<DeclRefExpr>(RHSs[I])->getDecl ()),
4325
- CopyOps[I]);
4326
- }
4327
- }
4328
- EmitBranch (IsInclusive ? OMPAfterScanBlock : OMPBeforeScanBlock);
4329
- OMPScanExitBlock = IsInclusive
4330
- ? BreakContinueStack.back ().ContinueBlock .getBlock ()
4331
- : OMPScanReduce;
4332
- EmitBlock (OMPAfterScanBlock);
4333
- return ;
4334
- }
4226
+ bool IsInclusive = S.hasClausesOfKind <OMPInclusiveClause>();
4335
4227
if (!IsInclusive) {
4336
4228
EmitBranch (BreakContinueStack.back ().ContinueBlock .getBlock ());
4337
4229
EmitBlock (OMPScanExitBlock);
@@ -6485,7 +6377,6 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
6485
6377
}
6486
6378
if (isOpenMPSimdDirective (D.getDirectiveKind ())) {
6487
6379
(void )GlobalsScope.Privatize ();
6488
- ParentLoopDirectiveForScanRegion ScanRegion (CGF, D);
6489
6380
emitOMPSimdRegion (CGF, cast<OMPLoopDirective>(D), Action);
6490
6381
} else {
6491
6382
if (const auto *LD = dyn_cast<OMPLoopDirective>(&D)) {
0 commit comments