[Mlir-commits] [mlir] [MLIR] Let matchers work on int ranges (PR #102494)

Jakub Kuderski llvmlistbot at llvm.org
Fri Aug 9 06:59:13 PDT 2024


================
@@ -100,6 +101,41 @@ struct constant_op_binder {
   }
 };
 
+/// A matcher that matches operations that implement the
+/// `InferIntRangeInterface` interface, and binds the inferred range.
+struct infer_int_range_op_binder {
+  IntegerValueRange *bind_value;
+
+  explicit infer_int_range_op_binder(IntegerValueRange *bind_value)
+      : bind_value(bind_value) {}
+
+  bool match(Operation *op) {
+    auto inferIntRangeOp = dyn_cast<InferIntRangeInterface>(op);
+    if (!inferIntRangeOp)
+      return false;
+
+    // Set the range of all integer operands to the maximal range.
+    SmallVector<IntegerValueRange> argRanges;
+    argRanges.reserve(op->getNumOperands());
+    for (Value operand : op->getOperands())
+      argRanges.emplace_back(IntegerValueRange::getMaxRange(operand));
----------------
kuhar wrote:

nit: I think we should be able to replace this with `map_to_vector`

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


More information about the Mlir-commits mailing list