[Mlir-commits] [mlir] [mlir][Arith] Let integer range narrowing handle negative values (PR #119642)
Ivan Butygin
llvmlistbot at llvm.org
Thu Dec 12 14:33:17 PST 2024
================
@@ -319,36 +318,46 @@ struct NarrowElementwise final : OpTraitRewritePattern<OpTrait::Elementwise> {
using OpTraitRewritePattern::OpTraitRewritePattern;
LogicalResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const override {
- std::optional<ConstantIntRanges> range =
- getOperandsRange(solver, op->getResults());
- if (!range)
- return failure();
+ SmallVector<ConstantIntRanges> ranges;
+ if (failed(collectRanges(solver, op->getOperands(), ranges)))
+ return rewriter.notifyMatchFailure(op, "input without specified range");
+ if (failed(collectRanges(solver, op->getResults(), ranges)))
+ return rewriter.notifyMatchFailure(op, "output without specified range");
+
+ if (op->getNumResults() == 0)
----------------
Hardcode84 wrote:
Maybe move arg/result count/types check before `collectRanges` as `collectRanges` is probably more expensive?
https://github.com/llvm/llvm-project/pull/119642
More information about the Mlir-commits
mailing list