llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-clang-codegen Author: Kaitlin Peng (kmpeng) <details> <summary>Changes</summary> Closes #<!-- -->213097. This PR replaces the previous implementation of `lerp` with a new one inside the header files. It also cleans up the tests to use 3 distinct parameters (x, y, s) for consistency with other similar tests. The SPIRV intrinsic (`int_spv_lerp`) and its lowering are intentionally kept, since a follow-up will pattern match `X + S * (Y - X)` back to the extended instruction and needs the SPIRV intrinsic to do so. Assisted-by: Claude Opus 4.8 --- Patch is 49.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/215692.diff 13 Files Affected: - (modified) clang/include/clang/Basic/Builtins.td (-6) - (modified) clang/include/clang/Basic/HLSLIntrinsics.td (+2-1) - (modified) clang/lib/CodeGen/CGHLSLBuiltins.cpp (-10) - (modified) clang/lib/CodeGen/CGHLSLRuntime.h (-1) - (modified) clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h (+4) - (modified) clang/lib/Sema/SemaHLSL.cpp (-12) - (removed) clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl (-12) - (modified) clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl (+180-116) - (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+57-56) - (removed) clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl (-130) - (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (-3) - (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (-14) - (removed) llvm/test/CodeGen/DirectX/lerp.ll (-56) ``````````diff diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index a54f91069acd0..ab39f535edd8b 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -5707,12 +5707,6 @@ def HLSLIsnan : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } -def HLSLLerp : LangBuiltin<"HLSL_LANG"> { - let Spellings = ["__builtin_hlsl_lerp"]; - let Attributes = [NoThrow, Const, CustomTypeChecking]; - let Prototype = "void(...)"; -} - def HLSLMad : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_mad"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td index 4373d04ab2f22..6027fba17e15f 100644 --- a/clang/include/clang/Basic/HLSLIntrinsics.td +++ b/clang/include/clang/Basic/HLSLIntrinsics.td @@ -1143,7 +1143,7 @@ Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...). } // Returns the linear interpolation of x to y by s. -def hlsl_lerp : HLSLThreeArgBuiltin<"lerp", "__builtin_hlsl_lerp"> { +def hlsl_lerp : HLSLThreeArgDetail<"lerp", "lerp_impl"> { let Doc = [{ \fn T lerp(T x, T y, T s) \brief Returns the linear interpolation of x to y by s. @@ -1155,6 +1155,7 @@ the y parameter. Linear interpolation is based on the following formula: x*(1-s) + y*s which can equivalently be written as x + s(y-x). }]; + let ParamNames = ["x", "y", "s"]; let VaryingTypes = [HalfTy, FloatTy]; let VaryingMatDims = []; } diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp index 8df92da988f65..137fba2cff1bc 100644 --- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp +++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp @@ -1137,16 +1137,6 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, CGM.getHLSLRuntime().getFirstBitLowIntrinsic(), ArrayRef<Value *>{X}, nullptr, "hlsl.firstbitlow"); } - case Builtin::BI__builtin_hlsl_lerp: { - Value *X = EmitScalarExpr(E->getArg(0)); - Value *Y = EmitScalarExpr(E->getArg(1)); - Value *S = EmitScalarExpr(E->getArg(2)); - if (!E->getArg(0)->getType()->hasFloatingRepresentation()) - llvm_unreachable("lerp operand must have a float representation"); - return Builder.CreateIntrinsic( - /*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(), - ArrayRef<Value *>{X, Y, S}, nullptr, "hlsl.lerp"); - } case Builtin::BI__builtin_hlsl_normalize: { Value *X = EmitScalarExpr(E->getArg(0)); diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h index f5674b64d0041..28e8798202807 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.h +++ b/clang/lib/CodeGen/CGHLSLRuntime.h @@ -129,7 +129,6 @@ class CGHLSLRuntime { flattened_thread_id_in_group) GENERATE_HLSL_INTRINSIC_FUNCTION(IsInf, isinf) GENERATE_HLSL_INTRINSIC_FUNCTION(IsNaN, isnan) - GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp) GENERATE_HLSL_INTRINSIC_FUNCTION(Normalize, normalize) GENERATE_HLSL_INTRINSIC_FUNCTION(Rsqrt, rsqrt) GENERATE_HLSL_INTRINSIC_FUNCTION(Saturate, saturate) diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h index 0b6adc66c672a..d96199f206504 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h @@ -120,6 +120,10 @@ template <typename T> constexpr T step_impl(T Y, T X) { return select(X < Y, (T)0, (T)1); } +template <typename T> constexpr T lerp_impl(T X, T Y, T S) { + return X + S * (Y - X); +} + template <typename T> constexpr vector<T, 4> lit_impl(T NDotL, T NDotH, T M) { bool DiffuseCond = NDotL < 0; T Diffuse = select<T>(DiffuseCond, 0, NDotL); diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 4c9ef04da609b..89ff1061d65a5 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -4466,18 +4466,6 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { SetElementTypeAsReturnType(&SemaRef, TheCall, getASTContext().BoolTy); break; } - case Builtin::BI__builtin_hlsl_lerp: { - if (SemaRef.checkArgCount(TheCall, 3)) - return true; - if (CheckAllArgTypesAreCorrect(&SemaRef, TheCall, - CheckFloatOrHalfRepresentation)) - return true; - if (CheckAllArgsHaveSameType(&SemaRef, TheCall)) - return true; - if (SemaRef.BuiltinElementwiseTernaryMath(TheCall)) - return true; - break; - } case Builtin::BI__builtin_hlsl_mad: { if (SemaRef.BuiltinElementwiseTernaryMath( TheCall, /*ArgTyRestr=*/ diff --git a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl deleted file mode 100644 index cb8634c9234e3..0000000000000 --- a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s - - -// CHECK-LABEL: builtin_lerp_half -// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn half @llvm.dx.lerp.f16(half %{{.*}}, half %{{.*}}, half %{{.*}}) -// CHECK: ret half %hlsl.lerp -half builtin_lerp_half(half p0) { return __builtin_hlsl_lerp(p0, p0, p0); } - -// CHECK-LABEL: builtin_lerp_float -// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.dx.lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}) -// CHECK: ret float %hlsl.lerp -float builtin_lerp_float(float p0) { return __builtin_hlsl_lerp(p0, p0, p0); } diff --git a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl index 19a0cf46dfcdd..2e915141fac9a 100644 --- a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl +++ b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl @@ -1,181 +1,245 @@ -// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NATIVE_HALF -DFNATTRS="hidden noundef nofpclass(nan inf)" -DTARGET=dx -// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF -DFNATTRS="hidden noundef nofpclass(nan inf)" -DTARGET=dx -// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s -fnative-half-type -fnative-int16-type -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NATIVE_HALF -DFNATTRS="hidden spir_func noundef nofpclass(nan inf)" -DTARGET=spv -// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF -DFNATTRS="hidden spir_func noundef nofpclass(nan inf)" -DTARGET=spv +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s \ +// RUN: -verify -verify-ignore-unexpected=note -// CHECK: define [[FNATTRS]] float @_Z16test_lerp_doubled( +// CHECK-LABEL: test_lerp_double // CHECK: [[CONV0:%.*]] = fptrunc {{.*}} double %{{.*}} to float // CHECK: [[CONV1:%.*]] = fptrunc {{.*}} double %{{.*}} to float // CHECK: [[CONV2:%.*]] = fptrunc {{.*}} double %{{.*}} to float -// CHECK: [[LERP:%.*]] = call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV0]], float [[CONV1]], float [[CONV2]]) -// CHECK: ret float [[LERP]] -float test_lerp_double(double p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <2 x float> @_Z17test_lerp_double2Dv2_d( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn float %{{.*}}, [[MUL]] +// CHECK: ret float [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x 64 bit API lowering for lerp is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +float test_lerp_double(double x, double y, double s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_double2 // CHECK: [[CONV0:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float> // CHECK: [[CONV1:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float> // CHECK: [[CONV2:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV0]], <2 x float> [[CONV1]], <2 x float> [[CONV2]]) -// CHECK: ret <2 x float> [[LERP]] -float2 test_lerp_double2(double2 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <3 x float> @_Z17test_lerp_double3Dv3_d( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[MUL]] +// CHECK: ret <2 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x 64 bit API lowering for lerp is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +float2 test_lerp_double2(double2 x, double2 y, double2 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_double3 // CHECK: [[CONV0:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float> // CHECK: [[CONV1:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float> // CHECK: [[CONV2:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV0]], <3 x float> [[CONV1]], <3 x float> [[CONV2]]) -// CHECK: ret <3 x float> [[LERP]] -float3 test_lerp_double3(double3 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <4 x float> @_Z17test_lerp_double4Dv4_d( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[MUL]] +// CHECK: ret <3 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x 64 bit API lowering for lerp is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +float3 test_lerp_double3(double3 x, double3 y, double3 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_double4 // CHECK: [[CONV0:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float> // CHECK: [[CONV1:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float> // CHECK: [[CONV2:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV0]], <4 x float> [[CONV1]], <4 x float> [[CONV2]]) -// CHECK: ret <4 x float> [[LERP]] -float4 test_lerp_double4(double4 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] float @_Z13test_lerp_inti( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, [[MUL]] +// CHECK: ret <4 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x 64 bit API lowering for lerp is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +float4 test_lerp_double4(double4 x, double4 y, double4 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_int // CHECK: [[CONV0:%.*]] = sitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV1:%.*]] = sitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV2:%.*]] = sitofp {{.*}} i32 %{{.*}} to float -// CHECK: [[LERP:%.*]] = call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV0]], float [[CONV1]], float [[CONV2]]) -// CHECK: ret float [[LERP]] -float test_lerp_int(int p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <2 x float> @_Z14test_lerp_int2Dv2_i( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn float %{{.*}}, [[MUL]] +// CHECK: ret float [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float test_lerp_int(int x, int y, int s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_int2 // CHECK: [[CONV0:%.*]] = sitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV1:%.*]] = sitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV2:%.*]] = sitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV0]], <2 x float> [[CONV1]], <2 x float> [[CONV2]]) -// CHECK: ret <2 x float> [[LERP]] -float2 test_lerp_int2(int2 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <3 x float> @_Z14test_lerp_int3Dv3_i( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[MUL]] +// CHECK: ret <2 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float2 test_lerp_int2(int2 x, int2 y, int2 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_int3 // CHECK: [[CONV0:%.*]] = sitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV1:%.*]] = sitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV2:%.*]] = sitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV0]], <3 x float> [[CONV1]], <3 x float> [[CONV2]]) -// CHECK: ret <3 x float> [[LERP]] -float3 test_lerp_int3(int3 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <4 x float> @_Z14test_lerp_int4Dv4_i( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[MUL]] +// CHECK: ret <3 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float3 test_lerp_int3(int3 x, int3 y, int3 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_int4 // CHECK: [[CONV0:%.*]] = sitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV1:%.*]] = sitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV2:%.*]] = sitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV0]], <4 x float> [[CONV1]], <4 x float> [[CONV2]]) -// CHECK: ret <4 x float> [[LERP]] -float4 test_lerp_int4(int4 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] float @_Z14test_lerp_uintj( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, [[MUL]] +// CHECK: ret <4 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float4 test_lerp_int4(int4 x, int4 y, int4 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_uint // CHECK: [[CONV0:%.*]] = uitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV1:%.*]] = uitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV2:%.*]] = uitofp {{.*}} i32 %{{.*}} to float -// CHECK: [[LERP:%.*]] = call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV0]], float [[CONV1]], float [[CONV2]]) -// CHECK: ret float [[LERP]] -float test_lerp_uint(uint p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <2 x float> @_Z15test_lerp_uint2Dv2_j( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn float %{{.*}}, [[MUL]] +// CHECK: ret float [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float test_lerp_uint(uint x, uint y, uint s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_uint2 // CHECK: [[CONV0:%.*]] = uitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV1:%.*]] = uitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV2:%.*]] = uitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV0]], <2 x float> [[CONV1]], <2 x float> [[CONV2]]) -// CHECK: ret <2 x float> [[LERP]] -float2 test_lerp_uint2(uint2 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <3 x float> @_Z15test_lerp_uint3Dv3_j( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <2 x float> %{{.*}}, [[MUL]] +// CHECK: ret <2 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float2 test_lerp_uint2(uint2 x, uint2 y, uint2 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_uint3 // CHECK: [[CONV0:%.*]] = uitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV1:%.*]] = uitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV2:%.*]] = uitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV0]], <3 x float> [[CONV1]], <3 x float> [[CONV2]]) -// CHECK: ret <3 x float> [[LERP]] -float3 test_lerp_uint3(uint3 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] <4 x float> @_Z15test_lerp_uint4Dv4_j( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <3 x float> %{{.*}}, [[MUL]] +// CHECK: ret <3 x float> [[ADD]] +// expected-warning@+1 {{'lerp' is deprecated: In 202x int lowering for lerp is deprecated. Explicitly cast parameters to float types.}} +float3 test_lerp_uint3(uint3 x, uint3 y, uint3 s) { return lerp(x, y, s); } + +// CHECK-LABEL: test_lerp_uint4 // CHECK: [[CONV0:%.*]] = uitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV1:%.*]] = uitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV2:%.*]] = uitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> -// CHECK: [[LERP:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV0]], <4 x float> [[CONV1]], <4 x float> [[CONV2]]) -// CHECK: ret <4 x float> [[LERP]] -float4 test_lerp_uint4(uint4 p0) { return lerp(p0, p0, p0); } - -// CHECK: define [[FNATTRS]] float @_Z17test_lerp_int64_tl( +// CHECK: [[SUB:%.*]] = fsub reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <4 x float> %{{.*}}, [[SUB]] +// CHECK: [[ADD:%.*]] = fadd reassoc nnan ninf nsz arcp afn <4 x ... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/215692 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
