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: #[[ATTR:[0-9]+]] 11 // CHECK: fdiv{{.*}}, 12 // NODIVOPT: !fpmath ![[MD:[0-9]+]] 13 // DIVOPT-NOT: !fpmath ![[MD:[0-9]+]] 14 return a / b; 15} 16 17float4 spvectordiv(float4 a, float4 b) { 18 // CHECK: @spvectordiv 19 // CHECK: #[[ATTR]] 20 // CHECK: fdiv{{.*}}, 21 // NODIVOPT: !fpmath ![[MD]] 22 // DIVOPT-NOT: !fpmath ![[MD]] 23 return a / b; 24} 25 26#if __OPENCL_C_VERSION__ >=120 27void printf(constant char* fmt, ...); 28 29void testdbllit(long *val) { 30 // CHECK-FLT: float 2.000000e+01 31 // CHECK-DBL: double 2.000000e+01 32 printf("%f", 20.0); 33} 34 35#endif 36 37#ifndef NOFP64 38#pragma OPENCL EXTENSION cl_khr_fp64 : enable 39double dpscalardiv(double a, double b) { 40 // CHECK: @dpscalardiv 41 // CHECK: #[[ATTR]] 42 // CHECK-NOT: !fpmath 43 return a / b; 44} 45#endif 46 47// CHECK: attributes #[[ATTR]] = { 48// NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false" 49// DIVOPT: "correctly-rounded-divide-sqrt-fp-math"="true" 50// CHECK: } 51// NODIVOPT: ![[MD]] = !{float 2.500000e+00} 52