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

    <tr>
        <th>Summary</th>
        <td>
            Consider adding `arcp` to `divf` when lowering `tosa.reciprocal`
        </td>
    </tr>

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

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

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

<pre>
    When lowering `tosa.reciprocal` we generate during `tosa-to-linalg`:
```
 ^bb0(%in: f32, %out: f32):
    %cst = arith.constant 1.000000e+00 : f32
    %2 = arith.divf %cst, %in : f32
    linalg.yield %2 : f32
```
Assuming the tosa's specification is okay with using actual reciprocal instructions, at this point, we completely lost the information that this `divf` can be transformed into a reciprocal.

I don't know what's the situation in mlir with fast math flags, but if we support the same ones as in LLVM proper, we should be able to tag this `divf` with `arcp` (`Allow Reciprocal` see https://llvm.org/docs/LangRef.html#fast-math-flags); again assuming the tosa's spec allows that.

Reproducer:
```
func.func @main(%arg0: tensor<1x384xf32>) -> tensor<1x384xf32> {
  %res = "tosa.reciprocal"(%arg0) : (tensor<1x384xf32>) -> tensor<1x384xf32>
  return %res : tensor<1x384xf32>
}
```
And the command line:
```
iree-opt --iree-tosa-input-transformation-pipeline  input.mlir 
```
CC @silvasean @dcaballe @rsuderman 

What component(s) does this issue relate to?
`tosa-to-linalg`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVV1v6ygQ_TXkZWSL4Hw--CH9iLRS96UPe5_HZmyzF4MXxs3tv19Bkja9bbXSRpGDAzNnznAOYIymd0S1WN-J9cMCZx58qP9pvfVjQ7xovH6tfwzkwPoTBeN6EBvJPmIZqDVT8C1asZFwIujJUUAm0PPtwoJ9YY1D24uNFNVByAchD2l8_uZXEOvHppFC7YRaGyeqA3SVEuoehFr7md_-2L9lAIA02UYGUT0AB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