Skip to content

Commit 2f9769b

Browse files
author
Anagha Rajendra Rao
committed
enable spirv scalar implementation
1 parent bfdbc69 commit 2f9769b

File tree

10 files changed

+55
-59
lines changed

10 files changed

+55
-59
lines changed

clang/lib/CodeGen/TargetBuiltins/SPIR.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
6666
E->getArg(1)->getType()->hasFloatingRepresentation() &&
6767
E->getArg(2)->getType()->isFloatingType() &&
6868
"refract operands must have a float representation");
69-
assert(E->getArg(0)->getType()->isVectorType() &&
70-
E->getArg(1)->getType()->isVectorType() &&
71-
"refract I and N operands must be a vector");
7269
return Builder.CreateIntrinsic(
7370
/*ReturnType=*/I->getType(), Intrinsic::spv_refract,
7471
ArrayRef<Value *>{I, N, eta}, nullptr, "spv.refract");

clang/lib/Headers/hlsl/hlsl_detail.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ template <typename T> struct is_arithmetic {
4545
static const bool Value = __is_arithmetic(T);
4646
};
4747

48-
template <typename T> struct is_vector {
49-
static const bool value = false;
50-
};
51-
52-
template <typename T, int N> struct is_vector<vector<T, N>> {
53-
static const bool value = true;
54-
};
55-
5648
template <typename T, int N>
5749
using HLSL_FIXED_VECTOR =
5850
vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;

clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
7373

7474
template <typename T, typename U> constexpr T refract_impl(T I, T N, U Eta) {
7575
#if (__has_builtin(__builtin_spirv_refract))
76-
if (is_vector<T>::value)
77-
return __builtin_spirv_refract(I, N, Eta);
76+
return __builtin_spirv_refract(I, N, Eta);
7877
#endif
7978
T Mul = dot(N, I);
8079
T K = 1 - Eta * Eta * (1 - Mul * Mul);

clang/lib/Sema/SemaSPIRV.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,27 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(const TargetInfo &TI,
287287
if (CheckAllArgTypesAreCorrect(&SemaRef, TheCall,
288288
llvm::ArrayRef(ChecksArr)))
289289
return true;
290+
// Check that first two arguments are vectors of the same type
291+
QualType Arg0Type = TheCall->getArg(0)->getType();
292+
if (!SemaRef.getASTContext().hasSameUnqualifiedType(
293+
Arg0Type, TheCall->getArg(1)->getType()))
294+
return SemaRef.Diag(TheCall->getBeginLoc(),
295+
diag::err_vec_builtin_incompatible_vector)
296+
<< TheCall->getDirectCallee() << /* first two */ 0
297+
<< SourceRange(TheCall->getArg(0)->getBeginLoc(),
298+
TheCall->getArg(1)->getEndLoc());
299+
300+
// Check that scalar type of 3rd arg is same as base type of first two args
301+
clang::QualType BaseType =
302+
Arg0Type->isVectorType()
303+
? Arg0Type->castAs<clang::VectorType>()->getElementType()
304+
: Arg0Type;
305+
if (!SemaRef.getASTContext().hasSameUnqualifiedType(
306+
BaseType, TheCall->getArg(2)->getType()))
307+
return SemaRef.Diag(TheCall->getBeginLoc(),
308+
diag::err_hlsl_builtin_scalar_vector_mismatch)
309+
<< /* all */ 0 << TheCall->getDirectCallee() << Arg0Type
310+
<< TheCall->getArg(2)->getType();
290311

291312
QualType RetTy = TheCall->getArg(0)->getType();
292313
TheCall->setType(RetTy);

clang/test/CodeGenHLSL/builtins/refract.hlsl

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) half @_Z17test_refract_halfDhDhDh(
2828
// SPVCHECK-SAME: half noundef nofpclass(nan inf) [[I:%.*]], half noundef nofpclass(nan inf) [[N:%.*]], half noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]]
2929
// SPVCHECK: [[ENTRY:.*:]]
30-
// SPVCHECK: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}}
31-
// SPVCHECK: [[MUL1_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}}
32-
// SPVCHECK: [[MUL2_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}}
33-
// SPVCHECK: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half 0xH3C00, [[MUL2_I]]
34-
// SPVCHECK: [[MUL3_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[MUL1_I]], [[SUB_I]]
35-
// SPVCHECK: [[SUB4_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half 0xH3C00, [[MUL3_I]]
36-
// SPVCHECK: [[MUL5_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}}
37-
// SPVCHECK: [[MUL6_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}}
38-
// SPVCHECK: [[TMP18:%.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.sqrt.f16(half %{{.*}})
39-
// SPVCHECK: [[ADD_I:%.*]] = fadd reassoc nnan ninf nsz arcp afn half [[MUL6_I]], [[TMP18]]
40-
// SPVCHECK: [[MUL7_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[ADD_I]], %{{.*}}
41-
// SPVCHECK: [[SUB8_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half [[MUL5_I]], [[MUL7_I]]
42-
// SPVCHECK: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half %{{.*}}, 0xH0000
43-
// SPVCHECK: [[HLSL_SELECT_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[CMP_I]], half 0xH0000, half %{{.*}}
44-
// SPVCHECK: ret half [[HLSL_SELECT_I]]
30+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.refract.f16.f16(half %{{.*}}, half %{{.*}}, half %{{.*}})
31+
// SPVCHECK: ret half [[SPV_REFRACT_I]]
4532
//
4633
half test_refract_half(half I, half N, half ETA) {
4734
return refract(I, N, ETA);
@@ -70,7 +57,7 @@ half test_refract_half(half I, half N, half ETA) {
7057
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <2 x half> @_Z18test_refract_half2Dv2_DhS_Dh(
7158
// SPVCHECK-SAME: <2 x half> noundef nofpclass(nan inf) [[I:%.*]], <2 x half> noundef nofpclass(nan inf) [[N:%.*]], half noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
7259
// SPVCHECK: [[ENTRY:.*:]]
73-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <2 x half> @llvm.spv.refract.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, half %{{.*}})
60+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <2 x half> @llvm.spv.refract.v2f16.f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, half %{{.*}})
7461
// SPVCHECK: ret <2 x half> [[SPV_REFRACT_I]]
7562
//
7663
half2 test_refract_half2(half2 I, half2 N, half ETA) {
@@ -100,7 +87,7 @@ half2 test_refract_half2(half2 I, half2 N, half ETA) {
10087
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <3 x half> @_Z18test_refract_half3Dv3_DhS_Dh(
10188
// SPVCHECK-SAME: <3 x half> noundef nofpclass(nan inf) [[I:%.*]], <3 x half> noundef nofpclass(nan inf) [[N:%.*]], half noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
10289
// SPVCHECK: [[ENTRY:.*:]]
103-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <3 x half> @llvm.spv.refract.v3f16(<3 x half> %{{.*}}, <3 x half> %{{.*}}, half %{{.*}})
90+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <3 x half> @llvm.spv.refract.v3f16.f16(<3 x half> %{{.*}}, <3 x half> %{{.*}}, half %{{.*}})
10491
// SPVCHECK: ret <3 x half> [[SPV_REFRACT_I]]
10592
//
10693
half3 test_refract_half3(half3 I, half3 N, half ETA) {
@@ -130,7 +117,7 @@ half3 test_refract_half3(half3 I, half3 N, half ETA) {
130117
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <4 x half> @_Z18test_refract_half4Dv4_DhS_Dh(
131118
// SPVCHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[I:%.*]], <4 x half> noundef nofpclass(nan inf) [[N:%.*]], half noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
132119
// SPVCHECK: [[ENTRY:.*:]]
133-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x half> @llvm.spv.refract.v4f16(<4 x half> %{{.*}}, <4 x half> %{{.*}}, half %{{.*}})
120+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x half> @llvm.spv.refract.v4f16.f16(<4 x half> %{{.*}}, <4 x half> %{{.*}}, half %{{.*}})
134121
// SPVCHECK: ret <4 x half> [[SPV_REFRACT_I]]
135122
//
136123
half4 test_refract_half4(half4 I, half4 N, half ETA) {
@@ -156,25 +143,11 @@ half4 test_refract_half4(half4 I, half4 N, half ETA) {
156143
// CHECK: [[HLSL_SELECT_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[CMP_I]], float 0.000000e+00, float %{{.*}}
157144
// CHECK: ret float [[HLSL_SELECT_I]]
158145
//
159-
//
160146
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) float @_Z18test_refract_floatfff(
161147
// SPVCHECK-SAME: float noundef nofpclass(nan inf) [[I:%.*]], float noundef nofpclass(nan inf) [[N:%.*]], float noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
162148
// SPVCHECK: [[ENTRY:.*:]]
163-
// SPVCHECK: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}}
164-
// SPVCHECK: [[MUL1_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}}
165-
// SPVCHECK: [[MUL2_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}}
166-
// SPVCHECK: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float 1.000000e+00, [[MUL2_I]]
167-
// SPVCHECK: [[MUL3_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[MUL1_I]], [[SUB_I]]
168-
// SPVCHECK: [[SUB4_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float 1.000000e+00, [[MUL3_I]]
169-
// SPVCHECK: [[MUL5_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}}
170-
// SPVCHECK: [[MUL6_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}}
171-
// SPVCHECK: [[TMP18:%.*]] = call reassoc nnan ninf nsz arcp afn float @llvm.sqrt.f32(float %{{.*}})
172-
// SPVCHECK: [[ADD_I:%.*]] = fadd reassoc nnan ninf nsz arcp afn float [[MUL6_I]], [[TMP18]]
173-
// SPVCHECK: [[MUL7_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[ADD_I]], %{{.*}}
174-
// SPVCHECK: [[SUB8_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float [[MUL5_I]], [[MUL7_I]]
175-
// SPVCHECK: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float %{{.*}}, 0.000000e+00
176-
// SPVCHECK: [[HLSL_SELECT_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[CMP_I]], float 0.000000e+00, float %{{.*}}
177-
// SPVCHECK: ret float [[HLSL_SELECT_I]]
149+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.refract.f32.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
150+
// SPVCHECK: ret float [[SPV_REFRACT_I]]
178151
//
179152
float test_refract_float(float I, float N, float ETA) {
180153
return refract(I, N, ETA);
@@ -203,7 +176,7 @@ float test_refract_float(float I, float N, float ETA) {
203176
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <2 x float> @_Z19test_refract_float2Dv2_fS_f(
204177
// SPVCHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[I:%.*]], <2 x float> noundef nofpclass(nan inf) [[N:%.*]], float noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
205178
// SPVCHECK: [[ENTRY:.*:]]
206-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <2 x float> @llvm.spv.refract.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, float %{{.*}})
179+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <2 x float> @llvm.spv.refract.v2f32.f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, float %{{.*}})
207180
// SPVCHECK: ret <2 x float> [[SPV_REFRACT_I]]
208181
//
209182
float2 test_refract_float2(float2 I, float2 N, float ETA) {
@@ -233,7 +206,7 @@ float2 test_refract_float2(float2 I, float2 N, float ETA) {
233206
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <3 x float> @_Z19test_refract_float3Dv3_fS_f(
234207
// SPVCHECK-SAME: <3 x float> noundef nofpclass(nan inf) [[I:%.*]], <3 x float> noundef nofpclass(nan inf) [[N:%.*]], float noundef nofpclass(nan inf) [[ETA:%.*]]) #[[ATTR0:[0-9]+]] {
235208
// SPVCHECK: [[ENTRY:.*:]]
236-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <3 x float> @llvm.spv.refract.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, float %{{.*}})
209+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <3 x float> @llvm.spv.refract.v3f32.f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, float %{{.*}})
237210
// SPVCHECK: ret <3 x float> [[SPV_REFRACT_I]]
238211
//
239212
float3 test_refract_float3(float3 I, float3 N, float ETA) {
@@ -263,7 +236,7 @@ float3 test_refract_float3(float3 I, float3 N, float ETA) {
263236
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) <4 x float> @_Z19test_refract_float4Dv4_fS_f(
264237
// SPVCHECK-SAME: <4 x float> noundef nofpclass(nan inf) %{{.*}}, <4 x float> noundef nofpclass(nan inf) %{{.*}}, float noundef nofpclass(nan inf) %{{.*}}) #[[ATTR0:[0-9]+]] {
265238
// SPVCHECK: [[ENTRY:.*:]]
266-
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x float> @llvm.spv.refract.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, float %{{.*}})
239+
// SPVCHECK: [[SPV_REFRACT_I:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x float> @llvm.spv.refract.v4f32.f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, float %{{.*}})
267240
// SPVCHECK: ret <4 x float> [[SPV_REFRACT_I]]
268241
//
269242
float4 test_refract_float4(float4 I, float4 N, float ETA) {

clang/test/CodeGenSPIRV/Builtins/refract.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ typedef float float4 __attribute__((ext_vector_type(4)));
77
// CHECK-LABEL: define spir_func <2 x float> @test_refract_float2(
88
// CHECK-SAME: <2 x float> noundef [[I:%.*]], <2 x float> noundef [[N:%.*]], float noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
99
// CHECK-NEXT: [[ENTRY:.*:]]
10-
// CHECK: [[SPV_REFRACT:%.*]] = tail call <2 x float> @llvm.spv.refract.v2f32(<2 x float> [[I]], <2 x float> [[N]], float [[ETA]])
10+
// CHECK: [[SPV_REFRACT:%.*]] = tail call <2 x float> @llvm.spv.refract.v2f32.f32(<2 x float> [[I]], <2 x float> [[N]], float [[ETA]])
1111
// CHECK-NEXT: ret <2 x float> [[SPV_REFRACT]]
1212
//
1313
float2 test_refract_float2(float2 I, float2 N, float eta) { return __builtin_spirv_refract(I, N, eta); }
1414

1515
// CHECK-LABEL: define spir_func <3 x float> @test_refract_float3(
1616
// CHECK-SAME: <3 x float> noundef [[I:%.*]], <3 x float> noundef [[N:%.*]], float noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0]] {
1717
// CHECK-NEXT: [[ENTRY:.*:]]
18-
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <3 x float> @llvm.spv.refract.v3f32(<3 x float> [[I]], <3 x float> [[N]], float [[ETA]])
18+
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <3 x float> @llvm.spv.refract.v3f32.f32(<3 x float> [[I]], <3 x float> [[N]], float [[ETA]])
1919
// CHECK-NEXT: ret <3 x float> [[SPV_REFRACT]]
2020
//
2121
float3 test_refract_float3(float3 I, float3 N, float eta) { return __builtin_spirv_refract(I, N, eta); }
2222

2323
// CHECK-LABEL: define spir_func <4 x float> @test_refract_float4(
2424
// CHECK-SAME: <4 x float> noundef [[I:%.*]], <4 x float> noundef [[N:%.*]], float noundef [[ETA:%.*]]) local_unnamed_addr #[[ATTR0]] {
2525
// CHECK-NEXT: [[ENTRY:.*:]]
26-
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <4 x float> @llvm.spv.refract.v4f32(<4 x float> [[I]], <4 x float> [[N]], float [[ETA]])
26+
// CHECK-NEXT: [[SPV_REFRACT:%.*]] = tail call <4 x float> @llvm.spv.refract.v4f32.f32(<4 x float> [[I]], <4 x float> [[N]], float [[ETA]])
2727
// CHECK-NEXT: ret <4 x float> [[SPV_REFRACT]]
2828
//
2929
float4 test_refract_float4(float4 I, float4 N, float eta) { return __builtin_spirv_refract(I, N, eta); }

clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ float3 test_mixed_datatype_inputs(float3 p0, float3 p1, half p2) {
5858
return refract(p0, p1, p2);
5959
}
6060

61-
half3 test_mixed_datatype_inputs(half3 p0, half3 p1, float p2) {
62-
return refract(p0, p1, p2);
63-
}
64-
6561
typedef float float5 __attribute__((ext_vector_type(5)));
6662

6763
float5 test_vec5_inputs(float5 p0, float5 p1, float p2) {

clang/test/SemaSPIRV/BuiltIns/refract-errors.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 %s -triple spirv-pc-vulkan-compute -verify
22

33
typedef float float2 __attribute__((ext_vector_type(2)));
4+
typedef float float3 __attribute__((ext_vector_type(3)));
5+
typedef _Float16 half;
6+
typedef half half2 __attribute__((ext_vector_type(2)));
47

58
float2 test_no_third_arg(float2 p0) {
69
return __builtin_spirv_refract(p0, p0);
@@ -21,3 +24,18 @@ float test_int_scalar_inputs(int p0, int p1, int p2) {
2124
return __builtin_spirv_refract(p0, p1, p2);
2225
// expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int')}}
2326
}
27+
28+
float test_float_and_half_inputs(float2 p0, half2 p1, float p2) {
29+
return __builtin_spirv_refract(p0, p1, p2);
30+
// expected-error@-1 {{2nd argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'half2' (vector of 2 'half' values))}}
31+
}
32+
33+
float test_float_and_half_2_inputs(float2 p0, float2 p1, half p2) {
34+
return __builtin_spirv_refract(p0, p1, p2);
35+
// expected-error@-1 {{3rd argument must be a scalar 16 or 32 bit floating-point type (was 'half' (aka '_Float16'))}}
36+
}
37+
38+
float2 test_mismatch_vector_size_inputs(float2 p0, float3 p1, float p2) {
39+
return __builtin_spirv_refract(p0, p1, p2);
40+
// expected-error@-1 {{first two arguments to '__builtin_spirv_refract' must have the same type}}
41+
}

llvm/include/llvm/IR/IntrinsicsSPIRV.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ let TargetPrefix = "spv" in {
7979
def int_spv_refract
8080
: DefaultAttrsIntrinsic<[LLVMMatchType<0>],
8181
[llvm_anyfloat_ty, LLVMMatchType<0>,
82-
LLVMVectorElementType<0>],
82+
llvm_anyfloat_ty],
8383
[IntrNoMem]>;
8484
def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
8585
def int_spv_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>;

llvm/test/CodeGen/SPIRV/hlsl-intrinsics/refract.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -O0 -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
2-
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
33

44
; Make sure SPIRV operation function calls for refract are lowered correctly.
55

0 commit comments

Comments
 (0)