@@ -501,7 +501,7 @@ void fully2ComposeIntegerSetAndOperands(IntegerSet *set,
501501
502502namespace {
503503struct AffineCFGPass : public AffineCFGBase <AffineCFGPass> {
504- void runOnFunction () override ;
504+ void runOnOperation () override ;
505505};
506506} // namespace
507507
@@ -561,9 +561,9 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
561561 setLocationAfter (b2, iadd.getOperand (1 ));
562562 rewriter.replaceOpWithNewOp <AddIOp>(
563563 op,
564- b.create <IndexCastOp>(op.getLoc (), iadd. getOperand ( 0 ), op. getType ( )),
565- b2.create <IndexCastOp>(op.getLoc (), iadd. getOperand ( 1 ),
566- op. getType ( )));
564+ b.create <IndexCastOp>(op.getLoc (), op. getType ( ), iadd. getOperand ( 0 )),
565+ b2.create <IndexCastOp>(op.getLoc (), op. getType ( ),
566+ iadd. getOperand ( 1 )));
567567 return success ();
568568 }
569569 if (auto iadd = op.getOperand ().getDefiningOp <SubIOp>()) {
@@ -573,9 +573,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
573573 setLocationAfter (b2, iadd.getOperand (1 ));
574574 rewriter.replaceOpWithNewOp <SubIOp>(
575575 op,
576- b.create <IndexCastOp>(op.getLoc (), iadd.getOperand (0 ), op.getType ()),
577- b2.create <IndexCastOp>(op.getLoc (), iadd.getOperand (1 ),
578- op.getType ()));
576+ b.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
577+ iadd.getOperand (0 )),
578+ b2.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
579+ iadd.getOperand (1 )));
579580 return success ();
580581 }
581582 if (auto iadd = op.getOperand ().getDefiningOp <MulIOp>()) {
@@ -585,9 +586,9 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
585586 setLocationAfter (b2, iadd.getOperand (1 ));
586587 rewriter.replaceOpWithNewOp <MulIOp>(
587588 op,
588- b.create <IndexCastOp>(op.getLoc (), iadd. getOperand ( 0 ), op. getType ( )),
589- b2.create <IndexCastOp>(op.getLoc (), iadd. getOperand ( 1 ),
590- op. getType ( )));
589+ b.create <IndexCastOp>(op.getLoc (), op. getType ( ), iadd. getOperand ( 0 )),
590+ b2.create <IndexCastOp>(op.getLoc (), op. getType ( ),
591+ iadd. getOperand ( 1 )));
591592 return success ();
592593 }
593594 if (auto iadd = op.getOperand ().getDefiningOp <DivUIOp>()) {
@@ -597,9 +598,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
597598 setLocationAfter (b2, iadd.getOperand (1 ));
598599 rewriter.replaceOpWithNewOp <DivUIOp>(
599600 op,
600- b.create <IndexCastOp>(op.getLoc (), iadd.getOperand (0 ), op.getType ()),
601- b2.create <IndexCastOp>(op.getLoc (), iadd.getOperand (1 ),
602- op.getType ()));
601+ b.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
602+ iadd.getOperand (0 )),
603+ b2.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
604+ iadd.getOperand (1 )));
603605 return success ();
604606 }
605607 if (auto iadd = op.getOperand ().getDefiningOp <DivSIOp>()) {
@@ -609,9 +611,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
609611 setLocationAfter (b2, iadd.getOperand (1 ));
610612 rewriter.replaceOpWithNewOp <DivSIOp>(
611613 op,
612- b.create <IndexCastOp>(op.getLoc (), iadd.getOperand (0 ), op.getType ()),
613- b2.create <IndexCastOp>(op.getLoc (), iadd.getOperand (1 ),
614- op.getType ()));
614+ b.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
615+ iadd.getOperand (0 )),
616+ b2.create <arith::IndexCastOp>(op.getLoc (), op.getType (),
617+ iadd.getOperand (1 )));
615618 return success ();
616619 }
617620 return failure ();
@@ -753,17 +756,17 @@ bool handle(OpBuilder &b, CmpIOp cmpi, SmallVectorImpl<AffineExpr> &exprs,
753756 }
754757 SmallVector<Value, 4 > lhspack = {cmpi.getLhs ()};
755758 if (!lhspack[0 ].getType ().isa <IndexType>()) {
756- auto op = b.create <IndexCastOp>(cmpi. getLoc (), lhspack[ 0 ],
757- IndexType::get (cmpi.getContext ()));
759+ auto op = b.create <arith:: IndexCastOp>(
760+ cmpi. getLoc (), IndexType::get (cmpi.getContext ()), lhspack[ 0 ] );
758761 lhspack[0 ] = op;
759762 }
760763
761764 AffineMap rhsmap =
762765 AffineMap::get (0 , 1 , getAffineSymbolExpr (0 , cmpi.getContext ()));
763766 SmallVector<Value, 4 > rhspack = {cmpi.getRhs ()};
764767 if (!rhspack[0 ].getType ().isa <IndexType>()) {
765- auto op = b.create <IndexCastOp>(cmpi. getLoc (), rhspack[ 0 ],
766- IndexType::get (cmpi.getContext ()));
768+ auto op = b.create <arith:: IndexCastOp>(
769+ cmpi. getLoc (), IndexType::get (cmpi.getContext ()), rhspack[ 0 ] );
767770 rhspack[0 ] = op;
768771 }
769772
@@ -1131,16 +1134,15 @@ struct MoveIfToAffine : public OpRewritePattern<scf::IfOp> {
11311134 }
11321135};
11331136
1134- void AffineCFGPass::runOnFunction () {
1135- mlir::RewritePatternSet rpl (getFunction ().getContext ());
1137+ void AffineCFGPass::runOnOperation () {
1138+ mlir::RewritePatternSet rpl (getOperation ().getContext ());
11361139 rpl.add <SimplfyIntegerCastMath, CanonicalizeAffineApply,
11371140 CanonicalizeIndexCast, IndexCastMovement, AffineFixup<AffineLoadOp>,
11381141 AffineFixup<AffineStoreOp>, CanonicalizIfBounds, MoveStoreToAffine,
11391142 MoveIfToAffine, MoveLoadToAffine, CanonicalieForBounds>(
1140- getFunction ().getContext ());
1143+ getOperation ().getContext ());
11411144 GreedyRewriteConfig config;
1142- (void )applyPatternsAndFoldGreedily (getFunction ().getOperation (),
1143- std::move (rpl), config);
1145+ (void )applyPatternsAndFoldGreedily (getOperation (), std::move (rpl), config);
11441146}
11451147
11461148std::unique_ptr<OperationPass<FuncOp>> mlir::polygeist::replaceAffineCFGPass () {
0 commit comments