//
// This is not a fundamental limitation. The control operands can be moved
// onto the new HLOs after simplification, and any side-effecting ops inside
- // the loop aren't removed, just cloned and added back to the loop.
- // Nevertheless our infrastructure sees loop simplification as removal of
- // these nodes and currently doesn't allow it.
+ // the loop aren't removed, just cloned and added back to the loop. But
+ // moving an op out of the loop also removes implicit control dependencies
+ // between the op and the ops outside the loop, so we'd have to add those back
+ // for things like infeed/outfeed. It gets complicated. So for now we just
+ // avoid it.
if (!while_op->parent()->IsRemovable(while_op) || while_op->HasSideEffect()) {
VLOG(2) << "Not attempting to remove while loop it is not removable: "
<< while_op->ToShortString();