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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Inconsistent output when executing MLIR program with and without `-test-math-to-vcix`
        </td>
    </tr>

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

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

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

<pre>
    My git version is [9d7ca6c](https://github.com/llvm/llvm-project/commit/9d7ca6cdf038dab24fbc5c22a91be36604decb67).

## Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the `-test-math-to-vcix`.

## Steps to Reproduce:

### 1. **MLIR Program (test.mlir)**:

test.mlir:

```
module {
  func.func private @printMemrefI32(tensor<*xi32>)
  func.func @main() {
    %0 = "tosa.const"() <{values = dense<-16> : tensor<4x1xi32>}> : () -> tensor<4x1xi32>
    %1 = tosa.equal %0, %0 : (tensor<4x1xi32>, tensor<4x1xi32>) -> tensor<4x1xi1>
    %2 = tosa.cast %1 : (tensor<4x1xi1>) -> tensor<4x1xi32>
    %cast = tensor.cast %2 : tensor<4x1xi32> to tensor<*xi32>
    call @printMemrefI32(%cast) : (tensor<*xi32>) -> ()
 return
  }
}
```

### 2. **Command to Run Without `-test-math-to-vcix`:**

```
/path/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata -lower-host-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```

### 3. **Output Without `-test-math-to-vcix`:**

```
[[1], 
 [1], 
 [1], 
 [1]]
```

### 4. **Command to Run With `-test-math-to-vcix`:**

```
/path/llvm-project/build/bin/mlir-opt test.mlir -test-math-to-vcix | \
/path/llvm-project/build/bin/mlir-opt -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata -lower-host-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```

### 5. **Output With `-test-math-to-vcix`:**

```
[[-1], 
 [-1], 
 [-1], 
 [-1]]
```

I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused this result.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsV02P2zYT_jX0ZUBDoqyvgw9eOwsskOB9kR56DChqZLGgSJUf3t38-oKS7N1NvNs0aXtpAEEWpeEzj-bjsYY7J48acUvyG5IfVjz43tjtez40xrLNqjHt4_bDIxylhxNaJ40G6YDkN3VbCl4Ikh8Iq3rvR0eyHWG3hN0epe9DsxZmIOxWqdP5h47W_IbCE3YrzDDIeLHAtF2SVS1v2KZrRC4Y43XaYFYUyaZF0RQlYfWaJLt4sIywDA7ohJWjl0ZHx8nuDvgA-DCilaiF1EfgGqQWRjvpPGoPFl1QHu571IAPKIKPVr5HcHxA-PD-7iOM1hwtH-Be-h64bqcLE_xkRoqEenSeDtz31Bt6EvKBFMlLZr94HB14Ax9xtKYNAmeCF4tolK6BsB1hu8nr_xevhFURfz0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