[llvm] [LLVM][CodeGen][SVE] Implement nxvf32 fpround to nxvbf16. (PR #107420)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 08:59:03 PDT 2024
================
@@ -87,3 +93,122 @@ define <vscale x 8 x double> @fpext_nxv8bf16_to_nxv8f64(<vscale x 8 x bfloat> %a
%res = fpext <vscale x 8 x bfloat> %a to <vscale x 8 x double>
ret <vscale x 8 x double> %res
}
+
+define <vscale x 2 x bfloat> @fptrunc_nxv2f32_to_nxv2bf16(<vscale x 2 x float> %a) {
+; NOBF16-LABEL: fptrunc_nxv2f32_to_nxv2bf16:
+; NOBF16: // %bb.0:
+; NOBF16-NEXT: mov z1.s, #32767 // =0x7fff
+; NOBF16-NEXT: lsr z2.s, z0.s, #16
+; NOBF16-NEXT: ptrue p0.d
+; NOBF16-NEXT: fcmuo p0.s, p0/z, z0.s, z0.s
+; NOBF16-NEXT: and z2.s, z2.s, #0x1
+; NOBF16-NEXT: add z1.s, z0.s, z1.s
+; NOBF16-NEXT: orr z0.s, z0.s, #0x400000
+; NOBF16-NEXT: add z1.s, z2.s, z1.s
+; NOBF16-NEXT: sel z0.s, p0, z0.s, z1.s
+; NOBF16-NEXT: lsr z0.s, z0.s, #16
+; NOBF16-NEXT: ret
----------------
paulwalker-arm wrote:
Oh...
They should be tested by the first RUN line but seems I've somehow deleted its `--check-prefixes=` option.
https://github.com/llvm/llvm-project/pull/107420
More information about the llvm-commits
mailing list