|
| 1 | +// RUN: %clang_cc1 -finclude-default-header -fnative-half-type -triple \ |
| 2 | +// RUN: dxil-pc-shadermodel6.3-compute %s -emit-llvm -o - | \ |
| 3 | +// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-DXIL |
| 4 | +// RUN: %clang_cc1 -finclude-default-header -fnative-half-type -triple \ |
| 5 | +// RUN: spirv-pc-vulkan-compute %s -emit-llvm -o - | \ |
| 6 | +// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV |
| 7 | + |
| 8 | +// Test basic lowering to runtime function call. |
| 9 | + |
| 10 | +// CHECK-LABEL: define {{.*}}test_default_parameter_type |
| 11 | +float test_default_parameter_type(half2 p1, half2 p2, float p3) { |
| 12 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 13 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 14 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 15 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 16 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 17 | + // CHECK: ret float %[[RES]] |
| 18 | + return dot2add(p1, p2, p3); |
| 19 | +} |
| 20 | + |
| 21 | +// CHECK-LABEL: define {{.*}}test_float_arg2_type |
| 22 | +float test_float_arg2_type(half2 p1, float2 p2, float p3) { |
| 23 | + // CHECK: %conv = fptrunc reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}} to <2 x half> |
| 24 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 25 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 26 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 27 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 28 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 29 | + // CHECK: ret float %[[RES]] |
| 30 | + return dot2add(p1, p2, p3); |
| 31 | +} |
| 32 | + |
| 33 | +// CHECK-LABEL: define {{.*}}test_float_arg1_type |
| 34 | +float test_float_arg1_type(float2 p1, half2 p2, float p3) { |
| 35 | + // CHECK: %conv = fptrunc reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}} to <2 x half> |
| 36 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 37 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 38 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 39 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 40 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 41 | + // CHECK: ret float %[[RES]] |
| 42 | + return dot2add(p1, p2, p3); |
| 43 | +} |
| 44 | + |
| 45 | +// CHECK-LABEL: define {{.*}}test_double_arg3_type |
| 46 | +float test_double_arg3_type(half2 p1, half2 p2, double p3) { |
| 47 | + // CHECK: %conv = fptrunc reassoc nnan ninf nsz arcp afn double %{{.*}} to float |
| 48 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 49 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 50 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 51 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 52 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 53 | + // CHECK: ret float %[[RES]] |
| 54 | + return dot2add(p1, p2, p3); |
| 55 | +} |
| 56 | + |
| 57 | +// CHECK-LABEL: define {{.*}}test_float_arg1_arg2_type |
| 58 | +float test_float_arg1_arg2_type(float2 p1, float2 p2, float p3) { |
| 59 | + // CHECK: %conv = fptrunc reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}} to <2 x half> |
| 60 | + // CHECK: %conv1 = fptrunc reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}} to <2 x half> |
| 61 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 62 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 63 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 64 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 65 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 66 | + // CHECK: ret float %[[RES]] |
| 67 | + return dot2add(p1, p2, p3); |
| 68 | +} |
| 69 | + |
| 70 | +// CHECK-LABEL: define {{.*}}test_double_arg1_arg2_type |
| 71 | +float test_double_arg1_arg2_type(double2 p1, double2 p2, float p3) { |
| 72 | + // CHECK: %conv = fptrunc reassoc nnan ninf nsz arcp afn <2 x double> %{{.*}} to <2 x half> |
| 73 | + // CHECK: %conv1 = fptrunc reassoc nnan ninf nsz arcp afn <2 x double> %{{.*}} to <2 x half> |
| 74 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 75 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 76 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 77 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 78 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 79 | + // CHECK: ret float %[[RES]] |
| 80 | + return dot2add(p1, p2, p3); |
| 81 | +} |
| 82 | + |
| 83 | +// CHECK-LABEL: define {{.*}}test_int16_arg1_arg2_type |
| 84 | +float test_int16_arg1_arg2_type(int16_t2 p1, int16_t2 p2, float p3) { |
| 85 | + // CHECK: %conv = sitofp <2 x i16> %{{.*}} to <2 x half> |
| 86 | + // CHECK: %conv1 = sitofp <2 x i16> %{{.*}} to <2 x half> |
| 87 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 88 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 89 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 90 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 91 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 92 | + // CHECK: ret float %[[RES]] |
| 93 | + return dot2add(p1, p2, p3); |
| 94 | +} |
| 95 | + |
| 96 | +// CHECK-LABEL: define {{.*}}test_int32_arg1_arg2_type |
| 97 | +float test_int32_arg1_arg2_type(int32_t2 p1, int32_t2 p2, float p3) { |
| 98 | + // CHECK: %conv = sitofp <2 x i32> %{{.*}} to <2 x half> |
| 99 | + // CHECK: %conv1 = sitofp <2 x i32> %{{.*}} to <2 x half> |
| 100 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 101 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 102 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 103 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 104 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 105 | + // CHECK: ret float %[[RES]] |
| 106 | + return dot2add(p1, p2, p3); |
| 107 | +} |
| 108 | + |
| 109 | +// CHECK-LABEL: define {{.*}}test_int64_arg1_arg2_type |
| 110 | +float test_int64_arg1_arg2_type(int64_t2 p1, int64_t2 p2, float p3) { |
| 111 | + // CHECK: %conv = sitofp <2 x i64> %{{.*}} to <2 x half> |
| 112 | + // CHECK: %conv1 = sitofp <2 x i64> %{{.*}} to <2 x half> |
| 113 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 114 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 115 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 116 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 117 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 118 | + // CHECK: ret float %[[RES]] |
| 119 | + return dot2add(p1, p2, p3); |
| 120 | +} |
| 121 | + |
| 122 | +// CHECK-LABEL: define {{.*}}test_bool_arg1_arg2_type |
| 123 | +float test_bool_arg1_arg2_type(bool2 p1, bool2 p2, float p3) { |
| 124 | + // CHECK: %loadedv = trunc <2 x i32> %{{.*}} to <2 x i1> |
| 125 | + // CHECK: %conv = uitofp <2 x i1> %loadedv to <2 x half> |
| 126 | + // CHECK: %loadedv1 = trunc <2 x i32> %{{.*}} to <2 x i1> |
| 127 | + // CHECK: %conv2 = uitofp <2 x i1> %loadedv1 to <2 x half> |
| 128 | + // CHECK-SPIRV: %[[MUL:.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.spv.fdot.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}) |
| 129 | + // CHECK-SPIRV: %[[CONV:.*]] = fpext reassoc nnan ninf nsz arcp afn half %[[MUL]] to float |
| 130 | + // CHECK-SPIRV: %[[C:.*]] = load float, ptr %c.addr.i, align 4 |
| 131 | + // CHECK-SPIRV: %[[RES:.*]] = fadd reassoc nnan ninf nsz arcp afn float %[[CONV]], %[[C]] |
| 132 | + // CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @llvm.dx.dot2add.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}}, float %{{.*}}) |
| 133 | + // CHECK: ret float %[[RES]] |
| 134 | + return dot2add(p1, p2, p3); |
| 135 | +} |
0 commit comments