From: Alexey Bataev Date: Mon, 18 Jun 2018 17:11:45 +0000 (+0000) Subject: [OPENMP, NVPTX] Emit simple reduction if requested. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ec623490af2011ba3f67cd31ce045d581e452b5;p=clang [OPENMP, NVPTX] Emit simple reduction if requested. If simple reduction is requested, use the simple reduction instead of the runtime functions calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334962 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index 785ed56760..9452bdea4c 100644 --- a/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -3163,6 +3163,12 @@ void CGOpenMPRuntimeNVPTX::emitReduction( assert((TeamsReduction || ParallelReduction || SimdReduction) && "Invalid reduction selection in emitReduction."); + if (Options.SimpleReduction) { + CGOpenMPRuntime::emitReduction(CGF, Loc, Privates, LHSExprs, RHSExprs, + ReductionOps, Options); + return; + } + ASTContext &C = CGM.getContext(); // 1. Build a list of reduction variables. diff --git a/test/OpenMP/nvptx_target_simd_codegen.cpp b/test/OpenMP/nvptx_target_simd_codegen.cpp index 5f307d8835..89ea173add 100644 --- a/test/OpenMP/nvptx_target_simd_codegen.cpp +++ b/test/OpenMP/nvptx_target_simd_codegen.cpp @@ -78,9 +78,8 @@ int bar(int n){ // CHECK: call void @__kmpc_kernel_init(i32 %{{.+}}, i16 1) // CHECK-NOT: call void @__kmpc_for_static_init // CHECK-NOT: call void @__kmpc_for_static_fini -// CHECK: [[RES:%.+]] = call i32 @__kmpc_nvptx_simd_reduce_nowait(i32 %{{.+}}, i32 1, i{{64|32}} {{8|4}}, i8* %{{.+}}, void (i8*, i16, i16, i16)* @{{.+}}, void (i8*, i32)* @{{.+}}) -// CHECK: switch i32 [[RES]] -// CHECK: call void @__kmpc_nvptx_end_reduce_nowait(i32 %{{.+}}) +// CHECK-NOT: call i32 @__kmpc_nvptx_simd_reduce_nowait( +// CHECK-NOT: call void @__kmpc_nvptx_end_reduce_nowait( // CHECK: call void @__kmpc_kernel_deinit(i16 1) // CHECK: ret void