[llvm] 90ca88b - [SPIR-V] Replace custom bitcast in FPMaxError decoration handling (NFC) (#203179)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 01:44:30 PDT 2026


Author: Arseniy Obolenskiy
Date: 2026-06-12T10:44:26+02:00
New Revision: 90ca88b509d5c70e98002bde45453877a404ffc8

URL: https://github.com/llvm/llvm-project/commit/90ca88b509d5c70e98002bde45453877a404ffc8
DIFF: https://github.com/llvm/llvm-project/commit/90ca88b509d5c70e98002bde45453877a404ffc8.diff

LOG: [SPIR-V] Replace custom bitcast in FPMaxError decoration handling (NFC) (#203179)

Added: 
    

Modified: 
    llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
index de454228f8602..58e90acd52024 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
@@ -893,15 +893,6 @@ static void insertInlineAsm(MachineFunction &MF, SPIRVGlobalRegistry *GR,
   insertInlineAsmProcess(MF, GR, ST, MIRBuilder, ToProcess);
 }
 
-static uint32_t convertFloatToSPIRVWord(float F) {
-  union {
-    float F;
-    uint32_t Spir;
-  } FPMaxError;
-  FPMaxError.F = F;
-  return FPMaxError.Spir;
-}
-
 static void insertSpirvDecorations(MachineFunction &MF, SPIRVGlobalRegistry *GR,
                                    MachineIRBuilder MIB) {
   const SPIRVSubtarget &ST = cast<SPIRVSubtarget>(MIB.getMF().getSubtarget());
@@ -920,8 +911,7 @@ static void insertSpirvDecorations(MachineFunction &MF, SPIRVGlobalRegistry *GR,
                                 Intrinsic::spv_assign_fpmaxerror_decoration)) {
         ConstantFP *OpV = mdconst::dyn_extract<ConstantFP>(
             MI.getOperand(2).getMetadata()->getOperand(0));
-        uint32_t OpValue =
-            convertFloatToSPIRVWord(OpV->getValueAPF().convertToFloat());
+        uint32_t OpValue = OpV->getValueAPF().bitcastToAPInt().getZExtValue();
 
         buildOpDecorate(MI.getOperand(1).getReg(), MIB,
                         SPIRV::Decoration::FPMaxErrorDecorationINTEL,


        


More information about the llvm-commits mailing list