[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Headers / nvptx_device_math_modf.cpp
blobfdd87c5915e5b215a0fd9fe838a0469cf5e83d5c
1 // REQUIRES: nvptx-registered-target
2 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
3 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
5 #include <cmath>
7 // 4 calls to modf(f), all translated to __nv_modf calls:
9 // CHECK-NOT: _Z.modf
10 // CHECK: call noundef double @__nv_modf(double
11 // CHECK-NOT: _Z.modf
12 // CHECK: call noundef float @__nv_modff(float
13 // CHECK-NOT: _Z.modf
14 // CHECK: call noundef double @__nv_modf(double
15 // CHECK-NOT: _Z.modf
16 // CHECK: call noundef float @__nv_modff(float
17 // CHECK-NOT: _Z.modf
19 template<typename T>
20 void test_modf(T x)
22 T dx;
23 int intx;
25 #pragma omp target map(from: intx, dx)
27 T ipart;
28 dx = std::modf(x, &ipart);
29 intx = static_cast<int>(ipart);
33 int main()
36 #if !defined(C_ONLY)
37 test_modf<double>(1.0);
38 test_modf<float>(1.0);
39 #endif
41 #pragma omp target
43 double intpart, res;
44 res = modf(1.1, &intpart);
47 #pragma omp target
49 float intpart, res;
50 res = modff(1.1f, &intpart);