FuncBufferizePass always fails with scf.while

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'

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?

Can you send a patch?

Yes, I will try

https://reviews.llvm.org/D100832

1 Like