https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/207213

Replace the chain of fltSemantics singleton address comparisons with a
switch over the APFloatBase::Semantics enum.

Co-authored-by: Claude (Opus 4.8) <[email protected]>

>From da16f6480d09d6dc9dd07a10a2a934d35fe79f5b Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 2 Jul 2026 10:20:37 +0200
Subject: [PATCH] clang: Use a switch over APFloat semantics instead of if
 chain

Replace the chain of fltSemantics singleton address comparisons with a
switch over the APFloatBase::Semantics enum.

Co-authored-by: Claude (Opus 4.8) <[email protected]>
---
 clang/lib/CodeGen/CodeGenTypes.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index c68a24ca045bc..ddf82ab5b33f8 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -301,21 +301,24 @@ void CodeGenTypes::RefreshTypeCacheForClass(const 
CXXRecordDecl *RD) {
 
 static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
                                     const llvm::fltSemantics &format) {
-  if (&format == &llvm::APFloat::IEEEhalf())
+  switch (llvm::APFloat::SemanticsToEnum(format)) {
+  case llvm::APFloat::S_IEEEhalf:
     return llvm::Type::getHalfTy(VMContext);
-  if (&format == &llvm::APFloat::BFloat())
+  case llvm::APFloat::S_BFloat:
     return llvm::Type::getBFloatTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEsingle())
+  case llvm::APFloat::S_IEEEsingle:
     return llvm::Type::getFloatTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEdouble())
+  case llvm::APFloat::S_IEEEdouble:
     return llvm::Type::getDoubleTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEquad())
+  case llvm::APFloat::S_IEEEquad:
     return llvm::Type::getFP128Ty(VMContext);
-  if (&format == &llvm::APFloat::PPCDoubleDouble())
+  case llvm::APFloat::S_PPCDoubleDouble:
     return llvm::Type::getPPC_FP128Ty(VMContext);
-  if (&format == &llvm::APFloat::x87DoubleExtended())
+  case llvm::APFloat::S_x87DoubleExtended:
     return llvm::Type::getX86_FP80Ty(VMContext);
-  llvm_unreachable("Unknown float format!");
+  default:
+    llvm_unreachable("Unknown float format!");
+  }
 }
 
 llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) {

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to