Skip to content

Commit ae1a274

Browse files
committed
[SPIRV] add pre legalization instruction combine
- Add the boilerplate to support instcombine in SPIRV - instcombine length(X-Y) to distance(X,Y) - switch HLSL's distance intrinsic to not special case for SPIRV. - fixes #122766
1 parent b665ddd commit ae1a274

File tree

16 files changed

+525
-72
lines changed

16 files changed

+525
-72
lines changed

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ def SPIRVDistance : Builtin {
1313
let Attributes = [NoThrow, Const];
1414
let Prototype = "void(...)";
1515
}
16+
17+
def SPIRVLength : Builtin {
18+
let Spellings = ["__builtin_spirv_length"];
19+
let Attributes = [NoThrow, Const];
20+
let Prototype = "void(...)";
21+
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20487,6 +20487,16 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
2048720487
/*ReturnType=*/X->getType()->getScalarType(), Intrinsic::spv_distance,
2048820488
ArrayRef<Value *>{X, Y}, nullptr, "spv.distance");
2048920489
}
20490+
case SPIRV::BI__builtin_spirv_length: {
20491+
Value *X = EmitScalarExpr(E->getArg(0));
20492+
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
20493+
"length operand must have a float representation");
20494+
assert(E->getArg(0)->getType()->isVectorType() &&
20495+
"length operand must be a vector");
20496+
return Builder.CreateIntrinsic(
20497+
/*ReturnType=*/X->getType()->getScalarType(), Intrinsic::spv_length,
20498+
ArrayRef<Value *>{X}, nullptr, "spv.length");
20499+
}
2049020500
}
2049120501
return nullptr;
2049220502
}

clang/lib/Headers/hlsl/hlsl_detail.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ length_impl(T X) {
6161
template <typename T, int N>
6262
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
6363
length_vec_impl(vector<T, N> X) {
64+
#if (__has_builtin(__builtin_spirv_length))
65+
return __builtin_spirv_length(X);
66+
#else
6467
return __builtin_elementwise_sqrt(__builtin_hlsl_dot(X, X));
68+
#endif
6569
}
6670

6771
template <typename T>
@@ -73,11 +77,7 @@ distance_impl(T X, T Y) {
7377
template <typename T, int N>
7478
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
7579
distance_vec_impl(vector<T, N> X, vector<T, N> Y) {
76-
#if (__has_builtin(__builtin_spirv_distance))
77-
return __builtin_spirv_distance(X, Y);
78-
#else
7980
return length_vec_impl(X - Y);
80-
#endif
8181
}
8282
} // namespace __detail
8383
} // namespace hlsl

clang/lib/Sema/SemaSPIRV.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
5151
TheCall->setType(RetTy);
5252
break;
5353
}
54+
case SPIRV::BI__builtin_spirv_length: {
55+
if (SemaRef.checkArgCount(TheCall, 1))
56+
return true;
57+
ExprResult A = TheCall->getArg(0);
58+
QualType ArgTyA = A.get()->getType();
59+
auto *VTy = ArgTyA->getAs<VectorType>();
60+
if (VTy == nullptr) {
61+
SemaRef.Diag(A.get()->getBeginLoc(),
62+
diag::err_typecheck_convert_incompatible)
63+
<< ArgTyA
64+
<< SemaRef.Context.getVectorType(ArgTyA, 2, VectorKind::Generic) << 1
65+
<< 0 << 0;
66+
return true;
67+
}
68+
QualType RetTy = VTy->getElementType();
69+
TheCall->setType(RetTy);
70+
break;
71+
}
5472
}
5573
return false;
5674
}

clang/test/CodeGenHLSL/builtins/distance.hlsl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ half test_distance_half(half X, half Y) { return distance(X, Y); }
3333
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z19test_distance_half2Dv2_DhS_(
3434
// SPVCHECK-SAME: <2 x half> noundef nofpclass(nan inf) [[X:%.*]], <2 x half> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
3535
// SPVCHECK-NEXT: [[ENTRY:.*:]]
36-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.distance.v2f16(<2 x half> [[X]], <2 x half> [[Y]])
37-
// SPVCHECK-NEXT: ret half [[SPV_DISTANCE_I]]
36+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <2 x half> [[X]], [[Y]]
37+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v2f16(<2 x half> [[SUB_I]])
38+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
3839
//
3940
half test_distance_half2(half2 X, half2 Y) { return distance(X, Y); }
4041

@@ -49,8 +50,9 @@ half test_distance_half2(half2 X, half2 Y) { return distance(X, Y); }
4950
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z19test_distance_half3Dv3_DhS_(
5051
// SPVCHECK-SAME: <3 x half> noundef nofpclass(nan inf) [[X:%.*]], <3 x half> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
5152
// SPVCHECK-NEXT: [[ENTRY:.*:]]
52-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.distance.v3f16(<3 x half> [[X]], <3 x half> [[Y]])
53-
// SPVCHECK-NEXT: ret half [[SPV_DISTANCE_I]]
53+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <3 x half> [[X]], [[Y]]
54+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v3f16(<3 x half> [[SUB_I]])
55+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
5456
//
5557
half test_distance_half3(half3 X, half3 Y) { return distance(X, Y); }
5658

@@ -65,8 +67,9 @@ half test_distance_half3(half3 X, half3 Y) { return distance(X, Y); }
6567
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z19test_distance_half4Dv4_DhS_(
6668
// SPVCHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[X:%.*]], <4 x half> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
6769
// SPVCHECK-NEXT: [[ENTRY:.*:]]
68-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.distance.v4f16(<4 x half> [[X]], <4 x half> [[Y]])
69-
// SPVCHECK-NEXT: ret half [[SPV_DISTANCE_I]]
70+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <4 x half> [[X]], [[Y]]
71+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v4f16(<4 x half> [[SUB_I]])
72+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
7073
//
7174
half test_distance_half4(half4 X, half4 Y) { return distance(X, Y); }
7275

@@ -97,8 +100,9 @@ float test_distance_float(float X, float Y) { return distance(X, Y); }
97100
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z20test_distance_float2Dv2_fS_(
98101
// SPVCHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[X:%.*]], <2 x float> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
99102
// SPVCHECK-NEXT: [[ENTRY:.*:]]
100-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.distance.v2f32(<2 x float> [[X]], <2 x float> [[Y]])
101-
// SPVCHECK-NEXT: ret float [[SPV_DISTANCE_I]]
103+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <2 x float> [[X]], [[Y]]
104+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v2f32(<2 x float> [[SUB_I]])
105+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
102106
//
103107
float test_distance_float2(float2 X, float2 Y) { return distance(X, Y); }
104108

@@ -113,8 +117,9 @@ float test_distance_float2(float2 X, float2 Y) { return distance(X, Y); }
113117
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z20test_distance_float3Dv3_fS_(
114118
// SPVCHECK-SAME: <3 x float> noundef nofpclass(nan inf) [[X:%.*]], <3 x float> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
115119
// SPVCHECK-NEXT: [[ENTRY:.*:]]
116-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.distance.v3f32(<3 x float> [[X]], <3 x float> [[Y]])
117-
// SPVCHECK-NEXT: ret float [[SPV_DISTANCE_I]]
120+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <3 x float> [[X]], [[Y]]
121+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v3f32(<3 x float> [[SUB_I]])
122+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
118123
//
119124
float test_distance_float3(float3 X, float3 Y) { return distance(X, Y); }
120125

@@ -129,7 +134,8 @@ float test_distance_float3(float3 X, float3 Y) { return distance(X, Y); }
129134
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z20test_distance_float4Dv4_fS_(
130135
// SPVCHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[X:%.*]], <4 x float> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
131136
// SPVCHECK-NEXT: [[ENTRY:.*:]]
132-
// SPVCHECK-NEXT: [[SPV_DISTANCE_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.distance.v4f32(<4 x float> [[X]], <4 x float> [[Y]])
133-
// SPVCHECK-NEXT: ret float [[SPV_DISTANCE_I]]
137+
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn <4 x float> [[X]], [[Y]]
138+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v4f32(<4 x float> [[SUB_I]])
139+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
134140
//
135141
float test_distance_float4(float4 X, float4 Y) { return distance(X, Y); }

clang/test/CodeGenHLSL/builtins/length.hlsl

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,163 @@
1-
// RUN: %clang_cc1 -finclude-default-header -triple \
2-
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
3-
// RUN: -emit-llvm -O1 -o - | FileCheck %s --check-prefixes=CHECK,DXCHECK \
4-
// RUN: -DTARGET=dx
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
3+
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
4+
// RUN: -emit-llvm -O1 -o - | FileCheck %s
55

66
// RUN: %clang_cc1 -finclude-default-header -triple \
77
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \
8-
// RUN: -emit-llvm -O1 -o - | FileCheck %s --check-prefixes=CHECK,SPVCHECK \
9-
// RUN: -DTARGET=spv
8+
// RUN: -emit-llvm -O1 -o - | FileCheck %s --check-prefix=SPVCHECK
109

1110

12-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z16test_length_halfDh(
1311
// DXCHECK-LABEL: define noundef nofpclass(nan inf) half @_Z16test_length_halfDh(
12+
//
13+
14+
// CHECK-LABEL: define noundef nofpclass(nan inf) half @_Z16test_length_halfDh(
1415
// CHECK-SAME: half noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
1516
// CHECK-NEXT: [[ENTRY:.*:]]
1617
// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.fabs.f16(half [[P0]])
1718
// CHECK-NEXT: ret half [[ELT_ABS_I]]
1819
//
19-
20+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z16test_length_halfDh(
21+
// SPVCHECK-SAME: half noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
22+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
23+
// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.fabs.f16(half [[P0]])
24+
// SPVCHECK-NEXT: ret half [[ELT_ABS_I]]
25+
//
2026
half test_length_half(half p0)
2127
{
2228
return length(p0);
2329
}
2430

25-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half2Dv2_Dh(
2631
// DXCHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half2Dv2_Dh(
32+
//
33+
34+
35+
// CHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half2Dv2_Dh(
2736
// CHECK-SAME: <2 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
2837
// CHECK-NEXT: [[ENTRY:.*:]]
29-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.[[TARGET]].fdot.v2f16(<2 x half> [[P0]], <2 x half> [[P0]])
38+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.dx.fdot.v2f16(<2 x half> [[P0]], <2 x half> [[P0]])
3039
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.sqrt.f16(half [[HLSL_DOT_I]])
3140
// CHECK-NEXT: ret half [[TMP0]]
3241
//
33-
34-
42+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half2Dv2_Dh(
43+
// SPVCHECK-SAME: <2 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
44+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
45+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v2f16(<2 x half> [[P0]])
46+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
47+
//
3548
half test_length_half2(half2 p0)
3649
{
3750
return length(p0);
3851
}
3952

40-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half3Dv3_Dh(
4153
// DXCHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half3Dv3_Dh(
54+
// CHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half3Dv3_Dh(
4255
// CHECK-SAME: <3 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
4356
// CHECK-NEXT: [[ENTRY:.*:]]
44-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.[[TARGET]].fdot.v3f16(<3 x half> [[P0]], <3 x half> [[P0]])
57+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.dx.fdot.v3f16(<3 x half> [[P0]], <3 x half> [[P0]])
4558
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.sqrt.f16(half [[HLSL_DOT_I]])
4659
// CHECK-NEXT: ret half [[TMP0]]
4760
//
61+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half3Dv3_Dh(
62+
// SPVCHECK-SAME: <3 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
63+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
64+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v3f16(<3 x half> [[P0]])
65+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
66+
//
4867
half test_length_half3(half3 p0)
4968
{
5069
return length(p0);
5170
}
5271

53-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half4Dv4_Dh(
5472
// DXCHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half4Dv4_Dh(
73+
// CHECK-LABEL: define noundef nofpclass(nan inf) half @_Z17test_length_half4Dv4_Dh(
5574
// CHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
5675
// CHECK-NEXT: [[ENTRY:.*:]]
57-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.[[TARGET]].fdot.v4f16(<4 x half> [[P0]], <4 x half> [[P0]])
76+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.dx.fdot.v4f16(<4 x half> [[P0]], <4 x half> [[P0]])
5877
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.sqrt.f16(half [[HLSL_DOT_I]])
5978
// CHECK-NEXT: ret half [[TMP0]]
6079
//
80+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z17test_length_half4Dv4_Dh(
81+
// SPVCHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
82+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
83+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.length.v4f16(<4 x half> [[P0]])
84+
// SPVCHECK-NEXT: ret half [[SPV_LENGTH_I]]
85+
//
6186
half test_length_half4(half4 p0)
6287
{
6388
return length(p0);
6489
}
6590

66-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z17test_length_floatf(
6791
// DXCHECK-LABEL: define noundef nofpclass(nan inf) float @_Z17test_length_floatf(
92+
// CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z17test_length_floatf(
6893
// CHECK-SAME: float noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
6994
// CHECK-NEXT: [[ENTRY:.*:]]
7095
// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.fabs.f32(float [[P0]])
7196
// CHECK-NEXT: ret float [[ELT_ABS_I]]
7297
//
98+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z17test_length_floatf(
99+
// SPVCHECK-SAME: float noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
100+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
101+
// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.fabs.f32(float [[P0]])
102+
// SPVCHECK-NEXT: ret float [[ELT_ABS_I]]
103+
//
73104
float test_length_float(float p0)
74105
{
75106
return length(p0);
76107
}
77108

78-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float2Dv2_f(
79109
// DXCHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float2Dv2_f(
110+
// CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float2Dv2_f(
80111
// CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
81112
// CHECK-NEXT: [[ENTRY:.*:]]
82-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].fdot.v2f32(<2 x float> [[P0]], <2 x float> [[P0]])
113+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.dx.fdot.v2f32(<2 x float> [[P0]], <2 x float> [[P0]])
83114
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.sqrt.f32(float [[HLSL_DOT_I]])
84115
// CHECK-NEXT: ret float [[TMP0]]
85116
//
117+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float2Dv2_f(
118+
// SPVCHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
119+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
120+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v2f32(<2 x float> [[P0]])
121+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
122+
//
86123
float test_length_float2(float2 p0)
87124
{
88125
return length(p0);
89126
}
90127

91-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float3Dv3_f(
92128
// DXCHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float3Dv3_f(
129+
// CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float3Dv3_f(
93130
// CHECK-SAME: <3 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
94131
// CHECK-NEXT: [[ENTRY:.*:]]
95-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].fdot.v3f32(<3 x float> [[P0]], <3 x float> [[P0]])
132+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.dx.fdot.v3f32(<3 x float> [[P0]], <3 x float> [[P0]])
96133
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.sqrt.f32(float [[HLSL_DOT_I]])
97134
// CHECK-NEXT: ret float [[TMP0]]
98135
//
136+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float3Dv3_f(
137+
// SPVCHECK-SAME: <3 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
138+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
139+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v3f32(<3 x float> [[P0]])
140+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
141+
//
99142
float test_length_float3(float3 p0)
100143
{
101144
return length(p0);
102145
}
103146

104-
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float4Dv4_f(
105147
// DXCHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float4Dv4_f(
148+
// CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z18test_length_float4Dv4_f(
106149
// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
107150
// CHECK-NEXT: [[ENTRY:.*:]]
108-
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].fdot.v4f32(<4 x float> [[P0]], <4 x float> [[P0]])
151+
// CHECK-NEXT: [[HLSL_DOT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.dx.fdot.v4f32(<4 x float> [[P0]], <4 x float> [[P0]])
109152
// CHECK-NEXT: [[TMP0:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.sqrt.f32(float [[HLSL_DOT_I]])
110153
// CHECK-NEXT: ret float [[TMP0]]
111154
//
155+
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z18test_length_float4Dv4_f(
156+
// SPVCHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] {
157+
// SPVCHECK-NEXT: [[ENTRY:.*:]]
158+
// SPVCHECK-NEXT: [[SPV_LENGTH_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.length.v4f32(<4 x float> [[P0]])
159+
// SPVCHECK-NEXT: ret float [[SPV_LENGTH_I]]
160+
//
112161
float test_length_float4(float4 p0)
113162
{
114163
return length(p0);

0 commit comments

Comments
 (0)