[llvm] [SPIR-V] Reject fp128 and ppc_fp128 types with a diagnostic (PR #208397)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 01:48:55 PDT 2026
https://github.com/aobolensk created https://github.com/llvm/llvm-project/pull/208397
Introduced as a part of discussion in https://github.com/llvm/llvm-project/pull/208219
>From 51f21c45bf6922574040773bc56ea6b1c47d967e Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Thu, 9 Jul 2026 10:47:58 +0200
Subject: [PATCH] [SPIR-V] Reject fp128 and ppc_fp128 types with a diagnostic
---
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp | 6 ++++++
llvm/test/CodeGen/SPIRV/constant/fp128-unsupported.ll | 10 ++++++++++
2 files changed, 16 insertions(+)
create mode 100644 llvm/test/CodeGen/SPIRV/constant/fp128-unsupported.ll
diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index eea63194fa8b7..4ea4067d69bb4 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -1204,6 +1204,12 @@ SPIRVTypeInst SPIRVGlobalRegistry::createSPIRVType(
: getOpTypeInt(Width, MIRBuilder, false);
}
if (Ty->isFloatingPointTy()) {
+ if (Ty->isFP128Ty() || Ty->isPPC_FP128Ty()) {
+ Function &F = MIRBuilder.getMF().getFunction();
+ F.getContext().diagnose(DiagnosticInfoUnsupported(
+ F, "fp128 is not supported in SPIR-V", DebugLoc(), DS_Error));
+ return getOpTypeFloat(64, MIRBuilder);
+ }
if (Ty->isBFloatTy()) {
return getOpTypeFloat(Ty->getPrimitiveSizeInBits(), MIRBuilder,
SPIRV::FPEncoding::BFloat16KHR);
diff --git a/llvm/test/CodeGen/SPIRV/constant/fp128-unsupported.ll b/llvm/test/CodeGen/SPIRV/constant/fp128-unsupported.ll
new file mode 100644
index 0000000000000..d10c99c12cfe7
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/constant/fp128-unsupported.ll
@@ -0,0 +1,10 @@
+; Test that fp128 and ppc_fp128, which are not valid standard SPIR-V types,
+; produce an error instead of being silently miscompiled.
+
+; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: error:{{.*}}fp128 is not supported in SPIR-V
+
+define fp128 @getConstantFP128() {
+ ret fp128 0xL00000000000000004001000000000000
+}
More information about the llvm-commits
mailing list