@@ -16,26 +16,32 @@ half test_distance_half(half X, half Y) { return distance(X, Y); }
1616// CHECK-SAME: <2 x half> noundef [[X:%.*]], <2 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
1717// CHECK-NEXT: [[ENTRY:.*:]]
1818// CHECK-NEXT: [[SUB_I:%.*]] = fsub <2 x half> [[X]], [[Y]]
19- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.dx.length.v2f16(<2 x half> [[SUB_I]])
20- // CHECK-NEXT: ret half [[HLSL_LENGTH_I]]
19+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x half> [[SUB_I]], [[SUB_I]]
20+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v2f16(half 0xH0000, <2 x half> [[MUL_I]])
21+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]])
22+ // CHECK-NEXT: ret half [[TMP0]]
2123//
2224half test_distance_half2 (half2 X, half2 Y) { return distance (X, Y); }
2325
2426// CHECK-LABEL: define noundef half @_Z19test_distance_half3Dv3_DhS_(
2527// CHECK-SAME: <3 x half> noundef [[X:%.*]], <3 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
2628// CHECK-NEXT: [[ENTRY:.*:]]
2729// CHECK-NEXT: [[SUB_I:%.*]] = fsub <3 x half> [[X]], [[Y]]
28- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.dx.length.v3f16(<3 x half> [[SUB_I]])
29- // CHECK-NEXT: ret half [[HLSL_LENGTH_I]]
30+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x half> [[SUB_I]], [[SUB_I]]
31+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v3f16(half 0xH0000, <3 x half> [[MUL_I]])
32+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]])
33+ // CHECK-NEXT: ret half [[TMP0]]
3034//
3135half test_distance_half3 (half3 X, half3 Y) { return distance (X, Y); }
3236
3337// CHECK-LABEL: define noundef half @_Z19test_distance_half4Dv4_DhS_(
3438// CHECK-SAME: <4 x half> noundef [[X:%.*]], <4 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
3539// CHECK-NEXT: [[ENTRY:.*:]]
3640// CHECK-NEXT: [[SUB_I:%.*]] = fsub <4 x half> [[X]], [[Y]]
37- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.dx.length.v4f16(<4 x half> [[SUB_I]])
38- // CHECK-NEXT: ret half [[HLSL_LENGTH_I]]
41+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x half> [[SUB_I]], [[SUB_I]]
42+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v4f16(half 0xH0000, <4 x half> [[MUL_I]])
43+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]])
44+ // CHECK-NEXT: ret half [[TMP0]]
3945//
4046half test_distance_half4 (half4 X, half4 Y) { return distance (X, Y); }
4147
@@ -52,25 +58,31 @@ float test_distance_float(float X, float Y) { return distance(X, Y); }
5258// CHECK-SAME: <2 x float> noundef [[X:%.*]], <2 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
5359// CHECK-NEXT: [[ENTRY:.*:]]
5460// CHECK-NEXT: [[SUB_I:%.*]] = fsub <2 x float> [[X]], [[Y]]
55- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.dx.length.v2f32(<2 x float> [[SUB_I]])
56- // CHECK-NEXT: ret float [[HLSL_LENGTH_I]]
61+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x float> [[SUB_I]], [[SUB_I]]
62+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v2f32(float 0.000000e+00, <2 x float> [[MUL_I]])
63+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]])
64+ // CHECK-NEXT: ret float [[TMP0]]
5765//
5866float test_distance_float2 (float2 X, float2 Y) { return distance (X, Y); }
5967
6068// CHECK-LABEL: define noundef float @_Z20test_distance_float3Dv3_fS_(
6169// CHECK-SAME: <3 x float> noundef [[X:%.*]], <3 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
6270// CHECK-NEXT: [[ENTRY:.*:]]
6371// CHECK-NEXT: [[SUB_I:%.*]] = fsub <3 x float> [[X]], [[Y]]
64- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.dx.length.v3f32(<3 x float> [[SUB_I]])
65- // CHECK-NEXT: ret float [[HLSL_LENGTH_I]]
72+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x float> [[SUB_I]], [[SUB_I]]
73+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v3f32(float 0.000000e+00, <3 x float> [[MUL_I]])
74+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]])
75+ // CHECK-NEXT: ret float [[TMP0]]
6676//
6777float test_distance_float3 (float3 X, float3 Y) { return distance (X, Y); }
6878
6979// CHECK-LABEL: define noundef float @_Z20test_distance_float4Dv4_fS_(
7080// CHECK-SAME: <4 x float> noundef [[X:%.*]], <4 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
7181// CHECK-NEXT: [[ENTRY:.*:]]
7282// CHECK-NEXT: [[SUB_I:%.*]] = fsub <4 x float> [[X]], [[Y]]
73- // CHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.dx.length.v4f32(<4 x float> [[SUB_I]])
74- // CHECK-NEXT: ret float [[HLSL_LENGTH_I]]
83+ // CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x float> [[SUB_I]], [[SUB_I]]
84+ // CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[MUL_I]])
85+ // CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]])
86+ // CHECK-NEXT: ret float [[TMP0]]
7587//
7688float test_distance_float4 (float4 X, float4 Y) { return distance (X, Y); }
0 commit comments