2016-08-10 04:10:18 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
|
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
|
2016-12-14 00:22:50 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.2 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-FLT %s
|
2016-12-14 01:04:33 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -DFP64 -cl-std=CL1.2 -triple spir-unknown-unknown -pedantic | FileCheck --check-prefix=CHECK-DBL %s
|
2011-10-28 03:19:51 +08:00
|
|
|
|
|
|
|
typedef __attribute__(( ext_vector_type(4) )) float float4;
|
|
|
|
|
|
|
|
float spscalardiv(float a, float b) {
|
|
|
|
// CHECK: @spscalardiv
|
2016-08-10 04:10:18 +08:00
|
|
|
// CHECK: fdiv{{.*}},
|
|
|
|
// NODIVOPT: !fpmath ![[MD:[0-9]+]]
|
2021-04-04 15:31:41 +08:00
|
|
|
// DIVOPT-NOT: !fpmath !{{[0-9]+}}
|
2011-10-28 03:19:51 +08:00
|
|
|
return a / b;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 spvectordiv(float4 a, float4 b) {
|
|
|
|
// CHECK: @spvectordiv
|
2016-08-10 04:10:18 +08:00
|
|
|
// CHECK: fdiv{{.*}},
|
|
|
|
// NODIVOPT: !fpmath ![[MD]]
|
2021-04-04 15:31:41 +08:00
|
|
|
// DIVOPT-NOT: !fpmath !{{[0-9]+}}
|
2011-10-28 03:19:51 +08:00
|
|
|
return a / b;
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:22:50 +08:00
|
|
|
#if __OPENCL_C_VERSION__ >=120
|
|
|
|
void printf(constant char* fmt, ...);
|
|
|
|
|
|
|
|
void testdbllit(long *val) {
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK-FLT: float 2.000000e+01
|
|
|
|
// CHECK-DBL: double 2.000000e+01
|
2016-12-14 00:22:50 +08:00
|
|
|
printf("%f", 20.0);
|
|
|
|
}
|
2011-10-28 03:19:51 +08:00
|
|
|
|
2016-12-14 00:22:50 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NOFP64
|
|
|
|
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
2011-10-28 03:19:51 +08:00
|
|
|
double dpscalardiv(double a, double b) {
|
|
|
|
// CHECK: @dpscalardiv
|
2012-04-14 20:37:26 +08:00
|
|
|
// CHECK-NOT: !fpmath
|
2011-10-28 03:19:51 +08:00
|
|
|
return a / b;
|
|
|
|
}
|
2016-12-14 00:22:50 +08:00
|
|
|
#endif
|
2011-10-28 03:19:51 +08:00
|
|
|
|
2016-08-10 04:10:18 +08:00
|
|
|
// NODIVOPT: ![[MD]] = !{float 2.500000e+00}
|