[clang] e2e1703 - [Matrix] Implement matrix support for the `step` intrinsic (#236850)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 13:01:49 PST 2026
Author: Kaitlin Peng
Date: 2026-11-02T13:01:42-08:00
New Revision: e2e1703c2143de0d5dd4eaf26b8ac1a4daad8800
URL: https://github.com/llvm/llvm-project/commit/e2e1703c2143de0d5dd4eaf26b8ac1a4daad8800
DIFF: https://github.com/llvm/llvm-project/commit/e2e1703c2143de0d5dd4eaf26b8ac1a4daad8800.diff
LOG: [Matrix] Implement matrix support for the `step` intrinsic (#236850)
Closes #184490.
This PR implements the matrix api for `step` and adds matrix codegen
tests and SPIRV matrix backend tests. DirectX matrix backend tests were
not added because no DirectX backend changes were made.
Assisted-by: Claude Opus 5.5
Added:
clang/test/CodeGenHLSL/builtins/step_mat-overloads.hlsl
clang/test/CodeGenHLSL/builtins/step_mat.hlsl
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step_mat.ll
Modified:
clang/include/clang/Basic/HLSLIntrinsics.td
clang/lib/Headers/hlsl/hlsl_compat_overloads.h
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index fd59e3477b8c79..c8eb074f484e9b 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -1630,7 +1630,6 @@ Step is based on the following formula: (x >= y) ? 1 : 0
let ParamNames = ["y", "x"];
let VaryingTypes = [HalfTy, FloatTy];
let VaryingLongVector = 1;
- let VaryingMatDims = [];
}
// Returns the tangent of the input value, Val.
diff --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
index 15af384ec15076..36fe1911a83eaf 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -58,6 +58,12 @@ namespace hlsl {
_DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float4 fn(double4 V1, double4 V2) { \
return fn((float4)V1, (float4)V2); \
+ } \
+ template <uint R, uint C> \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
+ constexpr matrix<float, R, C> fn(matrix<double, R, C> V1, \
+ matrix<double, R, C> V2) { \
+ return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
}
#define _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(fn) \
@@ -166,6 +172,30 @@ namespace hlsl {
_DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint64_t4 V1, uint64_t4 V2) { \
return fn((float4)V1, (float4)V2); \
+ } \
+ template <uint R, uint C> \
+ _DXC_DEPRECATED_INT_FN(fn) \
+ constexpr matrix<float, R, C> fn(matrix<int, R, C> V1, \
+ matrix<int, R, C> V2) { \
+ return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
+ } \
+ template <uint R, uint C> \
+ _DXC_DEPRECATED_INT_FN(fn) \
+ constexpr matrix<float, R, C> fn(matrix<uint, R, C> V1, \
+ matrix<uint, R, C> V2) { \
+ return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
+ } \
+ template <uint R, uint C> \
+ _DXC_DEPRECATED_INT_FN(fn) \
+ constexpr matrix<float, R, C> fn(matrix<int64_t, R, C> V1, \
+ matrix<int64_t, R, C> V2) { \
+ return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
+ } \
+ template <uint R, uint C> \
+ _DXC_DEPRECATED_INT_FN(fn) \
+ constexpr matrix<float, R, C> fn(matrix<uint64_t, R, C> V1, \
+ matrix<uint64_t, R, C> V2) { \
+ return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
}
#define _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(fn) \
@@ -234,43 +264,6 @@ namespace hlsl {
return fn((float4)V1, (float4)V2, (float4)V3); \
}
-#define _DXC_COMPAT_BINARY_DOUBLE_MATRIX_OVERLOADS(fn) \
- template <uint R, uint C> \
- _DXC_DEPRECATED_64BIT_FN(fn) \
- constexpr matrix<float, R, C> fn(matrix<double, R, C> V1, \
- matrix<double, R, C> V2) { \
- return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
- }
-
-#define _DXC_COMPAT_BINARY_INTEGER_MATRIX_OVERLOADS(fn) \
- template <uint R, uint C> \
- _DXC_DEPRECATED_INT_FN(fn) \
- constexpr matrix<float, R, C> fn(matrix<int, R, C> V1, \
- matrix<int, R, C> V2) { \
- return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
- } \
- \
- template <uint R, uint C> \
- _DXC_DEPRECATED_INT_FN(fn) \
- constexpr matrix<float, R, C> fn(matrix<uint, R, C> V1, \
- matrix<uint, R, C> V2) { \
- return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
- } \
- \
- template <uint R, uint C> \
- _DXC_DEPRECATED_INT_FN(fn) \
- constexpr matrix<float, R, C> fn(matrix<int64_t, R, C> V1, \
- matrix<int64_t, R, C> V2) { \
- return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
- } \
- \
- template <uint R, uint C> \
- _DXC_DEPRECATED_INT_FN(fn) \
- constexpr matrix<float, R, C> fn(matrix<uint64_t, R, C> V1, \
- matrix<uint64_t, R, C> V2) { \
- return fn((matrix<float, R, C>)V1, (matrix<float, R, C>)V2); \
- }
-
//===----------------------------------------------------------------------===//
// acos builtins overloads
//===----------------------------------------------------------------------===//
@@ -298,8 +291,6 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(atan)
_DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(atan2)
_DXC_COMPAT_BINARY_INTEGER_OVERLOADS(atan2)
-_DXC_COMPAT_BINARY_DOUBLE_MATRIX_OVERLOADS(atan2)
-_DXC_COMPAT_BINARY_INTEGER_MATRIX_OVERLOADS(atan2)
//===----------------------------------------------------------------------===//
// ceil builtins overloads
@@ -607,8 +598,6 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(normalize)
_DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(pow)
_DXC_COMPAT_BINARY_INTEGER_OVERLOADS(pow)
-_DXC_COMPAT_BINARY_DOUBLE_MATRIX_OVERLOADS(pow)
-_DXC_COMPAT_BINARY_INTEGER_MATRIX_OVERLOADS(pow)
//===----------------------------------------------------------------------===//
// rsqrt builtins overloads
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 599b1a1c8ae03a..2a908239d471bf 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -104,7 +104,8 @@ template <typename T> constexpr T smoothstep_impl(T Min, T Max, T X) {
}
template <typename T> constexpr T step_impl(T Y, T X) {
- return select(X < Y, (T)0, (T)1);
+ return select(X < Y, (T)(__detail::elem_type_t<T>)0,
+ (T)(__detail::elem_type_t<T>)1);
}
template <typename T> constexpr T lerp_impl(T X, T Y, T S) {
diff --git a/clang/test/CodeGenHLSL/builtins/step_mat-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/step_mat-overloads.hlsl
new file mode 100644
index 00000000000000..8841cf483192ef
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/step_mat-overloads.hlsl
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm \
+// RUN: -o - | FileCheck %s --check-prefixes=CHECK -DSPIR_FUNC=""
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN: spirv-unknown-vulkan-library %s -emit-llvm \
+// RUN: -o - | FileCheck %s --check-prefixes=CHECK -DSPIR_FUNC="spir_func "
+
+
+// CHECK: define hidden [[SPIR_FUNC]]noundef nofpclass(nan inf) <12 x float> @_{{.*}}test_step_double3x4{{.*}}(
+// CHECK: fptrunc [[FMF:reassoc nnan ninf nsz arcp afn]] <12 x double> %{{.*}} to <12 x float>
+// CHECK: fptrunc [[FMF]] <12 x double> %{{.*}} to <12 x float>
+// CHECK: [[CMP:%.*]] = fcmp [[FMF]] olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: [[SEL:%.*]] = select [[FMF]] <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+// CHECK: ret <12 x float> [[SEL]]
+float3x4 test_step_double3x4 (double3x4 p0, double3x4 p1) {
+ return step(p0, p1);
+}
+
+// CHECK: define hidden [[SPIR_FUNC]]noundef nofpclass(nan inf) <12 x float> @_{{.*}}test_step_uint3x4{{.*}}(
+// CHECK: uitofp [[FMF:reassoc nnan ninf nsz arcp afn]] <12 x i32> %{{.*}} to <12 x float>
+// CHECK: uitofp [[FMF]] <12 x i32> %{{.*}} to <12 x float>
+// CHECK: [[CMP:%.*]] = fcmp [[FMF]] olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: [[SEL:%.*]] = select [[FMF]] <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+// CHECK: ret <12 x float> [[SEL]]
+float3x4 test_step_uint3x4 (uint3x4 p0, uint3x4 p1) {
+ return step(p0, p1);
+}
+
+// CHECK: define hidden [[SPIR_FUNC]]noundef nofpclass(nan inf) <12 x float> @_{{.*}}test_step_int3x4{{.*}}(
+// CHECK: sitofp [[FMF:reassoc nnan ninf nsz arcp afn]] <12 x i32> %{{.*}} to <12 x float>
+// CHECK: sitofp [[FMF]] <12 x i32> %{{.*}} to <12 x float>
+// CHECK: [[CMP:%.*]] = fcmp [[FMF]] olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: [[SEL:%.*]] = select [[FMF]] <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+// CHECK: ret <12 x float> [[SEL]]
+float3x4 test_step_int3x4 (int3x4 p0, int3x4 p1) {
+ return step(p0, p1);
+}
+
+// CHECK: define hidden [[SPIR_FUNC]]noundef nofpclass(nan inf) <12 x float> @_{{.*}}test_step_int64_t3x4{{.*}}(
+// CHECK: sitofp [[FMF:reassoc nnan ninf nsz arcp afn]] <12 x i64> %{{.*}} to <12 x float>
+// CHECK: sitofp [[FMF]] <12 x i64> %{{.*}} to <12 x float>
+// CHECK: [[CMP:%.*]] = fcmp [[FMF]] olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: [[SEL:%.*]] = select [[FMF]] <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+// CHECK: ret <12 x float> [[SEL]]
+float3x4 test_step_int64_t3x4 (int64_t3x4 p0, int64_t3x4 p1) {
+ return step(p0, p1);
+}
+
+// CHECK: define hidden [[SPIR_FUNC]]noundef nofpclass(nan inf) <12 x float> @_{{.*}}test_step_uint64_t3x4{{.*}}(
+// CHECK: uitofp [[FMF:reassoc nnan ninf nsz arcp afn]] <12 x i64> %{{.*}} to <12 x float>
+// CHECK: uitofp [[FMF]] <12 x i64> %{{.*}} to <12 x float>
+// CHECK: [[CMP:%.*]] = fcmp [[FMF]] olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: [[SEL:%.*]] = select [[FMF]] <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+// CHECK: ret <12 x float> [[SEL]]
+float3x4 test_step_uint64_t3x4 (uint64_t3x4 p0, uint64_t3x4 p1) {
+ return step(p0, p1);
+}
diff --git a/clang/test/CodeGenHLSL/builtins/step_mat.hlsl b/clang/test/CodeGenHLSL/builtins/step_mat.hlsl
new file mode 100644
index 00000000000000..ecd271323e860e
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/step_mat.hlsl
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN: dxil-pc-shadermodel6.3-library %s \
+// RUN: -fnative-half-type -fnative-int16-type -emit-llvm -o - \
+// RUN: | FileCheck %s
+
+// CHECK-LABEL: test_step_half2x3
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <6 x half> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <6 x i1> [[CMP]], <6 x half> zeroinitializer, <6 x half> splat (half 1.000000e+00)
+half2x3 test_step_half2x3(half2x3 p0, half2x3 p1) { return step(p0, p1); }
+
+// CHECK-LABEL: test_step_half3x4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <12 x half> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <12 x i1> [[CMP]], <12 x half> zeroinitializer, <12 x half> splat (half 1.000000e+00)
+half3x4 test_step_half3x4(half3x4 p0, half3x4 p1) { return step(p0, p1); }
+
+// CHECK-LABEL: test_step_half4x4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <16 x half> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <16 x i1> [[CMP]], <16 x half> zeroinitializer, <16 x half> splat (half 1.000000e+00)
+half4x4 test_step_half4x4(half4x4 p0, half4x4 p1) { return step(p0, p1); }
+
+// CHECK-LABEL: test_step_float2x3
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <6 x float> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <6 x i1> [[CMP]], <6 x float> zeroinitializer, <6 x float> splat (float 1.000000e+00)
+float2x3 test_step_float2x3(float2x3 p0, float2x3 p1) { return step(p0, p1); }
+
+// CHECK-LABEL: test_step_float3x4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <12 x float> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <12 x i1> [[CMP]], <12 x float> zeroinitializer, <12 x float> splat (float 1.000000e+00)
+float3x4 test_step_float3x4(float3x4 p0, float3x4 p1) { return step(p0, p1); }
+
+// CHECK-LABEL: test_step_float4x4
+// CHECK: [[CMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt <16 x float> %{{.*}}, %{{.*}}
+// CHECK: select reassoc nnan ninf nsz arcp afn <16 x i1> [[CMP]], <16 x float> zeroinitializer, <16 x float> splat (float 1.000000e+00)
+float4x4 test_step_float4x4(float4x4 p0, float4x4 p1) { return step(p0, p1); }
diff --git a/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
index 48e339a57e2cc4..f8397a699679ca 100644
--- a/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
@@ -4,18 +4,20 @@ void test_too_few_arg()
{
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_inline_intrinsics_gen.inc:* 38 {{candidate function not viable: requires 2 arguments, but 0 were provided}}
// expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function template 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}}
+ // expected-note at hlsl/hlsl_compat_overloads.h:* 5 {{candidate function template not viable: requires 2 arguments, but 0 were provided}}
}
void test_too_many_arg(float2 p0)
{
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_inline_intrinsics_gen.inc:* 38 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
// expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function template 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}}
+ // expected-note at hlsl/hlsl_compat_overloads.h:* 5 {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
}
bool test_bool_to_float_type_promotion(bool p1)
diff --git a/llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp b/llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp
index e28c2b76ddbe13..50ded2aa0a0d4c 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp
@@ -331,6 +331,8 @@ static SPIRVTypeInst deduceResultTypeFromOperands(MachineInstr *I,
auto IntrinsicID = cast<GIntrinsic>(I)->getIntrinsicID();
if (IntrinsicID == Intrinsic::spv_gep)
return deduceGEPType(I, GR, MIB);
+ if (IntrinsicID == Intrinsic::spv_extractelt)
+ return deduceTypeFromSingleOperand(I, MIB, GR, 2);
break;
}
case TargetOpcode::G_LOAD: {
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step_mat.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step_mat.ll
new file mode 100644
index 00000000000000..6163527f89d234
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step_mat.ll
@@ -0,0 +1,75 @@
+; 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 --target-env vulkan1.3 %}
+
+; CHECK-NOT: OpCapability Vector16
+; CHECK-DAG: OpCapability Float16
+; CHECK-DAG: %[[#void:]] = OpTypeVoid
+; CHECK-DAG: %[[#bool:]] = OpTypeBool
+; CHECK-DAG: %[[#vec4bool:]] = OpTypeVector %[[#bool]] 4
+; CHECK-DAG: %[[#vec2bool:]] = OpTypeVector %[[#bool]] 2
+; CHECK-DAG: %[[#f32:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#vec4f32:]] = OpTypeVector %[[#f32]] 4
+; CHECK-DAG: %[[#vec2f32:]] = OpTypeVector %[[#f32]] 2
+; CHECK-DAG: %[[#f16:]] = OpTypeFloat 16
+; CHECK-DAG: %[[#vec4f16:]] = OpTypeVector %[[#f16]] 4
+
+ at shuffle_f32_4 = internal addrspace(10) global <4 x float> zeroinitializer
+ at wide_f32_6 = internal addrspace(10) global [6 x float] zeroinitializer
+ at wide_f16_9 = internal addrspace(10) global [9 x half] zeroinitializer
+ at wide_f32_16 = internal addrspace(10) global [16 x float] zeroinitializer
+
+define internal void @step_float6_from_shuffle() {
+entry:
+ ; CHECK: OpFunction %[[#void]] None
+ ; CHECK: %[[#shuffle_f32:]] = OpLoad %[[#vec4f32]]
+ ; CHECK: OpCompositeExtract %[[#f32]] %[[#shuffle_f32]] 0
+ ; CHECK: OpFOrdLessThan %[[#vec4bool]]
+ ; CHECK: OpFOrdLessThan %[[#vec2bool]]
+ ; CHECK: OpSelect %[[#vec4f32]]
+ ; CHECK: OpSelect %[[#vec2f32]]
+ %vec = load <4 x float>, ptr addrspace(10) @shuffle_f32_4
+ %va = shufflevector <4 x float> %vec, <4 x float> %vec,
+ <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>
+ %c = fcmp olt <6 x float> %va, %va
+ %r = select <6 x i1> %c, <6 x float> zeroinitializer, <6 x float> splat (float 1.000000e+00)
+ store <6 x float> %r, ptr addrspace(10) @wide_f32_6
+ ret void
+}
+
+define internal void @step_half9() {
+entry:
+ ; CHECK: OpFunction %[[#void]] None
+ ; CHECK-COUNT-2: OpFOrdLessThan %[[#vec4bool]]
+ ; CHECK: OpFOrdLessThan %[[#bool]]
+ ; CHECK-COUNT-2: OpSelect %[[#vec4f16]]
+ ; CHECK: OpSelect %[[#f16]]
+ %va = load <9 x half>, ptr addrspace(10) @wide_f16_9
+ %vb = load <9 x half>, ptr addrspace(10) @wide_f16_9
+ %c = fcmp olt <9 x half> %va, %vb
+ %r = select <9 x i1> %c, <9 x half> zeroinitializer, <9 x half> splat (half 1.000000e+00)
+ store <9 x half> %r, ptr addrspace(10) @wide_f16_9
+ ret void
+}
+
+define internal void @step_float16() {
+entry:
+ ; CHECK: OpFunction %[[#void]] None
+ ; CHECK-COUNT-4: OpFOrdLessThan %[[#vec4bool]]
+ ; CHECK-COUNT-4: OpSelect %[[#vec4f32]]
+ %va = load <16 x float>, ptr addrspace(10) @wide_f32_16
+ %vb = load <16 x float>, ptr addrspace(10) @wide_f32_16
+ %c = fcmp olt <16 x float> %va, %vb
+ %r = select <16 x i1> %c, <16 x float> zeroinitializer, <16 x float> splat (float 1.000000e+00)
+ store <16 x float> %r, ptr addrspace(10) @wide_f32_16
+ ret void
+}
+
+define void @main() #0 {
+entry:
+ call void @step_float6_from_shuffle()
+ call void @step_half9()
+ call void @step_float16()
+ ret void
+}
+
+attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
More information about the cfe-commits
mailing list