1// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
2// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=clc++ -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
3
4#pragma OPENCL EXTENSION cl_khr_fp64 : enable
5
6typedef int int4 __attribute((ext_vector_type(4)));
7typedef long long4 __attribute((ext_vector_type(4)));
8typedef float float4 __attribute((ext_vector_type(4)));
9typedef double double4 __attribute((ext_vector_type(4)));
10
11// CHECK: floatops
12kernel void floatops(global int4 *out, global float4 *fout) {
13  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
14  out[0] = (float4)(1, 1, 1, 1) && 1.0f;
15  // CHECK: store <4 x i32> zeroinitializer
16  out[1] = (float4)(0, 0, 0, 0) && (float4)(0, 0, 0, 0);
17
18  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
19  out[2] = (float4)(0, 0, 0, 0) || (float4)(1, 1, 1, 1);
20  // CHECK: store <4 x i32> zeroinitializer
21  out[3] = (float4)(0, 0, 0, 0) || 0.0f;
22
23  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
24  out[4] = !(float4)(0, 0, 0, 0);
25  // CHECK: store <4 x i32> zeroinitializer
26  out[5] = !(float4)(1, 2, 3, 4);
27  // CHECK: store <4 x i32> <i32 -1, i32 0, i32 -1, i32 0>
28  out[6] = !(float4)(0, 1, 0, 1);
29  // CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
30  fout[0] = (float4)(!0.0f);
31  // CHECK: store <4 x float> zeroinitializer
32  fout[1] = (float4)(!1.0f);
33}
34
35// CHECK: doubleops
36kernel void doubleops(global long4 *out, global double4 *dout) {
37  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
38  out[0] = (double4)(1, 1, 1, 1) && 1.0;
39  // CHECK: store <4 x i64> zeroinitializer
40  out[1] = (double4)(0, 0, 0, 0) && (double4)(0, 0, 0, 0);
41
42  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
43  out[2] = (double4)(0, 0, 0, 0) || (double4)(1, 1, 1, 1);
44  // CHECK: store <4 x i64> zeroinitializer
45  out[3] = (double4)(0, 0, 0, 0) || 0.0f;
46
47  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
48  out[4] = !(double4)(0, 0, 0, 0);
49  // CHECK: store <4 x i64> zeroinitializer
50  out[5] = !(double4)(1, 2, 3, 4);
51  // CHECK: store <4 x i64> <i64 -1, i64 0, i64 -1, i64 0>
52  out[6] = !(double4)(0, 1, 0, 1);
53  // CHECK: store <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>
54  dout[0] = (double4)(!0.0f);
55  // CHECK: store <4 x double> zeroinitializer
56  dout[1] = (double4)(!1.0f);
57}
58