Open vaivaswatha opened 1 year ago
This MLIR code fails to compile,
func.func @multiply(%A: i64) -> i64 { %B = arith.addi %A, %A : i64 %Zero = arith.constant 0 : i64 %C = arith.cmpi eq, %B, %Zero : i64 %C1 = arith.constant 1 : i1 cf.cond_br %C, ^bb1, ^bb2 ^bb1: %One = arith.constant 1 : i64 cf.br ^bb3 ^bb3: %Res = scf.if %C1 -> i64 { %Two = arith.constant 2 : i64 %res = arith.addi %Two, %Two : i64 scf.yield %res : i64 } else { %One = arith.constant 3 : i64 %res = arith.addi %One, %One : i64 scf.yield %res : i64 } return %Res: i64 ^bb2: return %B: i64 }
with error:
$ mlir-opt test.mlir test.mlir:18:13: error: redefinition of SSA value '%One' %One = arith.constant 3 : i64 ^ test.mlir:9:9: note: previously defined here %One = arith.constant 1 : i64 ^
However if I move ^bb1 to be lexicographically after ^bb3, the redefinition is no longer detected, and hence no error thrown.
^bb1
^bb3
For clarity, this code compiles without errors:
func.func @multiply(%A: i64) -> i64 { %B = arith.addi %A, %A : i64 %Zero = arith.constant 0 : i64 %C = arith.cmpi eq, %B, %Zero : i64 %C1 = arith.constant 1 : i1 cf.cond_br %C, ^bb1, ^bb2 ^bb3: %Res = scf.if %C1 -> i64 { %Two = arith.constant 2 : i64 %res = arith.addi %Two, %Two : i64 scf.yield %res : i64 } else { %One = arith.constant 3 : i64 %res = arith.addi %One, %One : i64 scf.yield %res : i64 } return %Res: i64 ^bb1: %One = arith.constant 1 : i64 cf.br ^bb3 ^bb2: return %B: i64 }
@llvm/issue-subscribers-mlir-core
Author: Vaivaswatha N (vaivaswatha)
@llvm/issue-subscribers-bug
This MLIR code fails to compile,
with error:
However if I move
^bb1
to be lexicographically after^bb3
, the redefinition is no longer detected, and hence no error thrown.For clarity, this code compiles without errors: