|
| 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: %3 = fsub half %1, %0 |
| 10 | +// NATIVE_HALF: %4 = fmul half %2, %3 |
| 11 | +// NATIVE_HALF: %dx.lerp = fadd half %0, %4 |
| 12 | +// NATIVE_HALF: ret half %dx.lerp |
| 13 | +// NO_HALF: %3 = fsub float %1, %0 |
| 14 | +// NO_HALF: %4 = fmul float %2, %3 |
| 15 | +// NO_HALF: %dx.lerp = fadd float %0, %4 |
| 16 | +// NO_HALF: ret float %dx.lerp |
| 17 | +half test_lerp_half ( half p0) { |
| 18 | + return lerp ( p0, p0, p0 ); |
| 19 | +} |
| 20 | + |
| 21 | +// NATIVE_HALF: %dx.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x half> %0, <2 x half> %1, <2 x half> %2) |
| 22 | +// NATIVE_HALF: ret <2 x half> %dx.lerp |
| 23 | +// NO_HALF: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 x float> %1, <2 x float> %2) |
| 24 | +// NO_HALF: ret <2 x float> %dx.lerp |
| 25 | +half2 test_lerp_half2 ( half2 p0, half2 p1 ) { |
| 26 | + return lerp ( p0, p0, p0 ); |
| 27 | +} |
| 28 | + |
| 29 | +// NATIVE_HALF: %dx.lerp = call <3 x half> @llvm.dx.lerp.v3f16(<3 x half> %0, <3 x half> %1, <3 x half> %2) |
| 30 | +// NATIVE_HALF: ret <3 x half> %dx.lerp |
| 31 | +// NO_HALF: %dx.lerp = call <3 x float> @llvm.dx.lerp.v3f32(<3 x float> %0, <3 x float> %1, <3 x float> %2) |
| 32 | +// NO_HALF: ret <3 x float> %dx.lerp |
| 33 | +half3 test_lerp_half3 ( half3 p0, half3 p1 ) { |
| 34 | + return lerp ( p0, p0, p0 ); |
| 35 | +} |
| 36 | + |
| 37 | +// NATIVE_HALF: %dx.lerp = call <4 x half> @llvm.dx.lerp.v4f16(<4 x half> %0, <4 x half> %1, <4 x half> %2) |
| 38 | +// NATIVE_HALF: ret <4 x half> %dx.lerp |
| 39 | +// NO_HALF: %dx.lerp = call <4 x float> @llvm.dx.lerp.v4f32(<4 x float> %0, <4 x float> %1, <4 x float> %2) |
| 40 | +// NO_HALF: ret <4 x float> %dx.lerp |
| 41 | +half4 test_lerp_half4 ( half4 p0, half4 p1 ) { |
| 42 | + return lerp ( p0, p0, p0 ); |
| 43 | +} |
| 44 | + |
| 45 | +// CHECK: %3 = fsub float %1, %0 |
| 46 | +// CHECK: %4 = fmul float %2, %3 |
| 47 | +// CHECK: %dx.lerp = fadd float %0, %4 |
| 48 | +// CHECK: ret float %dx.lerp |
| 49 | +float test_lerp_float ( float p0, float p1 ) { |
| 50 | + return lerp ( p0, p0, p0 ); |
| 51 | +} |
| 52 | + |
| 53 | +// CHECK: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 x float> %1, <2 x float> %2) |
| 54 | +// CHECK: ret <2 x float> %dx.lerp |
| 55 | +float2 test_lerp_float2 ( float2 p0, float2 p1 ) { |
| 56 | + return lerp ( p0, p0, p0 ); |
| 57 | +} |
| 58 | + |
| 59 | +// CHECK: %dx.lerp = call <3 x float> @llvm.dx.lerp.v3f32(<3 x float> %0, <3 x float> %1, <3 x float> %2) |
| 60 | +// CHECK: ret <3 x float> %dx.lerp |
| 61 | +float3 test_lerp_float3 ( float3 p0, float3 p1 ) { |
| 62 | + return lerp ( p0, p0, p0 ); |
| 63 | +} |
| 64 | + |
| 65 | +// CHECK: %dx.lerp = call <4 x float> @llvm.dx.lerp.v4f32(<4 x float> %0, <4 x float> %1, <4 x float> %2) |
| 66 | +// CHECK: ret <4 x float> %dx.lerp |
| 67 | +float4 test_lerp_float4 ( float4 p0, float4 p1) { |
| 68 | + return lerp ( p0, p0, p0 ); |
| 69 | +} |
| 70 | + |
| 71 | +// CHECK: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %splat.splat, <2 x float> %1, <2 x float> %2) |
| 72 | +// CHECK: ret <2 x float> %dx.lerp |
| 73 | +float2 test_lerp_float2_splat ( float p0, float2 p1 ) { |
| 74 | + return lerp( p0, p1, p1 ); |
| 75 | +} |
| 76 | + |
| 77 | +// CHECK: %dx.lerp = call <3 x float> @llvm.dx.lerp.v3f32(<3 x float> %splat.splat, <3 x float> %1, <3 x float> %2) |
| 78 | +// CHECK: ret <3 x float> %dx.lerp |
| 79 | +float3 test_lerp_float3_splat ( float p0, float3 p1 ) { |
| 80 | + return lerp( p0, p1, p1 ); |
| 81 | +} |
| 82 | + |
| 83 | +// CHECK: %dx.lerp = call <4 x float> @llvm.dx.lerp.v4f32(<4 x float> %splat.splat, <4 x float> %1, <4 x float> %2) |
| 84 | +// CHECK: ret <4 x float> %dx.lerp |
| 85 | +float4 test_lerp_float4_splat ( float p0, float4 p1 ) { |
| 86 | + return lerp( p0, p1, p1 ); |
| 87 | +} |
| 88 | + |
| 89 | +// CHECK: %conv = sitofp i32 %2 to float |
| 90 | +// CHECK: %splat.splatinsert = insertelement <2 x float> poison, float %conv, i64 0 |
| 91 | +// CHECK: %splat.splat = shufflevector <2 x float> %splat.splatinsert, <2 x float> poison, <2 x i32> zeroinitializer |
| 92 | +// CHECK: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 x float> %1, <2 x float> %splat.splat) |
| 93 | +// CHECK: ret <2 x float> %dx.lerp |
| 94 | +float2 test_lerp_float2_int_splat ( float2 p0, int p1 ) { |
| 95 | + return lerp ( p0, p0, p1 ); |
| 96 | +} |
| 97 | + |
| 98 | +// CHECK: %conv = sitofp i32 %2 to float |
| 99 | +// CHECK: %splat.splatinsert = insertelement <3 x float> poison, float %conv, i64 0 |
| 100 | +// CHECK: %splat.splat = shufflevector <3 x float> %splat.splatinsert, <3 x float> poison, <3 x i32> zeroinitializer |
| 101 | +// CHECK: %dx.lerp = call <3 x float> @llvm.dx.lerp.v3f32(<3 x float> %0, <3 x float> %1, <3 x float> %splat.splat) |
| 102 | +// CHECK: ret <3 x float> %dx.lerp |
| 103 | +float3 test_lerp_float3_int_splat ( float3 p0, int p1 ) { |
| 104 | + return lerp ( p0, p0, p1 ); |
| 105 | +} |
0 commit comments