diff options
author | Carlo Bertolli <cbertol@us.ibm.com> | 2018-02-22 19:38:14 +0000 |
---|---|---|
committer | Carlo Bertolli <cbertol@us.ibm.com> | 2018-02-22 19:38:14 +0000 |
commit | beda214996f6b4ed426490ed853bf0a5912a2c7d (patch) | |
tree | 3848d5b125b6ddb4b5901b3e35857c9e08b4d582 /clang/lib/CodeGen | |
parent | 401b2a463c1230dcae12472457d6fce5176a8c29 (diff) | |
download | bcm5719-llvm-beda214996f6b4ed426490ed853bf0a5912a2c7d.tar.gz bcm5719-llvm-beda214996f6b4ed426490ed853bf0a5912a2c7d.zip |
[OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'
Differential Revision: https://reviews.llvm.org/D43513
This is a bug fix that removes the emission of reduction support for pragma 'distribute' when found alone or in combinations without simd.
Pragma 'distribute' does not have a reduction clause, but when combined with pragma 'simd' we need to emit the support for simd's reduction clause as part of code generation for distribute. This guard is similar to the one used for reduction support earlier in the same code gen function.
llvm-svn: 325822
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index b4cc7ad63ce..bf9a2572231 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3358,26 +3358,30 @@ void CodeGenFunction::EmitOMPDistributeLoop(const OMPLoopDirective &S, CGF.EmitLoadOfScalar(IL, S.getLocStart())); }); } - OpenMPDirectiveKind ReductionKind = OMPD_unknown; - if (isOpenMPParallelDirective(S.getDirectiveKind()) && - isOpenMPSimdDirective(S.getDirectiveKind())) { - ReductionKind = OMPD_parallel_for_simd; - } else if (isOpenMPParallelDirective(S.getDirectiveKind())) { - ReductionKind = OMPD_parallel_for; - } else if (isOpenMPSimdDirective(S.getDirectiveKind())) { - ReductionKind = OMPD_simd; - } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) && - S.hasClausesOfKind<OMPReductionClause>()) { - llvm_unreachable( - "No reduction clauses is allowed in distribute directive."); + if (isOpenMPSimdDirective(S.getDirectiveKind()) && + !isOpenMPParallelDirective(S.getDirectiveKind()) && + !isOpenMPTeamsDirective(S.getDirectiveKind())) { + OpenMPDirectiveKind ReductionKind = OMPD_unknown; + if (isOpenMPParallelDirective(S.getDirectiveKind()) && + isOpenMPSimdDirective(S.getDirectiveKind())) { + ReductionKind = OMPD_parallel_for_simd; + } else if (isOpenMPParallelDirective(S.getDirectiveKind())) { + ReductionKind = OMPD_parallel_for; + } else if (isOpenMPSimdDirective(S.getDirectiveKind())) { + ReductionKind = OMPD_simd; + } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) && + S.hasClausesOfKind<OMPReductionClause>()) { + llvm_unreachable( + "No reduction clauses is allowed in distribute directive."); + } + EmitOMPReductionClauseFinal(S, ReductionKind); + // Emit post-update of the reduction variables if IsLastIter != 0. + emitPostUpdateForReductionClause( + *this, S, [&](CodeGenFunction &CGF) -> llvm::Value * { + return CGF.Builder.CreateIsNotNull( + CGF.EmitLoadOfScalar(IL, S.getLocStart())); + }); } - EmitOMPReductionClauseFinal(S, ReductionKind); - // Emit post-update of the reduction variables if IsLastIter != 0. - emitPostUpdateForReductionClause( - *this, S, [&](CodeGenFunction &CGF) -> llvm::Value * { - return CGF.Builder.CreateIsNotNull( - CGF.EmitLoadOfScalar(IL, S.getLocStart())); - }); // Emit final copy of the lastprivate variables if IsLastIter != 0. if (HasLastprivateClause) { EmitOMPLastprivateClauseFinal( |