1717#include " mlir/Dialect/Arith/Utils/Utils.h"
1818#include " mlir/Dialect/Func/IR/FuncOps.h"
1919#include " mlir/Dialect/SCF/IR/SCF.h"
20+ #include " mlir/Dialect/Utils/StaticValueUtils.h"
2021#include " mlir/IR/BuiltinOps.h"
2122#include " mlir/IR/IRMapping.h"
2223#include " mlir/IR/OpDefinition.h"
@@ -807,7 +808,7 @@ void mlir::denormalizeInductionVariable(RewriterBase &rewriter, Location loc,
807808
808809static OpFoldResult getProductOfIndexes (RewriterBase &rewriter, Location loc,
809810 ArrayRef<OpFoldResult> values) {
810- assert (!values.empty () && " unexecpted empty array" );
811+ assert (!values.empty () && " unexpected empty array" );
811812 AffineExpr s0, s1;
812813 bindSymbols (rewriter.getContext (), s0, s1);
813814 AffineExpr mul = s0 * s1;
@@ -819,9 +820,8 @@ static OpFoldResult getProductOfIndexes(RewriterBase &rewriter, Location loc,
819820 return products;
820821}
821822
822- // / Helper function to multiply a sequence of values.
823- static Value getProductOfIntsOrIndexes (RewriterBase &rewriter, Location loc,
824- ArrayRef<Value> values) {
823+ Value mlir::getProductOfIntsOrIndexes (RewriterBase &rewriter, Location loc,
824+ ArrayRef<Value> values) {
825825 assert (!values.empty () && " unexpected empty list" );
826826 if (getType (values.front ()).isIndex ()) {
827827 SmallVector<OpFoldResult> ofrs = getAsOpFoldResult (values);
@@ -835,7 +835,7 @@ static Value getProductOfIntsOrIndexes(RewriterBase &rewriter, Location loc,
835835 continue ;
836836 if (productOf)
837837 productOf =
838- rewriter.create <arith::MulIOp>(loc, productOf.value (), v). getResult ( );
838+ rewriter.createOrFold <arith::MulIOp>(loc, productOf.value (), v);
839839 else
840840 productOf = v;
841841 }
@@ -848,17 +848,9 @@ static Value getProductOfIntsOrIndexes(RewriterBase &rewriter, Location loc,
848848 return productOf.value ();
849849}
850850
851- // / For each original loop, the value of the
852- // / induction variable can be obtained by dividing the induction variable of
853- // / the linearized loop by the total number of iterations of the loops nested
854- // / in it modulo the number of iterations in this loop (remove the values
855- // / related to the outer loops):
856- // / iv_i = floordiv(iv_linear, product-of-loop-ranges-until-i) mod range_i.
857- // / Compute these iteratively from the innermost loop by creating a "running
858- // / quotient" of division by the range.
859- static std::pair<SmallVector<Value>, SmallPtrSet<Operation *, 2 >>
860- delinearizeInductionVariable (RewriterBase &rewriter, Location loc,
861- Value linearizedIv, ArrayRef<Value> ubs) {
851+ std::pair<SmallVector<Value>, SmallPtrSet<Operation *, 2 >>
852+ mlir::delinearizeInductionVariable (RewriterBase &rewriter, Location loc,
853+ Value linearizedIv, ArrayRef<Value> ubs) {
862854
863855 if (linearizedIv.getType ().isIndex ()) {
864856 Operation *delinearizedOp =
0 commit comments