Skip to content

Commit

Permalink
Fix promote i1 to i8 order to avoid invalid IR (#6119)
Browse files Browse the repository at this point in the history
It turns out the first use is not guaranteed to be the first use in order.
Updated so that we can insert just before the first use.
  • Loading branch information
rsuderman committed Jun 8, 2021
1 parent b1b26d7 commit be8d33b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion iree/compiler/Dialect/Flow/Transforms/PromoteI1ToI8Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ class ConvertBoolConstantPattern : public OpRewritePattern<mlir::ConstantOp> {
// needed as it is possible we are reusing an existing ConstantOp
// containing the same values that occurs in a future line. Moving to the
// first use case avoids declaring out of order operations.
rewriter.setInsertionPoint(*op.getResult().getUsers().begin());
Operation *firstUser = *op.getResult().getUsers().begin();
for (auto checkOp : op.getResult().getUsers()) {
if (checkOp->isBeforeInBlock(firstUser)) {
firstUser = checkOp;
}
}
rewriter.setInsertionPoint(firstUser);

auto initTensor = rewriter.create<linalg::InitTensorOp>(
loc, ArrayRef<Value>({}), resultTy.getShape(),
Expand Down

0 comments on commit be8d33b

Please sign in to comment.