llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Kaitlin Peng (kmpeng) <details> <summary>Changes</summary> Closes #<!-- -->213098. This PR replaces the previous implementation of `step` with a new one inside the header files. Assisted-by: Claude Opus 4.8 --- Patch is 43.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/214604.diff 16 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.h (+1-1) - (modified) clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h (+4) - (modified) clang/lib/Sema/SemaHLSL.cpp (-13) - (modified) clang/test/CodeGenHLSL/builtins/step-overloads.hlsl (+82-64) - (modified) clang/test/CodeGenHLSL/builtins/step.hlsl (+34-46) - (modified) clang/test/SemaHLSL/BuiltIns/step-errors.hlsl (+21-13) - (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (-1) - (modified) llvm/include/llvm/IR/IntrinsicsSPIRV.td (-1) - (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (-26) - (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (-3) - (removed) llvm/test/CodeGen/DirectX/step.ll (-78) - (removed) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll (-33) ``````````diff diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index ea8dbb96fab56..b67a22ad50689 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -5767,12 +5767,6 @@ def HLSLSign : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } -def HLSLStep: LangBuiltin<"HLSL_LANG"> { - let Spellings = ["__builtin_hlsl_step"]; - let Attributes = [NoThrow, Const]; - let Prototype = "void(...)"; -} - def HLSLRadians : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_radians"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td index 56b031dbfa045..2d27728608c77 100644 --- a/clang/include/clang/Basic/HLSLIntrinsics.td +++ b/clang/include/clang/Basic/HLSLIntrinsics.td @@ -1562,7 +1562,7 @@ def hlsl_sqrt : HLSLOneArgBuiltin<"sqrt", "__builtin_elementwise_sqrt"> { // Returns 1 if the x parameter is greater than or equal to the y parameter; // otherwise, 0. -def hlsl_step : HLSLTwoArgBuiltin<"step", "__builtin_hlsl_step"> { +def hlsl_step : HLSLTwoArgDetail<"step", "step_impl"> { let Doc = [{ \fn T step(T y, T x) \brief Returns 1 if the x parameter is greater than or equal to the y @@ -1572,6 +1572,7 @@ parameter; otherwise, 0. Step is based on the following formula: (x >= y) ? 1 : 0 }]; + let ParamNames = ["y", "x"]; let VaryingTypes = [HalfTy, FloatTy]; let VaryingMatDims = []; } diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp index 45cb6de5b17c6..c7d1de29f0651 100644 --- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp +++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp @@ -1372,16 +1372,6 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, return SelectVal; } - case Builtin::BI__builtin_hlsl_step: { - Value *Op0 = EmitScalarExpr(E->getArg(0)); - Value *Op1 = EmitScalarExpr(E->getArg(1)); - assert(E->getArg(0)->getType()->hasFloatingRepresentation() && - E->getArg(1)->getType()->hasFloatingRepresentation() && - "step operands must have a float representation"); - return Builder.CreateIntrinsic( - /*ReturnType=*/Op0->getType(), CGM.getHLSLRuntime().getStepIntrinsic(), - ArrayRef<Value *>{Op0, Op1}, nullptr, "hlsl.step"); - } case Builtin::BI__builtin_hlsl_wave_active_all_equal: { Value *Op = EmitScalarExpr(E->getArg(0)); diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h index 9da6169c938fe..263d6faa8255c 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.h +++ b/clang/lib/CodeGen/CGHLSLRuntime.h @@ -134,7 +134,6 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(Rsqrt, rsqrt) GENERATE_HLSL_INTRINSIC_FUNCTION(Saturate, saturate) GENERATE_HLSL_INTRINSIC_FUNCTION(Sign, sign) - GENERATE_HLSL_INTRINSIC_FUNCTION(Step, step) GENERATE_HLSL_INTRINSIC_FUNCTION(Radians, radians) GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id) GENERATE_HLSL_INTRINSIC_FUNCTION(GroupThreadId, thread_id_in_group) diff --git a/clang/lib/Headers/hlsl.h b/clang/lib/Headers/hlsl.h index 684d29d5ed55b..8a144191c4695 100644 --- a/clang/lib/Headers/hlsl.h +++ b/clang/lib/Headers/hlsl.h @@ -22,10 +22,10 @@ // HLSL standard library function declarations/definitions. #include "hlsl/hlsl_alias_intrinsics.h" +#include "hlsl/hlsl_intrinsics.h" #if __HLSL_VERSION <= __HLSL_202x #include "hlsl/hlsl_compat_overloads.h" #endif -#include "hlsl/hlsl_intrinsics.h" #ifdef __spirv__ #include "hlsl/hlsl_spirv.h" diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h index 70ed581fab5a1..0b6adc66c672a 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h @@ -116,6 +116,10 @@ template <typename T> constexpr T smoothstep_impl(T Min, T Max, T X) { #endif } +template <typename T> constexpr T step_impl(T Y, T X) { + return select(X < Y, (T)0, (T)1); +} + 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 3fda2dbc0ffc6..3b9d9e4ed964b 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -4581,19 +4581,6 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { SetElementTypeAsReturnType(&SemaRef, TheCall, getASTContext().IntTy); break; } - case Builtin::BI__builtin_hlsl_step: { - if (SemaRef.checkArgCount(TheCall, 2)) - return true; - if (CheckAllArgTypesAreCorrect(&SemaRef, TheCall, - CheckFloatOrHalfRepresentation)) - return true; - - ExprResult A = TheCall->getArg(0); - QualType ArgTyA = A.get()->getType(); - // return type is the same as the input type - TheCall->setType(ArgTyA); - break; - } case Builtin::BI__builtin_hlsl_wave_active_all_equal: { if (SemaRef.checkArgCount(TheCall, 1)) return true; diff --git a/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl index 6a4733c067547..64723777d9485 100644 --- a/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl +++ b/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl @@ -1,215 +1,233 @@ // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ // RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm \ -// RUN: -Wdeprecated-declarations -o - | FileCheck %s --check-prefixes=CHECK \ -// RUN: -DFNATTRS="hidden noundef nofpclass(nan inf)" -DTARGET=dx +// RUN: -Wdeprecated-declarations -o - | FileCheck %s // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ // RUN: spirv-unknown-vulkan-library %s -emit-llvm \ -// RUN: -Wdeprecated-declarations -o - | FileCheck %s --check-prefixes=CHECK \ -// RUN: -DFNATTRS="hidden spir_func noundef nofpclass(nan inf)" -DTARGET=spv +// 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 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \ // RUN: -verify -verify-ignore-unexpected=note -// CHECK: define [[FNATTRS]] float @_Z16test_step_doubledd( +// CHECK-LABEL: test_step_double // CHECK: [[CONVI:%.*]] = fptrunc {{.*}} double %{{.*}} to float // CHECK: [[CONV1I:%.*]] = fptrunc {{.*}} double %{{.*}} to float -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} float @llvm.[[TARGET]].step.f32(float [[CONVI]], float [[CONV1I]]) -// CHECK: ret float [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt float %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} i1 [[CMP]], float 0.000000e+00, float 1.000000e+00 +// CHECK: ret float [[SELECT]] float test_step_double(double p0, double p1) { // expected-warning@+1 {{'step' is deprecated: In 202x 64 bit API lowering for step is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <2 x float> @_Z17test_step_double2Dv2_dS_( +// CHECK-LABEL: test_step_double2 // CHECK: [[CONVI:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float> // CHECK: [[CONV1I:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float> [[CONVI]], <2 x float> [[CONV1I]]) -// CHECK: ret <2 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <2 x i1> [[CMP]], <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00) +// CHECK: ret <2 x float> [[SELECT]] float2 test_step_double2(double2 p0, double2 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x 64 bit API lowering for step is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <3 x float> @_Z17test_step_double3Dv3_dS_( +// CHECK-LABEL: test_step_double3 // CHECK: [[CONVI:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float> // CHECK: [[CONV1I:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float> [[CONVI]], <3 x float> [[CONV1I]]) -// CHECK: ret <3 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <3 x i1> [[CMP]], <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00) +// CHECK: ret <3 x float> [[SELECT]] float3 test_step_double3(double3 p0, double3 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x 64 bit API lowering for step is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <4 x float> @_Z17test_step_double4Dv4_dS_( +// CHECK-LABEL: test_step_double4 // CHECK: [[CONVI:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float> // CHECK: [[CONV1I:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float> [[CONVI]], <4 x float> [[CONV1I]]) -// CHECK: ret <4 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <4 x i1> [[CMP]], <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00) +// CHECK: ret <4 x float> [[SELECT]] float4 test_step_double4(double4 p0, double4 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x 64 bit API lowering for step is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] float @_Z13test_step_intii( +// CHECK-LABEL: test_step_int // CHECK: [[CONVI:%.*]] = sitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} i32 %{{.*}} to float -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} float @llvm.[[TARGET]].step.f32(float [[CONVI]], float [[CONV1I]]) -// CHECK: ret float [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt float %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} i1 [[CMP]], float 0.000000e+00, float 1.000000e+00 +// CHECK: ret float [[SELECT]] float test_step_int(int p0, int p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <2 x float> @_Z14test_step_int2Dv2_iS_( +// CHECK-LABEL: test_step_int2 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float> [[CONVI]], <2 x float> [[CONV1I]]) -// CHECK: ret <2 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <2 x i1> [[CMP]], <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00) +// CHECK: ret <2 x float> [[SELECT]] float2 test_step_int2(int2 p0, int2 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <3 x float> @_Z14test_step_int3Dv3_iS_( +// CHECK-LABEL: test_step_int3 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float> [[CONVI]], <3 x float> [[CONV1I]]) -// CHECK: ret <3 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <3 x i1> [[CMP]], <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00) +// CHECK: ret <3 x float> [[SELECT]] float3 test_step_int3(int3 p0, int3 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <4 x float> @_Z14test_step_int4Dv4_iS_( +// CHECK-LABEL: test_step_int4 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float> [[CONVI]], <4 x float> [[CONV1I]]) -// CHECK: ret <4 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <4 x i1> [[CMP]], <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00) +// CHECK: ret <4 x float> [[SELECT]] float4 test_step_int4(int4 p0, int4 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] float @_Z14test_step_uintjj( +// CHECK-LABEL: test_step_uint // CHECK: [[CONVI:%.*]] = uitofp {{.*}} i32 %{{.*}} to float // CHECK: [[CONV1I:%.*]] = uitofp {{.*}} i32 %{{.*}} to float -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} float @llvm.[[TARGET]].step.f32(float [[CONVI]], float [[CONV1I]]) -// CHECK: ret float [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt float %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} i1 [[CMP]], float 0.000000e+00, float 1.000000e+00 +// CHECK: ret float [[SELECT]] float test_step_uint(uint p0, uint p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <2 x float> @_Z15test_step_uint2Dv2_jS_( +// CHECK-LABEL: test_step_uint2 // CHECK: [[CONVI:%.*]] = uitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> // CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <2 x i32> %{{.*}} to <2 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float> [[CONVI]], <2 x float> [[CONV1I]]) -// CHECK: ret <2 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <2 x i1> [[CMP]], <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00) +// CHECK: ret <2 x float> [[SELECT]] float2 test_step_uint2(uint2 p0, uint2 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <3 x float> @_Z15test_step_uint3Dv3_jS_( +// CHECK-LABEL: test_step_uint3 // CHECK: [[CONVI:%.*]] = uitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> // CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <3 x i32> %{{.*}} to <3 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float> [[CONVI]], <3 x float> [[CONV1I]]) -// CHECK: ret <3 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <3 x i1> [[CMP]], <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00) +// CHECK: ret <3 x float> [[SELECT]] float3 test_step_uint3(uint3 p0, uint3 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <4 x float> @_Z15test_step_uint4Dv4_jS_( +// CHECK-LABEL: test_step_uint4 // CHECK: [[CONVI:%.*]] = uitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> // CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <4 x i32> %{{.*}} to <4 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float> [[CONVI]], <4 x float> [[CONV1I]]) -// CHECK: ret <4 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <4 x i1> [[CMP]], <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00) +// CHECK: ret <4 x float> [[SELECT]] float4 test_step_uint4(uint4 p0, uint4 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] float @_Z17test_step_int64_tll( +// CHECK-LABEL: test_step_int64_t // CHECK: [[CONVI:%.*]] = sitofp {{.*}} i64 %{{.*}} to float // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} i64 %{{.*}} to float -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} float @llvm.[[TARGET]].step.f32(float [[CONVI]], float [[CONV1I]]) -// CHECK: ret float [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt float %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} i1 [[CMP]], float 0.000000e+00, float 1.000000e+00 +// CHECK: ret float [[SELECT]] float test_step_int64_t(int64_t p0, int64_t p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <2 x float> @_Z18test_step_int64_t2Dv2_lS_( +// CHECK-LABEL: test_step_int64_t2 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <2 x i64> %{{.*}} to <2 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <2 x i64> %{{.*}} to <2 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float> [[CONVI]], <2 x float> [[CONV1I]]) -// CHECK: ret <2 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <2 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <2 x i1> [[CMP]], <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00) +// CHECK: ret <2 x float> [[SELECT]] float2 test_step_int64_t2(int64_t2 p0, int64_t2 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <3 x float> @_Z18test_step_int64_t3Dv3_lS_( +// CHECK-LABEL: test_step_int64_t3 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <3 x i64> %{{.*}} to <3 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <3 x i64> %{{.*}} to <3 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float> [[CONVI]], <3 x float> [[CONV1I]]) -// CHECK: ret <3 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <3 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <3 x i1> [[CMP]], <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00) +// CHECK: ret <3 x float> [[SELECT]] float3 test_step_int64_t3(int64_t3 p0, int64_t3 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}} return step(p0, p1); } -// CHECK: define [[FNATTRS]] <4 x float> @_Z18test_step_int64_t4Dv4_lS_( +// CHECK-LABEL: test_step_int64_t4 // CHECK: [[CONVI:%.*]] = sitofp {{.*}} <4 x i64> %{{.*}} to <4 x float> // CHECK: [[CONV1I:%.*]] = sitofp {{.*}} <4 x i64> %{{.*}} to <4 x float> -// CHECK: [[HLSLSTEPI:%.*]] = call {{.*}} <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float> [[CONVI]], <4 x float> [[CONV1I]]) -// CHECK: ret <4 x float> [[HLSLSTEPI]] +// CHECK: [[CMP:%.*]] = fcmp {{.*}} olt <4 x float> %{{.*}}, %{{.*}} +// CHECK: [[SELECT:%.*]] = select {{.*}} <4 x i1> [[CMP]], <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00) +// CHECK: ret <4 x float> [[SELECT]] float4 test_step_int64_t4(int64_t4 p0, int64_t4 p1) { // expected-warning@+1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly ca... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/214604 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
