<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153732>153732</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Canonicalisation of unreachable `arith.addi` hangs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Sirraide
      </td>
    </tr>
</table>

<pre>
    Consider (https://godbolt.org/z/a4r55zdEd):
```mlir
module @test {
  func.func @main() {
    cf.br ^bb4
  ^bb1(%2: i64):
    cf.br ^bb4
  ^bb3:
    %c1_i64_3 = arith.constant 1 : i64
    %9 = arith.addi %2, %c1_i64_3 : i64
    cf.br ^bb1(%9 : i64)
  ^bb4:
    return
  }
}
```
Attempting to canonicalise this with `mlir-opt --canonicalize` loops for ever; when I was running this in the debugger earlier before reducing it and dumped the add, it printed `%7 = arith.addi %7, %c1_i64_3 : i64`; so something doesn’t seem right here...
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0U8GOqzgQ_Jrm0goyDYRw4JCZTKQn7V52P-DJ4A54BXZkNzPa-fqVmbwketqRkEF0dXW57NIx2tExd1C_QH3K9CqTD93fNgRtDWe9N_92r95Fazgg0GESuUYoj0BnoPPoTe9nyX0Ygc6fQGddhbr-NG8GqE0wdYS9-nqW2QZQx8WbdWaESglHQWheQB0RL6sb8rSkyqKtAzoAtfc64nDJ-4BQv_V9tf3aPosNVxOUR7T76j72-47yAQCqh-Kn3Vc_S4TyhDpYmfLBuyjaCRb4i_UOb59w2hiL22x6_Y3quetJxU1si09q77qqh67Asgb3VWpOycSv9ZeVoI5HEV6uYt2I4nHQzjs76NlGRplsxA8rE95c3_mr4G73AH0y7BXO3l8jXnxAfucA5Qt-TOzwB37oiGF1biNPZNahTIyG-3UcOSDrMFsO2PPFB8bAZh0S2ApqZ9Csy5XN1qKNSe5YwWuwTtgkTUB18z8-Nt_5uFdJXPQY_cIypUnGc3TwRnBQ0LaCkXnBYMdJcOLAeZ5npitNW7Y6465o6pqoImqyqWtaM5hh6LmiQReNrko-NOWhb7ktyBQ6sx0pqtWhqBUVjWpyKoqKVKX71hy4Ug1Uihdt53ye35d0-TMb48pdUZdNSdmse57jFimi7dYTpXCFLuF3_TpGqNRso8QHg1iZtxj--cePv6A-4evjSLVY79BfcHWB9TDpPgVorx72peOctBtjtoa5-y2kVqa1zwe_AJ3TvNtrdw3-Hx4E6LzJj0Dn2w7eO_ovAAD__znFNx4">