[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

Trevor Gross via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 4 16:00:26 PDT 2025


================
@@ -0,0 +1,65 @@
+; Test copysign intrinsics involving half.
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+
+declare half @llvm.copysign.f16(half, half)
+declare float @llvm.copysign.f32(float, float)
+declare double @llvm.copysign.f64(double, double)
+
+; Test f16 copies.
+define half @f0(half %a, half %b) {
+; CHECK-LABEL: f0:
+; CHECK: brasl %r14, __extendhfsf2 at PLT
+; CHECK: brasl %r14, __extendhfsf2 at PLT
+; CHECK: cpsdr %f0, %f9, %f0
+; CHECK: brasl %r14, __truncsfhf2 at PLT
+; CHECK: br %r14
+  %res = call half @llvm.copysign.f16(half %a, half %b)
----------------
tgross35 wrote:

(Nonblocker) a few other architectures use an asm lowering to avoid the calls here, it's just `(a & !MASK) | (Y & MASK)` with `MASK = 1 << 15`.

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


More information about the llvm-commits mailing list