95 lines · plain
1// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s2// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s3// 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 %s4// RUN: %clang_cc1 %s -emit-llvm -o - -DFP64 -cl-std=CL1.2 -triple spir-unknown-unknown -pedantic | FileCheck --check-prefix=CHECK-DBL %s5 6typedef __attribute__(( ext_vector_type(4) )) float float4;7 8float spscalardiv(float a, float b) {9 // CHECK: @spscalardiv10 // CHECK: fdiv{{.*}},11 // NODIVOPT: !fpmath ![[MD_FDIV:[0-9]+]]12 // DIVOPT-NOT: !fpmath !{{[0-9]+}}13 return a / b;14}15 16float4 spvectordiv(float4 a, float4 b) {17 // CHECK: @spvectordiv18 // CHECK: fdiv{{.*}},19 // NODIVOPT: !fpmath ![[MD_FDIV]]20 // DIVOPT-NOT: !fpmath !{{[0-9]+}}21 return a / b;22}23 24float spscalarsqrt(float a) {25 // CHECK-LABEL: @spscalarsqrt26 // NODIVOPT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]27 // DIVOPT: call float @llvm.sqrt.f32(float %{{.+}}){{$}}28 return __builtin_sqrtf(a);29}30 31float elementwise_sqrt_f32(float a) {32 // CHECK-LABEL: @elementwise_sqrt_f3233 // NODIVOPT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]34 // DIVOPT: call float @llvm.sqrt.f32(float %{{.+}}){{$}}35 return __builtin_elementwise_sqrt(a);36}37 38float4 elementwise_sqrt_v4f32(float4 a) {39 // CHECK-LABEL: @elementwise_sqrt_v4f3240 // NODIVOPT: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]41 // DIVOPT: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %{{.+}}){{$}}42 return __builtin_elementwise_sqrt(a);43}44 45 46#if __OPENCL_C_VERSION__ >=12047void printf(constant char* fmt, ...);48 49void testdbllit(long *val) {50 // CHECK-FLT: float noundef 2.000000e+0151 // CHECK-DBL: double noundef 2.000000e+0152 printf("%f", 20.0);53}54 55#endif56 57#ifndef NOFP6458#pragma OPENCL EXTENSION cl_khr_fp64 : enable59typedef __attribute__(( ext_vector_type(4) )) double double4;60 61double dpscalardiv(double a, double b) {62 // CHECK: @dpscalardiv63 // CHECK-NOT: !fpmath64 return a / b;65}66 67double4 dpvectordiv(double4 a, double4 b) {68 // CHECK: @dpvectordiv69 // CHECK-NOT: !fpmath70 return a / b;71}72 73double dpscalarsqrt(double a) {74 // CHECK-LABEL: @dpscalarsqrt75 // CHECK: call double @llvm.sqrt.f64(double %{{.+}}){{$}}76 return __builtin_sqrt(a);77}78 79double elementwise_sqrt_f64(double a) {80 // CHECK-LABEL: @elementwise_sqrt_f6481 // CHECK: call double @llvm.sqrt.f64(double %{{.+}}){{$}}82 return __builtin_elementwise_sqrt(a);83}84 85double4 elementwise_sqrt_v4f64(double4 a) {86 // CHECK-LABEL: @elementwise_sqrt_v4f6487 // CHECK: call <4 x double> @llvm.sqrt.v4f64(<4 x double> %{{.+}}){{$}}88 return __builtin_elementwise_sqrt(a);89}90 91#endif92 93// NODIVOPT: ![[MD_FDIV]] = !{float 2.500000e+00}94// NODIVOPT: ![[MD_SQRT]] = !{float 3.000000e+00}95