[Mlir-commits] [mlir] [mlir] Add `arith-int-range-narrowing` pass (PR #112404)
Jakub Kuderski
llvmlistbot at llvm.org
Sun Nov 3 19:25:41 PST 2024
================
@@ -190,8 +195,263 @@ struct DeleteTrivialRem : public OpRewritePattern<RemOp> {
DataFlowSolver &solver;
};
-struct IntRangeOptimizationsPass
- : public arith::impl::ArithIntRangeOptsBase<IntRangeOptimizationsPass> {
+/// Check if `type` is index or integer type with `getWidth() > targetBitwidth`.
+static bool checkIntType(Type type, unsigned targetBitwidth) {
+ Type elemType = getElementTypeOrSelf(type);
+ if (isa<IndexType>(elemType))
+ return true;
+
+ if (auto intType = dyn_cast<IntegerType>(elemType))
+ if (intType.getWidth() > targetBitwidth)
+ return true;
+
+ return false;
+}
+
+/// Check if op have same type for all operands and results and this type
+/// is suitable for truncation.
+static bool checkElementwiseOpType(Operation *op, unsigned targetBitwidth) {
----------------
kuhar wrote:
Also here
https://github.com/llvm/llvm-project/pull/112404
More information about the Mlir-commits
mailing list