What is the ancestor check for in the carried variable analysis?

I’m looking at the issue in [MLIR]`test-match-reduction` pass triggers Assertion Failure `Index < this->size() && "Invalid index!"' · Issue #61735 · llvm/llvm-project · GitHub here.

I found in some cases (i.e. arith cast operation happens), dependsOnCarriedVals could not properly analyze the carried variable dependencies because the operations such as cast between the block argument and combinator op are not tracked by this dependency analysis.

The cause seems to ascribe to the option to filter out the ops belonging to the ancestor op. Apparently, the reduced val and cast operations are in the ancestor op. They are all excluded from the analysis.

  sliceOptions.filter = [&](Operation *op) {
    return !ancestorOp->isAncestor(op);

I think we can fix the issue by treating the reduced val and its operants as special. But I’m wondering why this filter is necessary. Is it safe to treat some operations in the ancestor op as exceptions?