[Mlir-commits] [mlir] [mlir][tosa] Fix check for isolated regions in `tosa.cond_if` (PR #143772)

Luke Hutton llvmlistbot at llvm.org
Fri Jul 18 07:37:32 PDT 2025


================
@@ -1193,32 +1193,55 @@ bool checkErrorIfPad(Operation *op) {
   return true;
 }
 
-// Returns true if the operation takes no input operands, excluding attributes.
-static bool isNullaryOperation(Operation *op) {
-  if (isa<tosa::ConstOp>(op) || isa<tosa::ConstShapeOp>(op) ||
-      isa<tosa::YieldOp>(op) || isa<tosa::VariableOp>(op))
-    return true;
-  return false;
+static bool isOpIsolatedFromAbove(Operation *op, Region *region) {
+  return llvm::all_of(op->getOperands(), [&](auto operand) {
+    Region *operandRegion = operand.getParentRegion();
+    return region->isAncestor(operandRegion);
----------------
lhutton1 wrote:

> Does "ancestor" relationship always equate to "IsolatedFromAbove" ?

Yes as far as I'm aware. Infact, this is the same style of check used in the `IsolatedFromAbove` trait verifier: https://github.com/llvm/llvm-project/blob/89c5c3ba38492de8163c344d076733b32d522727/mlir/lib/IR/Operation.cpp#L1369

https://github.com/llvm/llvm-project/pull/143772


More information about the Mlir-commits mailing list