Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s |
Erich Keane | 14c1085 | 2018-05-01 14:16:15 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-pc-win32 | FileCheck %s |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 3 | |
| 4 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
| 5 | |
| 6 | |
| 7 | half test() |
| 8 | { |
| 9 | half x = 0.1f; |
| 10 | x+=2.0f; |
| 11 | x-=2.0f; |
| 12 | half y = x + x; |
| 13 | half z = y * 1.0f; |
| 14 | return z; |
| 15 | // CHECK: half 0xH3260 |
| 16 | } |
Ahmed Bougacha | 6ba3831 | 2015-03-24 23:44:42 +0000 | [diff] [blame] | 17 | |
| 18 | // CHECK-LABEL: @test_inc(half %x) |
| 19 | // CHECK: [[INC:%.*]] = fadd half %x, 0xH3C00 |
| 20 | // CHECK: ret half [[INC]] |
| 21 | half test_inc(half x) |
| 22 | { |
| 23 | return ++x; |
| 24 | } |
Egor Churaev | dd7d82c | 2017-05-29 07:44:22 +0000 | [diff] [blame] | 25 | |
| 26 | __attribute__((overloadable)) int min(int, int); |
| 27 | __attribute__((overloadable)) half min(half, half); |
| 28 | __attribute__((overloadable)) float min(float, float); |
| 29 | |
| 30 | __kernel void foo( __global half* buf, __global float* buf2 ) |
| 31 | { |
| 32 | buf[0] = min( buf[0], 1.5h ); |
| 33 | // CHECK: half 0xH3E00 |
| 34 | buf[0] = min( buf2[0], 1.5f ); |
| 35 | // CHECK: float 1.500000e+00 |
| 36 | |
| 37 | const half one = 1.6666; |
| 38 | buf[1] = min( buf[1], one ); |
| 39 | // CHECK: half 0xH3EAB |
| 40 | } |
| 41 | |