[clang] [llvm] [HLSL] Implement f32tof16() intrinsic (PR #172469)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 10:28:24 PST 2026
================
@@ -0,0 +1,67 @@
+; ModuleID = 'clang/test/CodeGenHLSL/builtins/f32tof16-builtin.hlsl'
+source_filename = "clang/test/CodeGenHLSL/builtins/f32tof16-builtin.hlsl"
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64-v48:16:16-v96:32:32-v192:64:64"
+target triple = "dxilv1.3-pc-shadermodel6.3-library"
+
+; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
+define hidden noundef i32 @_Z11test_scalarf(float noundef nofpclass(nan inf) %p0) #0 {
+entry:
+ %p0.addr = alloca float, align 4
+ store float %p0, ptr %p0.addr, align 4
+ %0 = load float, ptr %p0.addr, align 4
+ %hlsl.f32tof16 = call i32 @llvm.dx.legacyf32tof16.f32(float %0)
+ ret i32 %hlsl.f32tof16
+}
+
+; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
+declare i32 @llvm.dx.legacyf32tof16.f32(float) #1
+
+; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
+define hidden noundef <2 x i32> @_Z10test_uint2Dv2_f(<2 x float> noundef nofpclass(nan inf) %p0) #0 {
+entry:
+ %p0.addr = alloca <2 x float>, align 8
+ store <2 x float> %p0, ptr %p0.addr, align 8
+ %0 = load <2 x float>, ptr %p0.addr, align 8
+ %hlsl.f32tof16 = call <2 x i32> @llvm.dx.legacyf32tof16.v2f32(<2 x float> %0)
+ ret <2 x i32> %hlsl.f32tof16
+}
+
+; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
+declare <2 x i32> @llvm.dx.legacyf32tof16.v2f32(<2 x float>) #1
+
+; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
+define hidden noundef <3 x i32> @_Z10test_uint3Dv3_f(<3 x float> noundef nofpclass(nan inf) %p0) #0 {
+entry:
+ %p0.addr = alloca <3 x float>, align 16
+ store <3 x float> %p0, ptr %p0.addr, align 16
+ %0 = load <3 x float>, ptr %p0.addr, align 16
+ %hlsl.f32tof16 = call <3 x i32> @llvm.dx.legacyf32tof16.v3f32(<3 x float> %0)
+ ret <3 x i32> %hlsl.f32tof16
+}
+
+; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
+declare <3 x i32> @llvm.dx.legacyf32tof16.v3f32(<3 x float>) #1
----------------
farzonl wrote:
you should not need any declares.
https://github.com/llvm/llvm-project/pull/172469
More information about the llvm-commits
mailing list