1// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s
2// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
3
4typedef __attribute__((ext_vector_type(2))) float float2;
5typedef __attribute__((ext_vector_type(2))) half half2;
6
7#ifdef cl_khr_fp64
8typedef __attribute__((ext_vector_type(2))) double double2;
9#endif
10
11int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
12
13
14// ALL-LABEL: @test_printf_float2(
15// FP64: %conv = fpext <2 x float> %0 to <2 x double>
16// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv)
17
18// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
19kernel void test_printf_float2(float2 arg) {
20  printf("%v2f", arg);
21}
22
23// ALL-LABEL: @test_printf_half2(
24// FP64: %conv = fpext <2 x half> %0 to <2 x double>
25// FP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv) #2
26
27// NOFP64: %conv = fpext <2 x half> %0 to <2 x float>
28// NOFP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %conv) #2
29kernel void test_printf_half2(half2 arg) {
30  printf("%v2f", arg);
31}
32
33#ifdef cl_khr_fp64
34// FP64-LABEL: @test_printf_double2(
35// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %0) #2
36kernel void test_printf_double2(double2 arg) {
37  printf("%v2f", arg);
38}
39#endif
40