File: half.cl

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (41 lines) | stat: -rw-r--r-- 956 bytes parent folder | download | duplicates (16)
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
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-pc-win32 | FileCheck %s

#pragma OPENCL EXTENSION cl_khr_fp16 : enable


half test()
{
   half x = 0.1f;
   x+=2.0f;
   x-=2.0f;
   half y = x + x;
   half z = y * 1.0f;
   return z;
// CHECK: half 0xH3260
}

// CHECK-LABEL: @test_inc(half noundef %x)
// CHECK: [[INC:%.*]] = fadd half %x, 0xH3C00
// CHECK: ret half [[INC]]
half test_inc(half x)
{
  return ++x;
}

__attribute__((overloadable)) int min(int, int);
__attribute__((overloadable)) half min(half, half);
__attribute__((overloadable)) float min(float, float);

__kernel void foo( __global half* buf, __global float* buf2 )
{
    buf[0] = min( buf[0], 1.5h );
// CHECK: half noundef 0xH3E00
    buf[0] = min( buf2[0], 1.5f );
// CHECK: float noundef 1.500000e+00

    const half one = 1.6666;
    buf[1] = min( buf[1], one );
// CHECK: half noundef 0xH3EAB
}