[Mlir-commits] [mlir] [MLIR][Arith] Fix BitcastOp fold crashing on unhandled constant attributes (PR #212483)

Henrich Lauko llvmlistbot at llvm.org
Mon Aug 3 00:48:48 PDT 2026


================
@@ -2270,9 +2270,14 @@ OpFoldResult arith::BitcastOp::fold(FoldAdaptor adaptor) {
     return ub::PoisonAttr::get(getContext());
 
   /// Bitcast integer or float to integer or float.
-  APInt bits = llvm::isa<FloatAttr>(operand)
-                   ? llvm::cast<FloatAttr>(operand).getValue().bitcastToAPInt()
-                   : llvm::cast<IntegerAttr>(operand).getValue();
+  APInt bits;
+  if (auto floatAttr = dyn_cast<FloatAttr>(operand))
----------------
xlauko wrote:

Can we make it at least one initialization statement (e.g. immediatly invoked lambda) not to have  uninitialized `bits` with mutliple intilization points.


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


More information about the Mlir-commits mailing list