Cf.br - Dialect `cf' not found for custom op 'cf.br'

I am writing a matrix multiplication code in MLIR and when translating it into LLVMIR the following error occurs:

<stdin>:65:5: error: Dialect `cf' not found for custom op 'cf.br'
    cf.br ^bb1(%5 : index)
    ^

This is the code:

module{
    func.func @main(){
        %A=memref.alloc():memref<3x3xf32>
        %B=memref.alloc():memref<3x3xf32>
        %C=memref.alloc():memref<3x3xf32>
        %ca=arith.constant 2.0:f32
        %cb=arith.constant 3.0:f32
        %cc=arith.constant 0.0:f32
        linalg.fill ins(%ca:f32) outs(%A:memref<3x3xf32>)
        linalg.fill ins(%cb:f32) outs(%B:memref<3x3xf32>)
        linalg.fill ins(%cc:f32) outs(%C:memref<3x3xf32>)
        %c0=arith.constant 0:index
        %c1=arith.constant 1:index
        %c3=arith.constant 3:index
        affine.for %i=%c0 to %c3{
            affine.for %j=%c0 to %c3{

               %sum=affine.for %k=%c0 to %c3 iter_args(%ia=%cc)->f32{
                   %aik=memref.load %A[%i,%k]:memref<3x3xf32>
                   %bkj=memref.load %A[%k,%j]:memref<3x3xf32>
                   %prod=arith.mulf %aik,%bkj:f32
                   %temp_sum=arith.addf %ia,%prod:f32
                   affine.yield %temp_sum:f32
               }
            memref.store %sum,%C[%i,%j]:memref<3x3xf32>
            }
        }
        %U = memref.cast %C :  memref<3x3xf32> to memref<*xf32>
        call @printMemrefF32(%U):(memref<*xf32>)->()
        memref.dealloc %A:memref<3x3xf32>
        memref.dealloc %B:memref<3x3xf32>
        memref.dealloc %C:memref<3x3xf32>
        return
    }
    func.func private @printMemrefF32(%U:memref<*xf32>)
}

These are the passes I used:

 mlir-opt --convert-linalg-to-loops --memref-expand --finalize-memref-to-llvm --convert-func-to-llvm --convert-scf-to-cf --convert-cf-to-llvm gptMatMul.mlir | mlir-translate --mlir-to-llvmir

This is the error I’m getting:

<stdin>:65:5: error: Dialect `cf' not found for custom op 'cf.br'
    cf.br ^bb1(%5 : index)
    ^
<stdin>:65:5: note: Registered dialects: acc, amx, arm_neon, arm_sme, arm_sve, builtin, dlti, func, gpu, llvm, nvvm, omp, rocdl, spirv, vcix, x86vector ; for more info on dialect registration see https://mlir.llvm.org/getting_started/Faq/#registered-loaded-dependent-whats-up-with-dialects-management

I know the error is because of cf is being used with index instead of integer but don’t know how to resolve it. Any help would be grateful.

PS: I am an absolute beginner to MLIR.

The error comes from mlir-translate and means that the first call to mlir-opt hasn’t lowered the cf dialect to the llvm dialect. The following combination of passes and pipelines works for me: mlir-opt -convert-linalg-to-loops -lower-affine -convert-scf-to-cf -convert-to-llvm.