How to bufferize scf.while?

Assume you have the following code. Is it possible to bufferize it and then synthesize deallocation? Am I correct in saying that scf.while is not yet covered by --scf-bufferize? I have verified, and if I put scf.for instead of the scf.while, it works. Funny enough, scf.if is not handled, either.

scf.while (%x0=%c0):(tensor<256xi16>)->(tensor<256xi16>) {
    %cond = constant 1: i1
    scf.condition(%cond) %x0:tensor<256xi16>
} do {
    ... // some tensor operations that require deallocation
    scf.yield %x0:tensor<256xi16>

Correct, scf.while it is not currently handled by scf-bufferize. It should be easy to extend SCF/Transforms/StructuralTypeConversions.cpp by doing something similar to what we do for ForOp. You’ll also need a new pattern for scf.condition. This code is tested via scf-bufferize and you can add a test in SCF/bufferize.mlir. Patches welcome!

Also, scf.if should be handled by scf-bufferize. Do you have a test case that is broken for scf.if?

I have a piece of code with an scf.if embedded inside an scf.for, and the whole pipeline of bufferization breaks on the synthesis of the deallocation (I encode output arguments as input memrefs).

It would be good to file your failing test as a bug at