[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 11:11:21 PDT 2024


================
@@ -0,0 +1,133 @@
+; RUN: opt -S  -dxil-intrinsic-expansion  < %s | FileCheck %s --check-prefixes=CHECK,EXPCHECK
+; RUN: opt -S  -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library < %s | FileCheck %s --check-prefixes=CHECK,DOPCHECK
+
+; Make sure dxil operation function calls for length are generated for half/float.
+
+declare half @llvm.fabs.f16(half)
+declare half @llvm.dx.length.v2f16(<2 x half>)
+declare half @llvm.dx.length.v3f16(<3 x half>)
+declare half @llvm.dx.length.v4f16(<4 x half>)
+
+declare float @llvm.fabs.f32(float)
+declare float @llvm.dx.length.v2f32(<2 x float>)
+declare float @llvm.dx.length.v3f32(<3 x float>)
+declare float @llvm.dx.length.v4f32(<4 x float>)
+
+define noundef half @test_length_half(half noundef %p0) {
+entry:  
+  ; EXPCHECK: call half @llvm.fabs.f16(half %{{.*}})
+  ; DOPCHECK: call half @dx.op.unary.f16(i32 6, half %{{.*}})
+  %0 = call half @llvm.fabs.f16(half %p0)
+  ret half %0
+}
----------------
bogner wrote:

This test probably doesn't need to be here, given that we have separate tests for fabs

https://github.com/llvm/llvm-project/pull/101256


More information about the llvm-commits mailing list