[llvm] [SPIRV] Add support for the SPIR-V extension SPV_KHR_bfloat16 (PR #155645)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 22:08:56 PDT 2025


================
@@ -0,0 +1,22 @@
+; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_KHR_bfloat16 %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_bfloat16 %s -o - -filetype=obj | spirv-val %}
+
+; CHECK-ERROR: LLVM ERROR: OpTypeFloat type with bfloat requires the following SPIR-V extension: SPV_KHR_bfloat16
+
+; CHECK-DAG: OpExtension "SPV_KHR_bfloat16"
+; CHECK-DAG: OpCapability BFloat16TypeKHR
+; CHECK: %[[#BFLOAT:]] = OpTypeFloat 16
----------------
YixingZhang007 wrote:

Thanks for pointing out the issue 🙂 I’ve updated the PR so that the Bfloat type is encoded using the SPIR-V instruction `OpTypeFloat 16 0`, which is now distinct from the IEEE-754 float encoded as  `OpTypeFloat 16`.

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


More information about the llvm-commits mailing list