[llvm] [DXIL] Add lowerings for cosine and floor (PR #86173)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 16:00:13 PDT 2024


================
@@ -0,0 +1,20 @@
+; RUN: opt -S -dxil-op-lower < %s | FileCheck %s
+
+; Make sure dxil operation function calls for cos are generated for float and half.
+
+define noundef float @cos_float(float noundef %a) #0 {
+entry:
+; CHECK:call float @dx.op.unary.f32(i32 12, float %{{.*}})
+  %elt.cos = call float @llvm.cos.f32(float %a)
+  ret float %elt.cos
+}
+
+define noundef half @cos_half(half noundef %a) #0 {
+entry:
+; CHECK:call half @dx.op.unary.f16(i32 12, half %{{.*}})
+  %elt.cos = call half @llvm.cos.f16(half %a)
+  ret half %elt.cos
+}
+
+declare half @llvm.cos.f16(half)
+declare float @llvm.cos.f32(float)
----------------
farzonl wrote:

In a past pr @bogner asked me to put these at the bottom of my test cases.  If we want to get rid of these, I think we should be consistent. Either we should keep the declares or Maybe a follow on pr is needed that cleans these up across all test cases so that this doesn't look arbitrary.

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


More information about the llvm-commits mailing list