module {
func @foo(%arg0: i64, %arg1: i64) -> i64 {
%c2_i64 = constant 2 : i64
%0:2 = scf.while (%arg2 = %arg0) : (i64) -> (i64, i64) {
%1 = cmpi slt, %arg2, %arg1 : i64
scf.condition(%1) %arg2, %arg2 : i64, i64
} do {
^bb0(%arg2: i64, %arg3: i64): // no predecessors
%1 = muli %arg3, %c2_i64 : i64
scf.yield %1 : i64
}
return %0#1 : i64
}
}
failed to legalize operation 'scf.condition'
});
populateCallOpTypeConversionPattern(patterns, typeConverter);
target.addDynamicallyLegalOp<CallOp>(
[&](CallOp op) { return typeConverter.isLegal(op); });
populateBranchOpInterfaceTypeConversionPattern(patterns, typeConverter);
populateReturnOpTypeConversionPattern(patterns, typeConverter);
target.addLegalOp<ModuleOp, memref::TensorLoadOp, memref::BufferCastOp>();
target.markUnknownOpDynamicallyLegal([&](Operation *op) {
return isNotBranchOpInterfaceOrReturnLikeOp(op) ||
isLegalForBranchOpInterfaceTypeConversionPattern(op,
typeConverter) ||
isLegalForReturnOpTypeConversionPattern(op, typeConverter);
});
if (failed(applyFullConversion(module, target, std::move(patterns))))
signalPassFailure();
}
};
} // namespace
markUnknownOpDynamicallyLegal
always returns false because scf.condition
doesn’t have ReturnLike
, neither BranchOpInterface
traits.
It feels like this pass needs to say “if the parent is not FuncOp, then the op is legal” to be in line with the composability goals of this pass (we don’t want to care about all possible nested regions and their terminators).
Can you send a patch?