[llvm] Add SPV_INTEL_bfloat16_arithmetic for Opencl.std instructions with bfloat16 type (PR #205128)
Viktoria Maximova via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 08:06:05 PDT 2026
================
@@ -0,0 +1,60 @@
+; RUN: split-file %s %t
+
+; RUN: not --crash llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_bfloat16 %t/bf16_result.ll -o /dev/null 2>&1 | FileCheck %s --check-prefix=RESULT-ERROR
+; RESULT-ERROR: error: <unknown>:0:0: in function test_fabs bfloat (bfloat): OpenCL Extended instructions with bfloat16 require the
+; RESULT-ERROR-SAME: following SPIR-V extension: SPV_INTEL_bfloat16_arithmetic
+
+; RUN: not --crash llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_bfloat16 %t/bf16_operand.ll -o /dev/null 2>&1 | FileCheck %s --check-prefix=OPERAND-ERROR
+; OPERAND-ERROR: error: <unknown>:0:0: in function test_ilogb i32 (bfloat): OpenCL Extended instructions with bfloat16 require the
+; OPERAND-ERROR-SAME: following SPIR-V extension: SPV_INTEL_bfloat16_arithmetic
+
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_bfloat16_arithmetic,+SPV_KHR_bfloat16 %t/bf16_result.ll -o - | FileCheck %s --check-prefixes=COMMON,BF16_RESULT
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_bfloat16_arithmetic,+SPV_KHR_bfloat16 %t/bf16_operand.ll -o - | FileCheck %s --check-prefixes=COMMON,BF16_OPERAND
+
+; TODO: re-enable spirv-val once it can verify SPV_INTEL_bfloat16_arithmetic with bfloat16 type on ExtInst
+; RUNx: %if spirv-tools %{ llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_bfloat16_arithmetic,+SPV_KHR_bfloat16 %t/bf16_result.ll -o - -filetype=obj | spirv-val %}
+; RUNx: %if spirv-tools %{ llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_bfloat16_arithmetic,+SPV_KHR_bfloat16 %t/bf16_operand.ll -o - -filetype=obj | spirv-val %}
+
+; COMMON-DAG: OpCapability BFloat16ArithmeticINTEL
+; COMMON-DAG: OpCapability BFloat16TypeKHR
+; COMMON-DAG: OpExtension "SPV_KHR_bfloat16"
+; COMMON-DAG: OpExtension "SPV_INTEL_bfloat16_arithmetic"
+; COMMON-DAG: [[EXTSET:%.*]] = OpExtInstImport "OpenCL.std"
+; COMMON-DAG: [[BFLOAT:%.*]] = OpTypeFloat 16 0
+
+; BF16_RESULT-DAG: [[BFLOATV:%.*]] = OpTypeVector [[BFLOAT]] 4
+; BF16_RESULT: OpExtInst [[BFLOAT]] [[EXTSET]] fabs
+; BF16_RESULT: OpExtInst [[BFLOATV]] [[EXTSET]] fabs
+
+; BF16_OPERAND-DAG: [[INT:%.*]] = OpTypeInt 32 0
+; BF16_OPERAND-DAG: [[INTV:%.*]] = OpTypeVector [[INT]] 4
+; BF16_OPERAND: OpExtInst [[INT]] [[EXTSET]] ilogb
+; BF16_OPERAND: OpExtInst [[INTV]] [[EXTSET]] ilogb
----------------
vmaksimo wrote:
Not sure if it makes sense to check for int type here, guess you intended to verify that operand type is bfloat?
https://github.com/llvm/llvm-project/pull/205128
More information about the llvm-commits
mailing list