[clang] [CIR] Add folders for bit manipulation operations (PR #150235)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 08:00:25 PDT 2025
================
@@ -2132,6 +2133,117 @@ LogicalResult cir::ComplexImagPtrOp::verify() {
return success();
}
+//===----------------------------------------------------------------------===//
+// Bit manipulation operations
+//===----------------------------------------------------------------------===//
+
+template <typename F>
+static OpFoldResult foldUnaryBitOp(mlir::Attribute inputAttr, F func,
+ bool poisonZero = false) {
+ auto input = mlir::dyn_cast_if_present<IntAttr>(inputAttr);
+ if (!input)
+ return nullptr;
+
+ llvm::APInt inputValue = input.getValue();
+ if (poisonZero && inputValue.isZero()) {
+ // TODO(cir): maybe we should return a poison value here?
----------------
Lancern wrote:
Added a missing feature guard here since `PoisonAttr` is not in the upstream yet. Will add in later patches.
https://github.com/llvm/llvm-project/pull/150235
More information about the cfe-commits
mailing list