1// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
2// 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
3// 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
4// RUN: %clang_cc1 %s -emit-llvm -o - -DFP64 -cl-std=CL1.2 -triple spir-unknown-unknown -pedantic | FileCheck --check-prefix=CHECK-DBL %s
5
6typedef __attribute__(( ext_vector_type(4) )) float float4;
7
8float spscalardiv(float a, float b) {
9  // CHECK: @spscalardiv
10  // CHECK: fdiv{{.*}},
11  // NODIVOPT: !fpmath ![[MD:[0-9]+]]
12  // DIVOPT-NOT: !fpmath !{{[0-9]+}}
13  return a / b;
14}
15
16float4 spvectordiv(float4 a, float4 b) {
17  // CHECK: @spvectordiv
18  // CHECK: fdiv{{.*}},
19  // NODIVOPT: !fpmath ![[MD]]
20  // DIVOPT-NOT: !fpmath !{{[0-9]+}}
21  return a / b;
22}
23
24#if __OPENCL_C_VERSION__ >=120
25void printf(constant char* fmt, ...);
26
27void testdbllit(long *val) {
28  // CHECK-FLT: float 2.000000e+01
29  // CHECK-DBL: double 2.000000e+01
30  printf("%f", 20.0);
31}
32
33#endif
34
35#ifndef NOFP64
36#pragma OPENCL EXTENSION cl_khr_fp64 : enable
37double dpscalardiv(double a, double b) {
38  // CHECK: @dpscalardiv
39  // CHECK-NOT: !fpmath
40  return a / b;
41}
42#endif
43
44// NODIVOPT: ![[MD]] = !{float 2.500000e+00}
45