[clang] [CIR] Implement builtin extractf (PR #170427)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 5 16:06:36 PST 2025


================
@@ -425,6 +425,32 @@ def CIR_ConstantOp : CIR_Op<"const", [
         return boolAttr.getValue();
       llvm_unreachable("Expected a BoolAttr in ConstantOp");
     }
+    static bool isAllOnesValue(mlir::Value value) {
+      auto constOp = mlir::dyn_cast_or_null<cir::ConstantOp>(value.getDefiningOp());
+      if (!constOp)
+        return false;
+
+      // Check for -1 integers
+      if (auto intAttr = constOp.getValueAttr<cir::IntAttr>())
+        return intAttr.getValue().isAllOnes();
+
+      // Check for FP which are bitcasted from -1 integers
+      if (auto fpAttr = constOp.getValueAttr<cir::FPAttr>())
+        return fpAttr.getValue().bitcastToAPInt().isAllOnes();
+
----------------
andykaylor wrote:

Can you remove the extra blank line here?

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


More information about the cfe-commits mailing list