Change the number of op results

This is the source file.

%1 = scf.if %0 -> (i32) {
      %2 = arith.addi %arg1, %c1_i32 : i32
      scf.yield %2 : i32
    }

I write a pass process and get the following file.

%25 = "scf.if"(%23) ({
      %26 = "arith.addi"(%20, %13) : (i32, i32) -> i32
      %27 = "arith.cmpi"(%arg2, %0) {predicate = 0 : i64} : (i32, i32) -> i1
      %28 = "arith.cmpi"(%arg2, %0) {predicate = 1 : i64} : (i32, i32) -> i1
      %29 = "scf.if"(%27) ({
        "scf.yield"(%arg2) : (i32) -> ()
      }, {
        %30 = "arith.constant"() {value = -1 : i32} : () -> i32
        %31 = "arith.addi"(%arg2, %30) : (i32, i32) -> i32
        "scf.yield"(%31) : (i32) -> ()
      }) : (i1) -> i32
      "scf.yield"(%29, %26, %28) : (i32, i32, i1) -> ()
    }

error: ‘scf.if’ op region control flow edge from Region #0 to parent results: source has 3 operands, but target successor needs 1
Q:Because I’m inside a while loop and have some carry variables, I need to return two or three values. But the source file only supports one result, how can I change the number of Result?

My thought is builder.create an ifop and modify the TypeRange, but is there another way?

Yes, you must recreate the op if you are changing the number of results it has.