Skip to content

Use bfcvt instruction on Arm to convert to __bf16 #134524

@DesWurstes

Description

@DesWurstes

Documentation for bfcvt: https://developer.arm.com/documentation/ddi0602/2025-03/SVE-Instructions/BFCVT--Single-precision-down-convert-to-BFloat16-format--predicated--

This code when compiled with -march=armv9-a+fp16 -O3 could use the instruction for better performance:

void convert2(float * __restrict a, __bf16 * __restrict x) {
    x[0] = (__bf16)a[0];
    x[1] = (__bf16)a[1];
    x[2] = (__bf16)a[2];
    x[3] = (__bf16)a[3];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:AArch64questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions