File: logical-ops.cl

package info (click to toggle)
llvm-toolchain-3.9 1%3A3.9.1-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 441,144 kB
  • ctags: 428,836
  • sloc: cpp: 2,546,577; ansic: 538,318; asm: 119,677; objc: 103,316; python: 102,148; sh: 27,847; pascal: 5,626; ml: 5,510; perl: 5,293; lisp: 4,801; makefile: 2,177; xml: 686; cs: 362; php: 212; csh: 117
file content (56 lines) | stat: -rw-r--r-- 2,338 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

typedef int int4 __attribute((ext_vector_type(4)));
typedef long long4 __attribute((ext_vector_type(4)));
typedef float float4 __attribute((ext_vector_type(4)));
typedef double double4 __attribute((ext_vector_type(4)));

// CHECK: floatops
kernel void floatops(global int4 *out, global float4 *fout) {
  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  out[0] = (float4)(1, 1, 1, 1) && 1.0f;
  // CHECK: store <4 x i32> zeroinitializer
  out[1] = (float4)(0, 0, 0, 0) && (float4)(0, 0, 0, 0);

  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  out[2] = (float4)(0, 0, 0, 0) || (float4)(1, 1, 1, 1);
  // CHECK: store <4 x i32> zeroinitializer
  out[3] = (float4)(0, 0, 0, 0) || 0.0f;

  // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  out[4] = !(float4)(0, 0, 0, 0);
  // CHECK: store <4 x i32> zeroinitializer
  out[5] = !(float4)(1, 2, 3, 4);
  // CHECK: store <4 x i32> <i32 -1, i32 0, i32 -1, i32 0>
  out[6] = !(float4)(0, 1, 0, 1);
  // CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
  fout[0] = (float4)(!0.0f);
  // CHECK: store <4 x float> zeroinitializer
  fout[1] = (float4)(!1.0f);
}

// CHECK: doubleops
kernel void doubleops(global long4 *out, global double4 *dout) {
  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
  out[0] = (double4)(1, 1, 1, 1) && 1.0;
  // CHECK: store <4 x i64> zeroinitializer
  out[1] = (double4)(0, 0, 0, 0) && (double4)(0, 0, 0, 0);

  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
  out[2] = (double4)(0, 0, 0, 0) || (double4)(1, 1, 1, 1);
  // CHECK: store <4 x i64> zeroinitializer
  out[3] = (double4)(0, 0, 0, 0) || 0.0f;

  // CHECK: store <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
  out[4] = !(double4)(0, 0, 0, 0);
  // CHECK: store <4 x i64> zeroinitializer
  out[5] = !(double4)(1, 2, 3, 4);
  // CHECK: store <4 x i64> <i64 -1, i64 0, i64 -1, i64 0>
  out[6] = !(double4)(0, 1, 0, 1);
  // CHECK: store <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>
  dout[0] = (double4)(!0.0f);
  // CHECK: store <4 x double> zeroinitializer
  dout[1] = (double4)(!1.0f);
}