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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][sparse] Sparsification pass crash
        </td>
    </tr>

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

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

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

<pre>
    I'm seeing the sparsification pass crash on this example. HEAD is at 8e2bd05c4e8 and ```mlir-opt -sparsification``` will reproduce this behavior. If I return a constant say %c1 from the absent region, the pass goes through. The original intent is to return the value at %arg0[i] from the absent region.

```
#map = affine_map<(d0) -> (d0)>
#SV = #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed) }>
 
func.func @assign(%arg0: tensor<?xi64, #SV>, %arg1: i64, %arg2: index, %arg3: tensor<?xi64, #SV>) -> tensor<?xi64, #SV> {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : i64
    %dim = tensor.dim %arg0, %c0 : tensor<?xi64, #SV>
    %0 = tensor.empty(%dim) : tensor<?xi64, #SV>
    %1 = linalg.generic {
      indexing_maps = [#map, #map, #map], 
      iterator_types = ["parallel"]} 
 ins(%arg3, %arg0 : tensor<?xi64, #SV>, tensor<?xi64, #SV>) 
      outs(%0 : tensor<?xi64, #SV>) {
    ^bb0(%in: i64, %in_0: i64, %out: i64):
 %2 = sparse_tensor.unary %in : i64 to i64
       present = {
 ^bb0(%arg4: i64):        
        sparse_tensor.yield %arg1 : i64
 }
       absent = {
        sparse_tensor.yield %in_0 : i64
 }
      linalg.yield %2 : i64
    } -> tensor<?xi64, #SV>
    return %1 : tensor<?xi64, #SV>
  }
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVUFvqzoT_TVmMyoiNoSwYNFcGn1d309vWxkzAT-BjWzT1_z7J2Ogoept-6QoYDNzZub4z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