Use for statement directly as an operand instead of having it pretend to be an induction variable.
PiperOrigin-RevId: 206759180
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index 2e09850..1102559 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -552,8 +552,8 @@
case SSAValueKind::FnArgument:
id = nextFnArgumentID++;
break;
- case SSAValueKind::InductionVar:
- id = nextInductionVarID++;
+ case SSAValueKind::ForStmt:
+ id = nextLoopID++;
break;
}
valueIDs[value] = id;
@@ -599,7 +599,7 @@
/// This is the value ID for each SSA value in the current function.
DenseMap<const SSAValue *, unsigned> valueIDs;
unsigned nextValueID = 0;
- unsigned nextInductionVarID = 0;
+ unsigned nextLoopID = 0;
unsigned nextFnArgumentID = 0;
};
} // end anonymous namespace
@@ -900,9 +900,7 @@
if (stmt->getNumResults() != 0)
printer->numberValueID(stmt->getResult(0));
}
- void visitForStmt(ForStmt *stmt) {
- printer->numberValueID(stmt->getInductionVar());
- }
+ void visitForStmt(ForStmt *stmt) { printer->numberValueID(stmt); }
MLFunctionPrinter *printer;
};
@@ -948,7 +946,7 @@
void MLFunctionPrinter::print(const ForStmt *stmt) {
os.indent(numSpaces) << "for ";
- printOperand(stmt->getInductionVar());
+ printOperand(stmt);
os << " = " << *stmt->getLowerBound();
os << " to " << *stmt->getUpperBound();
if (stmt->getStep()->getValue() != 1)
diff --git a/lib/IR/Statement.cpp b/lib/IR/Statement.cpp
index 6ace8ff..3ac481f 100644
--- a/lib/IR/Statement.cpp
+++ b/lib/IR/Statement.cpp
@@ -198,7 +198,7 @@
ForStmt::ForStmt(AffineConstantExpr *lowerBound, AffineConstantExpr *upperBound,
AffineConstantExpr *step, MLIRContext *context)
: Statement(Kind::For), StmtBlock(StmtBlockKind::For),
- MLValue(MLValueKind::InductionVar, Type::getAffineInt(context)),
+ MLValue(MLValueKind::ForStmt, Type::getAffineInt(context)),
lowerBound(lowerBound), upperBound(upperBound), step(step) {}
//===----------------------------------------------------------------------===//