[llvm] constant fold float to float bitcasts (PR #177663)

Karol Zwolak via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 23 11:57:12 PST 2026


================
@@ -145,6 +145,16 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
     }
   }
 
+  // Handle float -> float bitcast
+  if (DestTy->isFloatingPointTy() && isa<ConstantFP>(C)) {
+    bool Ignored;
+    const ConstantFP *CF = cast<ConstantFP>(C);
+    APFloat Val = CF->getValueAPF();
+    Val.convert(DestTy->getScalarType()->getFltSemantics(),
----------------
karolzwolak wrote:

Thanks, I wasn't sure what to use.

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


More information about the llvm-commits mailing list