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

    <tr>
        <th>Summary</th>
        <td>
            invalid code generation using --test-math-algebraic-simplification
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    I have the following MLIR program:
test.mlir:
```
module {
  func.func @func1() {
    %0 = arith.constant false
    %1 = arith.constant true
    %2 = math.ipowi %0, %1 : i1
    vector.print %2 : i1
    return
 }
}
```
When I tried ```mlir-opt --test-math-algebraic-simplification test.mlir```, then the math.ipowi operation was optimized to :
```
module {
  func.func @func1() {
 %false = arith.constant false
    %true = arith.constant true
    %0 = arith.divsi %true, %false : i1  // division by zero
    vector.print %0 : i1
    return
  }
}
```
which seems would get a poison value for the returning value.

By the way, I found that ```--canonicalize``` can not optimize this case.
However, when I change %0 and %1 to other values of i1, or just change the bitwidth, the```--test-math-algebraic-simplification``` won't get a division by zero result, and  ```--canonicalize``` can also optimize it.
I'm not sure if the value in the ```test.mlir``` is illegal, or if I didn't find the correct way to optimize math.ipowi operation?
My git version is 4a602d9250e1eb3c729d0421d11be2be8693cbf2.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslc-PqzYQx_8a5zICgSFhc-CwPxQ1Ut-ll56NPcCsjI1sE5T96ysDSXbb1749VIogNjPjme9nBoT31BnEmu1f2P5tJ6bQW1fPwnRXa7r3XOwaq671GXpxQQg9Qmu1tjOZDn78fv4DRmc7JwZWPLPsjWXPAX1IB03uvsMO2fZbloNVk0Zg1cu6BmgnI9N4AVZm8Z4z_sT48bMNAOP7DFjxBsJR6FNpjQ_CBGiF9vjFLP-ZWXDTVyu-WA0i9CmNdqblAMZfbxGegfKHwwVlsC4dHZlw8_5q4TB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