| Issue |
174526
|
| Summary |
[MLIR]`-arith-emulate-wide-int` causes inconsistent results for `exp+ceil` lowering
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
BealZephyr
|
**test commit**: [5cfd02](https://github.com/llvm/llvm-project/commit/5cfd02f44a43a2e2a085a633b022a62f64ba2b93)
## Description:
This seems like a correctness issue. With the same MLIR input (tosa.exp + tosa.ceil ), the runtime output differs depending on whether `-arith-emulate-wide-int` is present.
## test case
```
module {
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%0 = "tosa.const"() <{values = dense<-27> : tensor<8x4x2x9xi32>}> : () -> tensor<8x4x2x9xi32>
%1 = "tosa.const"() <{values = dense<5.041000e+01> : tensor<10xf32>}> : () -> tensor<10xf32>
%3 = tosa.exp %1 : (tensor<10xf32>) -> tensor<10xf32>
%5 = tosa.ceil %3 : (tensor<10xf32>) -> tensor<10xf32>
%cast_1 = tensor.cast %5 : tensor<10xf32> to tensor<*xf32>
call @printMemrefF32(%cast_1) : (tensor<*xf32>) -> ()
return
}
}
```
## Command:
### 1. without -arith-emulate-wide-int
#### cmd
```
mlir-opt test.mlir -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" -convert-linalg-to-loops -test-expand-math -convert-scf-to-cf \
-convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18]
```
### 2. With -arith-emulate-wide-int
#### cmd
```
mlir-opt test.mlir -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" -convert-linalg-to-loops -test-expand-math -convert-scf-to-cf \
-arith-emulate-wide-int -convert-to-llvm | /home/workdir/llvm-project-latest/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs