Skip to content

Commit 7a70ce6

Browse files
author
Anagha Rajendra Rao
committed
add spirv f16 and scalar tests
1 parent a2a15fd commit 7a70ce6

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

clang/test/CodeGenSPIRV/Builtins/refract.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1-
// RUN: %clang_cc1 -O1 -triple spirv-pc-vulkan-compute %s -emit-llvm -o - | FileCheck %s
1+
// RUN: %clang_cc1 -O1 -triple spirv-pc-vulkan-compute %s -fnative-half-type -emit-llvm -o - | FileCheck %s
22

3+
typedef _Float16 half;
4+
typedef half half2 __attribute__((ext_vector_type(2)));
5+
typedef half half3 __attribute__((ext_vector_type(3)));
6+
typedef half half4 __attribute__((ext_vector_type(4)));
37
typedef float float2 __attribute__((ext_vector_type(2)));
48
typedef float float3 __attribute__((ext_vector_type(3)));
59
typedef float float4 __attribute__((ext_vector_type(4)));
610

11+
// CHECK-LABEL: define spir_func half @test_refract_half(
12+
// CHECK-SAME: half noundef [[I:%.*]], half noundef [[N:%.*]], half noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
13+
// CHECK-NEXT: [[ENTRY:.*:]]
14+
// CHECK: [[SPV_REFRACT:%.*]] = tail call half @llvm.spv.refract.f16.f16(half [[I]], half [[N]], half [[ETA]])
15+
// CHECK-NEXT: ret half [[SPV_REFRACT]]
16+
//
17+
half test_refract_half(half I, half N, half eta) { return __builtin_spirv_refract(I, N, eta); }
18+
19+
// CHECK-LABEL: define spir_func <2 x half> @test_refract_half2(
20+
// CHECK-SAME: <2 x half> noundef [[I:%.*]], <2 x half> noundef [[N:%.*]], half noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
21+
// CHECK-NEXT: [[ENTRY:.*:]]
22+
// CHECK: [[SPV_REFRACT:%.*]] = tail call <2 x half> @llvm.spv.refract.v2f16.f16(<2 x half> [[I]], <2 x half> [[N]], half [[ETA]])
23+
// CHECK-NEXT: ret <2 x half> [[SPV_REFRACT]]
24+
//
25+
half2 test_refract_half2(half2 I, half2 N, half eta) { return __builtin_spirv_refract(I, N, eta); }
26+
27+
// CHECK-LABEL: define spir_func <3 x half> @test_refract_half3(
28+
// CHECK-SAME: <3 x half> noundef [[I:%.*]], <3 x half> noundef [[N:%.*]], half noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0]] {
29+
// CHECK-NEXT: [[ENTRY:.*:]]
30+
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <3 x half> @llvm.spv.refract.v3f16.f16(<3 x half> [[I]], <3 x half> [[N]], half [[ETA]])
31+
// CHECK-NEXT: ret <3 x half> [[SPV_REFRACT]]
32+
//
33+
half3 test_refract_half3(half3 I, half3 N, half eta) { return __builtin_spirv_refract(I, N, eta); }
34+
35+
// CHECK-LABEL: define spir_func <4 x half> @test_refract_half4(
36+
// CHECK-SAME: <4 x half> noundef [[I:%.*]], <4 x half> noundef [[N:%.*]], half noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0]] {
37+
// CHECK-NEXT: [[ENTRY:.*:]]
38+
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <4 x half> @llvm.spv.refract.v4f16.f16(<4 x half> [[I]], <4 x half> [[N]], half [[ETA]])
39+
// CHECK-NEXT: ret <4 x half> [[SPV_REFRACT]]
40+
//
41+
half4 test_refract_half4(half4 I, half4 N, half eta) { return __builtin_spirv_refract(I, N, eta); }
42+
43+
44+
// CHECK-LABEL: define spir_func float @test_refract_float(
45+
// CHECK-SAME: float noundef [[I:%.*]], float noundef [[N:%.*]], float noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
46+
// CHECK-NEXT: [[ENTRY:.*:]]
47+
// CHECK: [[SPV_REFRACT:%.*]] = tail call float @llvm.spv.refract.f32.f32(float [[I]], float [[N]], float [[ETA]])
48+
// CHECK-NEXT: ret float [[SPV_REFRACT]]
49+
//
50+
float test_refract_float(float I, float N, float eta) { return __builtin_spirv_refract(I, N, eta); }
51+
752
// CHECK-LABEL: define spir_func <2 x float> @test_refract_float2(
853
// CHECK-SAME: <2 x float> noundef [[I:%.*]], <2 x float> noundef [[N:%.*]], float noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
954
// CHECK-NEXT: [[ENTRY:.*:]]

0 commit comments

Comments
 (0)