|
1 | | -// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ |
2 | | -// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ |
3 | | -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ |
4 | | -// RUN: --check-prefixes=CHECK,NATIVE_HALF |
5 | | -// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ |
6 | | -// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ |
7 | | -// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF |
8 | | - |
9 | | -// NATIVE_HALF: define noundef half @ |
10 | | -// NATIVE_HALF: call half @llvm.fabs.f16(half |
11 | | -// NO_HALF: call float @llvm.fabs.f32(float |
12 | | -// NATIVE_HALF: ret half |
13 | | -// NO_HALF: ret float |
14 | | -half test_length_half(half p0) |
15 | | -{ |
16 | | - return length(p0); |
17 | | -} |
18 | | -// NATIVE_HALF: define noundef half @ |
19 | | -// NATIVE_HALF: %hlsl.length = call half @llvm.dx.length.v2f16 |
20 | | -// NO_HALF: %hlsl.length = call float @llvm.dx.length.v2f32( |
21 | | -// NATIVE_HALF: ret half %hlsl.length |
22 | | -// NO_HALF: ret float %hlsl.length |
23 | | -half test_length_half2(half2 p0) |
24 | | -{ |
25 | | - return length(p0); |
26 | | -} |
27 | | -// NATIVE_HALF: define noundef half @ |
28 | | -// NATIVE_HALF: %hlsl.length = call half @llvm.dx.length.v3f16 |
29 | | -// NO_HALF: %hlsl.length = call float @llvm.dx.length.v3f32( |
30 | | -// NATIVE_HALF: ret half %hlsl.length |
31 | | -// NO_HALF: ret float %hlsl.length |
32 | | -half test_length_half3(half3 p0) |
33 | | -{ |
34 | | - return length(p0); |
35 | | -} |
36 | | -// NATIVE_HALF: define noundef half @ |
37 | | -// NATIVE_HALF: %hlsl.length = call half @llvm.dx.length.v4f16 |
38 | | -// NO_HALF: %hlsl.length = call float @llvm.dx.length.v4f32( |
39 | | -// NATIVE_HALF: ret half %hlsl.length |
40 | | -// NO_HALF: ret float %hlsl.length |
41 | | -half test_length_half4(half4 p0) |
42 | | -{ |
43 | | - return length(p0); |
44 | | -} |
45 | | - |
46 | | -// CHECK: define noundef float @ |
47 | | -// CHECK: call float @llvm.fabs.f32(float |
48 | | -// CHECK: ret float |
49 | | -float test_length_float(float p0) |
50 | | -{ |
51 | | - return length(p0); |
52 | | -} |
53 | | -// CHECK: define noundef float @ |
54 | | -// CHECK: %hlsl.length = call float @llvm.dx.length.v2f32( |
55 | | -// CHECK: ret float %hlsl.length |
56 | | -float test_length_float2(float2 p0) |
57 | | -{ |
58 | | - return length(p0); |
59 | | -} |
60 | | -// CHECK: define noundef float @ |
61 | | -// CHECK: %hlsl.length = call float @llvm.dx.length.v3f32( |
62 | | -// CHECK: ret float %hlsl.length |
63 | | -float test_length_float3(float3 p0) |
64 | | -{ |
65 | | - return length(p0); |
66 | | -} |
67 | | -// CHECK: define noundef float @ |
68 | | -// CHECK: %hlsl.length = call float @llvm.dx.length.v4f32( |
69 | | -// CHECK: ret float %hlsl.length |
70 | | -float test_length_float4(float4 p0) |
71 | | -{ |
72 | | - return length(p0); |
73 | | -} |
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +// RUN: %clang_cc1 -finclude-default-header -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 | + |
| 10 | +// CHECK-LABEL: define noundef half @_Z16test_length_halfDh( |
| 11 | +// CHECK-SAME: half noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 12 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 13 | +// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef half @llvm.fabs.f16(half [[P0]]) |
| 14 | +// CHECK-NEXT: ret half [[ELT_ABS_I]] |
| 15 | +// |
| 16 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z16test_length_halfDh( |
| 17 | +// SPVCHECK-SAME: half noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 18 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 19 | +// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef half @llvm.fabs.f16(half [[P0]]) |
| 20 | +// SPVCHECK-NEXT: ret half [[ELT_ABS_I]] |
| 21 | +// |
| 22 | +half test_length_half(half p0) |
| 23 | +{ |
| 24 | + return length(p0); |
| 25 | +} |
| 26 | + |
| 27 | +// CHECK-LABEL: define noundef half @_Z17test_length_half2Dv2_Dh( |
| 28 | +// CHECK-SAME: <2 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 29 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 30 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x half> [[P0]], [[P0]] |
| 31 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v2f16(half 0xH0000, <2 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]] |
| 34 | +// |
| 35 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z17test_length_half2Dv2_Dh( |
| 36 | +// SPVCHECK-SAME: <2 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 37 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 38 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.spv.length.v2f16(<2 x half> [[P0]]) |
| 39 | +// SPVCHECK-NEXT: ret half [[HLSL_LENGTH_I]] |
| 40 | +// |
| 41 | +half test_length_half2(half2 p0) |
| 42 | +{ |
| 43 | + return length(p0); |
| 44 | +} |
| 45 | + |
| 46 | +// CHECK-LABEL: define noundef half @_Z17test_length_half3Dv3_Dh( |
| 47 | +// CHECK-SAME: <3 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 48 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 49 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x half> [[P0]], [[P0]] |
| 50 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v3f16(half 0xH0000, <3 x half> [[MUL_I]]) |
| 51 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]]) |
| 52 | +// CHECK-NEXT: ret half [[TMP0]] |
| 53 | +// |
| 54 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z17test_length_half3Dv3_Dh( |
| 55 | +// SPVCHECK-SAME: <3 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 56 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 57 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.spv.length.v3f16(<3 x half> [[P0]]) |
| 58 | +// SPVCHECK-NEXT: ret half [[HLSL_LENGTH_I]] |
| 59 | +// |
| 60 | +half test_length_half3(half3 p0) |
| 61 | +{ |
| 62 | + return length(p0); |
| 63 | +} |
| 64 | + |
| 65 | +// CHECK-LABEL: define noundef half @_Z17test_length_half4Dv4_Dh( |
| 66 | +// CHECK-SAME: <4 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 67 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 68 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x half> [[P0]], [[P0]] |
| 69 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call half @llvm.vector.reduce.fadd.v4f16(half 0xH0000, <4 x half> [[MUL_I]]) |
| 70 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef half @llvm.sqrt.f16(half [[RDX_FADD_I]]) |
| 71 | +// CHECK-NEXT: ret half [[TMP0]] |
| 72 | +// |
| 73 | +// SPVCHECK-LABEL: define spir_func noundef half @_Z17test_length_half4Dv4_Dh( |
| 74 | +// SPVCHECK-SAME: <4 x half> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 75 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 76 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef half @llvm.spv.length.v4f16(<4 x half> [[P0]]) |
| 77 | +// SPVCHECK-NEXT: ret half [[HLSL_LENGTH_I]] |
| 78 | +// |
| 79 | +half test_length_half4(half4 p0) |
| 80 | +{ |
| 81 | + return length(p0); |
| 82 | +} |
| 83 | + |
| 84 | + |
| 85 | +// CHECK-LABEL: define noundef float @_Z17test_length_floatf( |
| 86 | +// CHECK-SAME: float noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 87 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 88 | +// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef float @llvm.fabs.f32(float [[P0]]) |
| 89 | +// CHECK-NEXT: ret float [[ELT_ABS_I]] |
| 90 | +// |
| 91 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z17test_length_floatf( |
| 92 | +// SPVCHECK-SAME: float noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 93 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 94 | +// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call noundef float @llvm.fabs.f32(float [[P0]]) |
| 95 | +// SPVCHECK-NEXT: ret float [[ELT_ABS_I]] |
| 96 | +// |
| 97 | +float test_length_float(float p0) |
| 98 | +{ |
| 99 | + return length(p0); |
| 100 | +} |
| 101 | + |
| 102 | +// CHECK-LABEL: define noundef float @_Z18test_length_float2Dv2_f( |
| 103 | +// CHECK-SAME: <2 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 104 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 105 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <2 x float> [[P0]], [[P0]] |
| 106 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v2f32(float 0.000000e+00, <2 x float> [[MUL_I]]) |
| 107 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 108 | +// CHECK-NEXT: ret float [[TMP0]] |
| 109 | +// |
| 110 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z18test_length_float2Dv2_f( |
| 111 | +// SPVCHECK-SAME: <2 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 112 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 113 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.spv.length.v2f32(<2 x float> [[P0]]) |
| 114 | +// SPVCHECK-NEXT: ret float [[HLSL_LENGTH_I]] |
| 115 | +// |
| 116 | +float test_length_float2(float2 p0) |
| 117 | +{ |
| 118 | + return length(p0); |
| 119 | +} |
| 120 | + |
| 121 | +// CHECK-LABEL: define noundef float @_Z18test_length_float3Dv3_f( |
| 122 | +// CHECK-SAME: <3 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 123 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 124 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <3 x float> [[P0]], [[P0]] |
| 125 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v3f32(float 0.000000e+00, <3 x float> [[MUL_I]]) |
| 126 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 127 | +// CHECK-NEXT: ret float [[TMP0]] |
| 128 | +// |
| 129 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z18test_length_float3Dv3_f( |
| 130 | +// SPVCHECK-SAME: <3 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 131 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 132 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.spv.length.v3f32(<3 x float> [[P0]]) |
| 133 | +// SPVCHECK-NEXT: ret float [[HLSL_LENGTH_I]] |
| 134 | +// |
| 135 | +float test_length_float3(float3 p0) |
| 136 | +{ |
| 137 | + return length(p0); |
| 138 | +} |
| 139 | + |
| 140 | +// CHECK-LABEL: define noundef float @_Z18test_length_float4Dv4_f( |
| 141 | +// CHECK-SAME: <4 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 142 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 143 | +// CHECK-NEXT: [[MUL_I:%.*]] = fmul <4 x float> [[P0]], [[P0]] |
| 144 | +// CHECK-NEXT: [[RDX_FADD_I:%.*]] = tail call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[MUL_I]]) |
| 145 | +// CHECK-NEXT: [[TMP0:%.*]] = tail call noundef float @llvm.sqrt.f32(float [[RDX_FADD_I]]) |
| 146 | +// CHECK-NEXT: [[ADD:%.*]] = fadd float [[TMP0]], [[TMP0]] |
| 147 | +// CHECK-NEXT: ret float [[ADD]] |
| 148 | +// |
| 149 | +// SPVCHECK-LABEL: define spir_func noundef float @_Z18test_length_float4Dv4_f( |
| 150 | +// SPVCHECK-SAME: <4 x float> noundef [[P0:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 151 | +// SPVCHECK-NEXT: [[ENTRY:.*:]] |
| 152 | +// SPVCHECK-NEXT: [[HLSL_LENGTH_I:%.*]] = tail call noundef float @llvm.spv.length.v4f32(<4 x float> [[P0]]) |
| 153 | +// SPVCHECK-NEXT: [[ADD:%.*]] = fadd float [[HLSL_LENGTH_I]], [[HLSL_LENGTH_I]] |
| 154 | +// SPVCHECK-NEXT: ret float [[ADD]] |
| 155 | +// |
| 156 | +float test_length_float4(float4 p0) |
| 157 | +{ |
| 158 | + return length(p0) + length(p0); |
| 159 | +} |
0 commit comments