<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151786>151786</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] tosa.powf + tosa.ceil returns incorrect result with `-test-expand-math`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sweead
</td>
</tr>
</table>
<pre>
test commit: [8934a6e](https://github.com/llvm/llvm-project/commit/8934a6e13bd8d2a0ad2609bd62832ca700dab3a7)
## Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the ` -test-expand-math`.
## Steps to Reproduce:
### Minimal MLIR program (test.mlir):
```
module {
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() -> () {
%arg0 = "tosa.const"() {values = dense<137.27> : tensor<10x1xf32>} : () -> tensor<10x1xf32>
%0 = tosa.pow %arg0, %arg0 : (tensor<10x1xf32>, tensor<10x1xf32>) -> tensor<10x1xf32>
%5 = tosa.ceil %0 : (tensor<10x1xf32>) -> tensor<10x1xf32>
%rtn1 = tensor.cast %5 : tensor<10x1xf32> to tensor<*xf32>
call @printMemrefF32(%rtn1) : (tensor<*xf32>) -> ()
return
}
}
```
### 1. Without -test-expand-math:
#### Command:
```
/home/workdir/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))" | \
/home/workdir/llvm-project/build/bin/mlir-opt -tosa-to-arith -sparsifier | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
```
#### Output:
```
[[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf]]
```
### 2. With -test-expand-math:
```
/home/workdir/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-lina
lg))" | \
/home/workdir/llvm-project/build/bin/mlir-opt -tosa-to-arith -test-expand-math -sparsifier | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
```
#### Output:
```
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]]
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVt-L4zYQ_msmL8JGGcWx8-CHbHKBgx6F60MfD9keJ2plyUjy7t5_X2Q7P3Y3W7YcVygUjK3E4-_7NPpGGum9OhqiErIHyPYLOYSTdaV_IpLNorLN9zKQD6y2XacCiC2D7KHYiJVcE2R7wOIUQu9BbAEPgIejCqehSmvbAR60fjw_kt7ZP6gOgIcZCg8zzFJUTdGg5LLBNd9UzRoLgbXMOW9kJWQOuAG-jRcKQMH25Gun-qCsibzjq89Mdoyee3KKTK3MkUnDlKmt8coHMoE58oMO7OlEhtEz1UOIUeFEzMuO2JdfPn9lvbNHJzv2pMKJSdOMAzuEMQzWnCUxGQk999I0SSfDCdY8ncVd9P0WqPcsWPaVemeboaaLzCkiBn1RRnVSv-QFLCJB2mnl4qwvn635fPFtZ5tBE4P8AfiWtYOp03hjvVOPMhCDFe-dMuELdY7ag8AR1HjrQOwAt8-tQBCfpqSyGwBY8U4qA1gAblgC4hObxzMXYwwwk-7IGYg9A8RgvUxjjgMgXoMfpR7Ij0ENGU8gdkuRp5iPmGLLLnqW_Hl5FpTvx3e3_HfjLkomGaOG3j6dtQHubmRu2e30b2Fwdx_-Y9zZlbsmpc9y_obuQ7AumOWEPIaltfThTHc_bdFn95Z3gqyl1ncdMXONC_ZK9QuP3PpgxnQUBmfGH5Dvozun-41HrzZfpuz3uYbe1s6bqohf7GzXSdPML1-AHk62I8DDk3V_NrFCXm8t1aB0E5_RxodYRYntA7vUFEt66X3Sq560MgRiD4jxo6BMOhUWYHEpiZgV62USbKKVkfqYGNlRA7h7-XfMTbyQQb5jkO1-SG1yBpcubkOJ76Xzql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