[clang] 2299be0 - [HLSL] Move `step` implementation to header files (#214604)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 10 11:00:46 PDT 2026
Author: Kaitlin Peng
Date: 2026-08-10T11:00:40-07:00
New Revision: 2299be09be289e8fcf840ee73359528661cee259
URL: https://github.com/llvm/llvm-project/commit/2299be09be289e8fcf840ee73359528661cee259
DIFF: https://github.com/llvm/llvm-project/commit/2299be09be289e8fcf840ee73359528661cee259.diff
LOG: [HLSL] Move `step` implementation to header files (#214604)
Closes #213098.
This PR replaces the previous implementation of `step` with a new one
inside the header files.
Assisted-by: Claude Opus 4.8
Added:
Modified:
clang/include/clang/Basic/Builtins.td
clang/include/clang/Basic/HLSLIntrinsics.td
clang/lib/CodeGen/CGHLSLBuiltins.cpp
clang/lib/CodeGen/CGHLSLRuntime.h
clang/lib/Headers/hlsl.h
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
clang/lib/Sema/SemaHLSL.cpp
clang/test/CodeGenHLSL/builtins/step-overloads.hlsl
clang/test/CodeGenHLSL/builtins/step.hlsl
clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
llvm/include/llvm/IR/IntrinsicsDirectX.td
llvm/include/llvm/IR/IntrinsicsSPIRV.td
llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
Removed:
llvm/test/CodeGen/DirectX/step.ll
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll
################################################################################
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..2480f61f0a105 100644
--- a/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/step-overloads.hlsl
@@ -1,215 +1,228 @@
// 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: %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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 @_Z18test_step_uint64_tmm(
+// CHECK-LABEL: test_step_uint64_t
// CHECK: [[CONVI:%.*]] = uitofp {{.*}} i64 %{{.*}} to float
// CHECK: [[CONV1I:%.*]] = uitofp {{.*}} 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_uint64_t(uint64_t p0, uint64_t p1)
{
// expected-warning at +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> @_Z19test_step_uint64_t2Dv2_mS_(
+// CHECK-LABEL: test_step_uint64_t2
// CHECK: [[CONVI:%.*]] = uitofp {{.*}} <2 x i64> %{{.*}} to <2 x float>
// CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <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_uint64_t2(uint64_t2 p0, uint64_t2 p1)
{
// expected-warning at +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> @_Z19test_step_uint64_t3Dv3_mS_(
+// CHECK-LABEL: test_step_uint64_t3
// CHECK: [[CONVI:%.*]] = uitofp {{.*}} <3 x i64> %{{.*}} to <3 x float>
// CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <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_uint64_t3(uint64_t3 p0, uint64_t3 p1)
{
// expected-warning at +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> @_Z19test_step_uint64_t4Dv4_mS_(
+// CHECK-LABEL: test_step_uint64_t4
// CHECK: [[CONVI:%.*]] = uitofp {{.*}} <4 x i64> %{{.*}} to <4 x float>
// CHECK: [[CONV1I:%.*]] = uitofp {{.*}} <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_uint64_t4(uint64_t4 p0, uint64_t4 p1)
{
// expected-warning at +1 {{'step' is deprecated: In 202x int lowering for step is deprecated. Explicitly cast parameters to float types.}}
diff --git a/clang/test/CodeGenHLSL/builtins/step.hlsl b/clang/test/CodeGenHLSL/builtins/step.hlsl
index c2da511508110..1587edfbcc604 100644
--- a/clang/test/CodeGenHLSL/builtins/step.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/step.hlsl
@@ -1,83 +1,68 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type \
-// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN: --check-prefixes=CHECK,NATIVE_HALF \
-// RUN: -DFNATTRS="hidden noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \
-// RUN: -DFNATTRS="hidden noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: spirv-unknown-vulkan-library %s -fnative-half-type -fnative-int16-type \
-// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN: --check-prefixes=CHECK,NATIVE_HALF \
-// RUN: -DFNATTRS="hidden spir_func noundef nofpclass(nan inf)" -DTARGET=spv
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: spirv-unknown-vulkan-library %s -emit-llvm -disable-llvm-passes \
-// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \
-// RUN: -DFNATTRS="hidden spir_func noundef nofpclass(nan inf)" -DTARGET=spv
+// RUN: -emit-llvm -O1 -o - | FileCheck %s
-// NATIVE_HALF: define [[FNATTRS]] half @
-// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn half @llvm.[[TARGET]].step.f16(half
-// NO_HALF: call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].step.f32(float
-// NATIVE_HALF: ret half
-// NO_HALF: ret float
+// CHECK-LABEL: test_step_half
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[CMP]], half 0.000000e+00, half 1.000000e+00
+// CHECK-NEXT: ret half [[SELECT]]
half test_step_half(half p0, half p1)
{
return step(p0, p1);
}
-// NATIVE_HALF: define [[FNATTRS]] <2 x half> @
-// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <2 x half> @llvm.[[TARGET]].step.v2f16(<2 x half>
-// NO_HALF: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float>
-// NATIVE_HALF: ret <2 x half> %hlsl.step
-// NO_HALF: ret <2 x float> %hlsl.step
+// CHECK-LABEL: test_step_half2
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <2 x half> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <2 x i1> [[CMP]], <2 x half> zeroinitializer, <2 x half> splat (half 1.000000e+00)
+// CHECK-NEXT: ret <2 x half> [[SELECT]]
half2 test_step_half2(half2 p0, half2 p1)
{
return step(p0, p1);
}
-// NATIVE_HALF: define [[FNATTRS]] <3 x half> @
-// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.[[TARGET]].step.v3f16(<3 x half>
-// NO_HALF: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float>
-// NATIVE_HALF: ret <3 x half> %hlsl.step
-// NO_HALF: ret <3 x float> %hlsl.step
+// CHECK-LABEL: test_step_half3
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <3 x half> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <3 x i1> [[CMP]], <3 x half> zeroinitializer, <3 x half> splat (half 1.000000e+00)
+// CHECK-NEXT: ret <3 x half> [[SELECT]]
half3 test_step_half3(half3 p0, half3 p1)
{
return step(p0, p1);
}
-// NATIVE_HALF: define [[FNATTRS]] <4 x half> @
-// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.[[TARGET]].step.v4f16(<4 x half>
-// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float>
-// NATIVE_HALF: ret <4 x half> %hlsl.step
-// NO_HALF: ret <4 x float> %hlsl.step
+// CHECK-LABEL: test_step_half4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <4 x half> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <4 x i1> [[CMP]], <4 x half> zeroinitializer, <4 x half> splat (half 1.000000e+00)
+// CHECK-NEXT: ret <4 x half> [[SELECT]]
half4 test_step_half4(half4 p0, half4 p1)
{
return step(p0, p1);
}
-// CHECK: define [[FNATTRS]] float @
-// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].step.f32(float
-// CHECK: ret float
+// CHECK-LABEL: test_step_float
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[CMP]], float 0.000000e+00, float 1.000000e+00
+// CHECK-NEXT: ret float [[SELECT]]
float test_step_float(float p0, float p1)
{
return step(p0, p1);
}
-// CHECK: define [[FNATTRS]] <2 x float> @
-// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].step.v2f32(
-// CHECK: ret <2 x float> %hlsl.step
+// CHECK-LABEL: test_step_float2
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <2 x float> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <2 x i1> [[CMP]], <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00)
+// CHECK-NEXT: ret <2 x float> [[SELECT]]
float2 test_step_float2(float2 p0, float2 p1)
{
return step(p0, p1);
}
-// CHECK: define [[FNATTRS]] <3 x float> @
-// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].step.v3f32(
-// CHECK: ret <3 x float> %hlsl.step
+// CHECK-LABEL: test_step_float3
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <3 x float> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <3 x i1> [[CMP]], <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00)
+// CHECK-NEXT: ret <3 x float> [[SELECT]]
float3 test_step_float3(float3 p0, float3 p1)
{
return step(p0, p1);
}
-// CHECK: define [[FNATTRS]] <4 x float> @
-// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].step.v4f32(
-// CHECK: ret <4 x float> %hlsl.step
+// CHECK-LABEL: test_step_float4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <4 x float> %p1, %p0
+// CHECK-NEXT: [[SELECT:%.*]] = select reassoc nnan ninf nsz arcp afn <4 x i1> [[CMP]], <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00)
+// CHECK-NEXT: ret <4 x float> [[SELECT]]
float4 test_step_float4(float4 p0, float4 p1)
{
return step(p0, p1);
diff --git a/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
index 993450a17ebfb..dfe9d50dfb71e 100644
--- a/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
@@ -2,30 +2,38 @@
void test_too_few_arg()
{
- return __builtin_hlsl_step();
- // expected-error at -1 {{too few arguments to function call, expected 2, have 0}}
+ return step();
+ // expected-error at -1 {{no matching function for call to 'step'}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_compat_overloads.h:* 20 {{candidate function not viable: requires 2 arguments, but 0 were provided}}
}
void test_too_many_arg(float2 p0)
{
- return __builtin_hlsl_step(p0, p0, p0);
- // expected-error at -1 {{too many arguments to function call, expected 2, have 3}}
+ return step(p0, p0, p0);
+ // expected-error at -1 {{no matching function for call to 'step'}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_compat_overloads.h:* 20 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
-bool builtin_bool_to_float_type_promotion(bool p1)
+bool test_bool_to_float_type_promotion(bool p1)
{
- return __builtin_hlsl_step(p1, p1);
- // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'bool')}}
+ return step(p1, p1);
+ // expected-error at -1 {{call to 'step' is ambiguous}}
+ // expected-note at hlsl/hlsl_compat_overloads.h:* 3 {{candidate function}}
}
-bool builtin_step_int_to_float_promotion(int p1)
+float1 test_vec1_inputs(float1 p0, float1 p1)
{
- return __builtin_hlsl_step(p1, p1);
- // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int')}}
+ return step(p0, p1);
+ // expected-warning at -1 2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
-bool2 builtin_step_int2_to_float2_promotion(int2 p1)
+typedef float float5 __attribute__((ext_vector_type(5)));
+
+float5 test_vec5_inputs(float5 p0, float5 p1)
{
- return __builtin_hlsl_step(p1, p1);
- // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int2' (aka 'vector<int, 2>'))}}
+ return step(p0, p1);
+ // expected-error at -1 {{call to 'step' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/llvm/include/llvm/IR/IntrinsicsDirectX.td b/llvm/include/llvm/IR/IntrinsicsDirectX.td
index 62489b58a0300..0cf68a173930a 100644
--- a/llvm/include/llvm/IR/IntrinsicsDirectX.td
+++ b/llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -287,7 +287,6 @@ def int_dx_quad_read_across_x : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchT
def int_dx_quad_read_across_y : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrConvergent, IntrNoMem, IntrTriviallyScalarizable]>;
def int_dx_quad_read_across_diagonal : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrConvergent, IntrNoMem, IntrTriviallyScalarizable]>;
def int_dx_sign : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_any_ty], [IntrNoMem]>;
-def int_dx_step : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>], [IntrNoMem]>;
def int_dx_splitdouble : DefaultAttrsIntrinsic<[llvm_anyint_ty, LLVMMatchType<0>],
[LLVMScalarOrSameVectorWidth<0, llvm_double_ty>], [IntrNoMem, IntrTriviallyScalarizable]>;
def int_dx_imul : DefaultAttrsIntrinsic<[llvm_anyint_ty, LLVMMatchType<0>],
diff --git a/llvm/include/llvm/IR/IntrinsicsSPIRV.td b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
index 18b06cd30de25..b88d638be1019 100644
--- a/llvm/include/llvm/IR/IntrinsicsSPIRV.td
+++ b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
@@ -124,7 +124,6 @@ let TargetPrefix = "spv" in {
def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
def int_spv_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>;
def int_spv_smoothstep : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
- def int_spv_step : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [LLVMMatchType<0>, llvm_anyfloat_ty], [IntrNoMem]>;
def int_spv_fdot :
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
[llvm_anyfloat_ty, LLVMScalarOrSameVectorWidth<0, LLVMVectorElementType<0>>],
diff --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
index c5b8b4efee956..cbaf21f279581 100644
--- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
+++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
@@ -225,7 +225,6 @@ static bool isIntrinsicExpansion(Function &F) {
case Intrinsic::dx_sdot:
case Intrinsic::dx_udot:
case Intrinsic::dx_sign:
- case Intrinsic::dx_step:
case Intrinsic::dx_radians:
case Intrinsic::usub_sat:
case Intrinsic::vector_reduce_add:
@@ -801,28 +800,6 @@ static Value *expandPowIntrinsic(CallInst *Orig, Intrinsic::ID IntrinsicId) {
return Exp2Call;
}
-static Value *expandStepIntrinsic(CallInst *Orig) {
-
- Value *X = Orig->getOperand(0);
- Value *Y = Orig->getOperand(1);
- Type *Ty = X->getType();
- IRBuilder<> Builder(Orig);
-
- Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
- Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
- Value *Cond = Builder.CreateFCmpOLT(Y, X);
-
- if (Ty != Ty->getScalarType()) {
- auto *XVec = dyn_cast<FixedVectorType>(Ty);
- One = ConstantVector::getSplat(
- ElementCount::getFixed(XVec->getNumElements()), One);
- Zero = ConstantVector::getSplat(
- ElementCount::getFixed(XVec->getNumElements()), Zero);
- }
-
- return Builder.CreateSelect(Cond, Zero, One);
-}
-
static Value *expandRadiansIntrinsic(CallInst *Orig) {
Value *X = Orig->getOperand(0);
Type *Ty = X->getType();
@@ -1361,9 +1338,6 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
case Intrinsic::dx_sign:
Result = expandSignIntrinsic(Orig);
break;
- case Intrinsic::dx_step:
- Result = expandStepIntrinsic(Orig);
- break;
case Intrinsic::dx_radians:
Result = expandRadiansIntrinsic(Orig);
break;
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index ab06532db397c..a13775f9d02ad 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -748,7 +748,6 @@ static bool intrinsicHasSideEffects(Intrinsic::ID ID) {
case Intrinsic::spv_sdot:
case Intrinsic::spv_sign:
case Intrinsic::spv_smoothstep:
- case Intrinsic::spv_step:
case Intrinsic::spv_subgroup_id:
case Intrinsic::spv_subgroup_local_invocation_id:
case Intrinsic::spv_subgroup_max_size:
@@ -5625,8 +5624,6 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
case Intrinsic::spv_quad_read_across_diagonal: {
return selectQuadSwap(ResVReg, ResType, I, /*Direction*/ 2);
}
- case Intrinsic::spv_step:
- return selectExtInst(ResVReg, ResType, I, CL::step, GL::Step);
case Intrinsic::spv_radians:
return selectExtInst(ResVReg, ResType, I, CL::radians, GL::Radians);
// Discard intrinsics which we do not expect to actually represent code after
diff --git a/llvm/test/CodeGen/DirectX/step.ll b/llvm/test/CodeGen/DirectX/step.ll
deleted file mode 100644
index 7dbd59d55e2b1..0000000000000
--- a/llvm/test/CodeGen/DirectX/step.ll
+++ /dev/null
@@ -1,78 +0,0 @@
-; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s --check-prefix=CHECK
-; RUN: opt -S -dxil-intrinsic-expansion -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library < %s | FileCheck %s --check-prefix=CHECK
-
-; Make sure dxil operation function calls for step are generated for half/float.
-
-declare half @llvm.dx.step.f16(half, half)
-declare <2 x half> @llvm.dx.step.v2f16(<2 x half>, <2 x half>)
-declare <3 x half> @llvm.dx.step.v3f16(<3 x half>, <3 x half>)
-declare <4 x half> @llvm.dx.step.v4f16(<4 x half>, <4 x half>)
-
-declare float @llvm.dx.step.f32(float, float)
-declare <2 x float> @llvm.dx.step.v2f32(<2 x float>, <2 x float>)
-declare <3 x float> @llvm.dx.step.v3f32(<3 x float>, <3 x float>)
-declare <4 x float> @llvm.dx.step.v4f32(<4 x float>, <4 x float>)
-
-define noundef half @test_step_half(half noundef %p0, half noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt half %p1, %p0
- ; CHECK: %1 = select i1 %0, half 0.000000e+00, half 1.000000e+00
- %hlsl.step = call half @llvm.dx.step.f16(half %p0, half %p1)
- ret half %hlsl.step
-}
-
-define noundef <2 x half> @test_step_half2(<2 x half> noundef %p0, <2 x half> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <2 x half> %p1, %p0
- ; CHECK: %1 = select <2 x i1> %0, <2 x half> zeroinitializer, <2 x half> splat (half 1.000000e+00)
- %hlsl.step = call <2 x half> @llvm.dx.step.v2f16(<2 x half> %p0, <2 x half> %p1)
- ret <2 x half> %hlsl.step
-}
-
-define noundef <3 x half> @test_step_half3(<3 x half> noundef %p0, <3 x half> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <3 x half> %p1, %p0
- ; CHECK: %1 = select <3 x i1> %0, <3 x half> zeroinitializer, <3 x half> splat (half 1.000000e+00)
- %hlsl.step = call <3 x half> @llvm.dx.step.v3f16(<3 x half> %p0, <3 x half> %p1)
- ret <3 x half> %hlsl.step
-}
-
-define noundef <4 x half> @test_step_half4(<4 x half> noundef %p0, <4 x half> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <4 x half> %p1, %p0
- ; CHECK: %1 = select <4 x i1> %0, <4 x half> zeroinitializer, <4 x half> splat (half 1.000000e+00)
- %hlsl.step = call <4 x half> @llvm.dx.step.v4f16(<4 x half> %p0, <4 x half> %p1)
- ret <4 x half> %hlsl.step
-}
-
-define noundef float @test_step_float(float noundef %p0, float noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt float %p1, %p0
- ; CHECK: %1 = select i1 %0, float 0.000000e+00, float 1.000000e+00
- %hlsl.step = call float @llvm.dx.step.f32(float %p0, float %p1)
- ret float %hlsl.step
-}
-
-define noundef <2 x float> @test_step_float2(<2 x float> noundef %p0, <2 x float> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <2 x float> %p1, %p0
- ; CHECK: %1 = select <2 x i1> %0, <2 x float> zeroinitializer, <2 x float> splat (float 1.000000e+00)
- %hlsl.step = call <2 x float> @llvm.dx.step.v2f32(<2 x float> %p0, <2 x float> %p1)
- ret <2 x float> %hlsl.step
-}
-
-define noundef <3 x float> @test_step_float3(<3 x float> noundef %p0, <3 x float> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <3 x float> %p1, %p0
- ; CHECK: %1 = select <3 x i1> %0, <3 x float> zeroinitializer, <3 x float> splat (float 1.000000e+00)
- %hlsl.step = call <3 x float> @llvm.dx.step.v3f32(<3 x float> %p0, <3 x float> %p1)
- ret <3 x float> %hlsl.step
-}
-
-define noundef <4 x float> @test_step_float4(<4 x float> noundef %p0, <4 x float> noundef %p1) {
-entry:
- ; CHECK: %0 = fcmp olt <4 x float> %p1, %p0
- ; CHECK: %1 = select <4 x i1> %0, <4 x float> zeroinitializer, <4 x float> splat (float 1.000000e+00)
- %hlsl.step = call <4 x float> @llvm.dx.step.v4f32(<4 x float> %p0, <4 x float> %p1)
- ret <4 x float> %hlsl.step
-}
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll
deleted file mode 100644
index 4028146a1a3fa..0000000000000
--- a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll
+++ /dev/null
@@ -1,33 +0,0 @@
-; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
-; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
-
-; Make sure SPIRV operation function calls for step are lowered correctly.
-
-; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450"
-; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32
-; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16
-; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4
-; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4
-
-define noundef <4 x half> @step_half4(<4 x half> noundef %a, <4 x half> noundef %b) {
-entry:
- ; CHECK: %[[#]] = OpFunction %[[#vec4_float_16]] None %[[#]]
- ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]]
- ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_16]]
- ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_16]] %[[#op_ext_glsl]] Step %[[#arg0]] %[[#arg1]]
- %hlsl.step = call <4 x half> @llvm.spv.step.v4f16(<4 x half> %a, <4 x half> %b)
- ret <4 x half> %hlsl.step
-}
-
-define noundef <4 x float> @step_float4(<4 x float> noundef %a, <4 x float> noundef %b) {
-entry:
- ; CHECK: %[[#]] = OpFunction %[[#vec4_float_32]] None %[[#]]
- ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]]
- ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]]
- ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_32]] %[[#op_ext_glsl]] Step %[[#arg0]] %[[#arg1]]
- %hlsl.step = call <4 x float> @llvm.spv.step.v4f32(<4 x float> %a, <4 x float> %b)
- ret <4 x float> %hlsl.step
-}
-
-declare <4 x half> @llvm.spv.step.v4f16(<4 x half>, <4 x half>)
-declare <4 x float> @llvm.spv.step.v4f32(<4 x float>, <4 x float>)
More information about the cfe-commits
mailing list