|
| 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 |
| 5 | +// RUN: %clang_cc1 -finclude-default-header -triple \ |
| 6 | +// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ |
| 7 | +// RUN: -emit-llvm -O1 -o - | FileCheck %s --check-prefix=SPVCHECK |
| 8 | + |
| 9 | +// CHECK-LABEL: define noundef half @_Z18test_distance_halfDhDh( |
| 10 | +// CHECK-SAME: half noundef [[X:%.*]], half noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 11 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 12 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub half [[X]], [[Y]] |
| 13 | +// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef half @llvm.fabs.f16(half [[SUB_I]]) |
| 14 | +// CHECK-NEXT: ret half [[ELT_ABS_I]] |
| 15 | +// |
| 16 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z18test_distance_halfDhDh( |
| 17 | +// SPVCHECK-SAME: half noundef [[X:%.*]], half noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 18 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 19 | +// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub half [[X]], [[Y]] |
| 20 | +// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef half @llvm.fabs.f16(half [[SUB_I]]) |
| 21 | +// SPVCHECK-NEXT: ret half [[ELT_ABS_I]] |
| 22 | +// |
| 23 | +half test_distance_half(half X, half Y) { return distance(X, Y); } |
| 24 | + |
| 25 | +// CHECK-LABEL: define noundef half @_Z19test_distance_half2Dv2_DhS_( |
| 26 | +// CHECK-SAME: <2 x half> noundef [[X:%.*]], <2 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 27 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 28 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <2 x half> [[X]], [[Y]] |
| 29 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x half> [[SUB_I]], [[SUB_I]] |
| 30 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v2f16(half 0xH0000, <2 x half> [[MUL_I]]) |
| 31 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]]) |
| 32 | +// CHECK-NEXT: ret half [[TMP0]] |
| 33 | +// |
| 34 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z19test_distance_half2Dv2_DhS_( |
| 35 | +// SPVCHECK-SAME: <2 x half> noundef [[X:%.*]], <2 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 36 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 37 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef half @llvm.spv.distance.v2f16(<2 x half> [[X]], <2 x half> [[Y]]) |
| 38 | +// SPVCHECK-NEXT: ret half [[HLSL_DISTANCE_I]] |
| 39 | +// |
| 40 | +half test_distance_half2(half2 X, half2 Y) { return distance(X, Y); } |
| 41 | + |
| 42 | +// CHECK-LABEL: define noundef half @_Z19test_distance_half3Dv3_DhS_( |
| 43 | +// CHECK-SAME: <3 x half> noundef [[X:%.*]], <3 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 44 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 45 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <3 x half> [[X]], [[Y]] |
| 46 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x half> [[SUB_I]], [[SUB_I]] |
| 47 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v3f16(half 0xH0000, <3 x half> [[MUL_I]]) |
| 48 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]]) |
| 49 | +// CHECK-NEXT: ret half [[TMP0]] |
| 50 | +// |
| 51 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z19test_distance_half3Dv3_DhS_( |
| 52 | +// SPVCHECK-SAME: <3 x half> noundef [[X:%.*]], <3 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 53 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 54 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef half @llvm.spv.distance.v3f16(<3 x half> [[X]], <3 x half> [[Y]]) |
| 55 | +// SPVCHECK-NEXT: ret half [[HLSL_DISTANCE_I]] |
| 56 | +// |
| 57 | +half test_distance_half3(half3 X, half3 Y) { return distance(X, Y); } |
| 58 | + |
| 59 | +// CHECK-LABEL: define noundef half @_Z19test_distance_half4Dv4_DhS_( |
| 60 | +// CHECK-SAME: <4 x half> noundef [[X:%.*]], <4 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 61 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 62 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <4 x half> [[X]], [[Y]] |
| 63 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x half> [[SUB_I]], [[SUB_I]] |
| 64 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v4f16(half 0xH0000, <4 x half> [[MUL_I]]) |
| 65 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]]) |
| 66 | +// CHECK-NEXT: ret half [[TMP0]] |
| 67 | +// |
| 68 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z19test_distance_half4Dv4_DhS_( |
| 69 | +// SPVCHECK-SAME: <4 x half> noundef [[X:%.*]], <4 x half> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 70 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 71 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef half @llvm.spv.distance.v4f16(<4 x half> [[X]], <4 x half> [[Y]]) |
| 72 | +// SPVCHECK-NEXT: ret half [[HLSL_DISTANCE_I]] |
| 73 | +// |
| 74 | +half test_distance_half4(half4 X, half4 Y) { return distance(X, Y); } |
| 75 | + |
| 76 | +// CHECK-LABEL: define noundef float @_Z19test_distance_floatff( |
| 77 | +// CHECK-SAME: float noundef [[X:%.*]], float noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 78 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 79 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub float [[X]], [[Y]] |
| 80 | +// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef float @llvm.fabs.f32(float [[SUB_I]]) |
| 81 | +// CHECK-NEXT: ret float [[ELT_ABS_I]] |
| 82 | +// |
| 83 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z19test_distance_floatff( |
| 84 | +// SPVCHECK-SAME: float noundef [[X:%.*]], float noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 85 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 86 | +// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub float [[X]], [[Y]] |
| 87 | +// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef float @llvm.fabs.f32(float [[SUB_I]]) |
| 88 | +// SPVCHECK-NEXT: ret float [[ELT_ABS_I]] |
| 89 | +// |
| 90 | +float test_distance_float(float X, float Y) { return distance(X, Y); } |
| 91 | + |
| 92 | +// CHECK-LABEL: define noundef float @_Z20test_distance_float2Dv2_fS_( |
| 93 | +// CHECK-SAME: <2 x float> noundef [[X:%.*]], <2 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 94 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 95 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <2 x float> [[X]], [[Y]] |
| 96 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x float> [[SUB_I]], [[SUB_I]] |
| 97 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v2f32(float 0.000000e+00, <2 x float> [[MUL_I]]) |
| 98 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 99 | +// CHECK-NEXT: ret float [[TMP0]] |
| 100 | +// |
| 101 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z20test_distance_float2Dv2_fS_( |
| 102 | +// SPVCHECK-SAME: <2 x float> noundef [[X:%.*]], <2 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 103 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 104 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef float @llvm.spv.distance.v2f32(<2 x float> [[X]], <2 x float> [[Y]]) |
| 105 | +// SPVCHECK-NEXT: ret float [[HLSL_DISTANCE_I]] |
| 106 | +// |
| 107 | +float test_distance_float2(float2 X, float2 Y) { return distance(X, Y); } |
| 108 | + |
| 109 | +// CHECK-LABEL: define noundef float @_Z20test_distance_float3Dv3_fS_( |
| 110 | +// CHECK-SAME: <3 x float> noundef [[X:%.*]], <3 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 111 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 112 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <3 x float> [[X]], [[Y]] |
| 113 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x float> [[SUB_I]], [[SUB_I]] |
| 114 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v3f32(float 0.000000e+00, <3 x float> [[MUL_I]]) |
| 115 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 116 | +// CHECK-NEXT: ret float [[TMP0]] |
| 117 | +// |
| 118 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z20test_distance_float3Dv3_fS_( |
| 119 | +// SPVCHECK-SAME: <3 x float> noundef [[X:%.*]], <3 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 120 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 121 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef float @llvm.spv.distance.v3f32(<3 x float> [[X]], <3 x float> [[Y]]) |
| 122 | +// SPVCHECK-NEXT: ret float [[HLSL_DISTANCE_I]] |
| 123 | +// |
| 124 | +float test_distance_float3(float3 X, float3 Y) { return distance(X, Y); } |
| 125 | + |
| 126 | +// CHECK-LABEL: define noundef float @_Z20test_distance_float4Dv4_fS_( |
| 127 | +// CHECK-SAME: <4 x float> noundef [[X:%.*]], <4 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 128 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 129 | +// CHECK-NEXT: [[SUB_I:%.*]] = fsub <4 x float> [[X]], [[Y]] |
| 130 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x float> [[SUB_I]], [[SUB_I]] |
| 131 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[MUL_I]]) |
| 132 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 133 | +// CHECK-NEXT: ret float [[TMP0]] |
| 134 | +// |
| 135 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z20test_distance_float4Dv4_fS_( |
| 136 | +// SPVCHECK-SAME: <4 x float> noundef [[X:%.*]], <4 x float> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 137 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 138 | +// SPVCHECK-NEXT: [[HLSL_DISTANCE_I:%.*]] = tail call noundef float @llvm.spv.distance.v4f32(<4 x float> [[X]], <4 x float> [[Y]]) |
| 139 | +// SPVCHECK-NEXT: ret float [[HLSL_DISTANCE_I]] |
| 140 | +// |
| 141 | +float test_distance_float4(float4 X, float4 Y) { return distance(X, Y); } |
0 commit comments