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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR][Affine] Loop with missing lower and upper bound from affine-data-copy-generate
        </td>
    </tr>

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

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

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

<pre>
    For this test case, invalid IR is being generated unchecked (outermost loop's bounds missing)
https://github.com/llvm/llvm-project/blob/0b63dfb06698ea1a78ba09506f83a1d427a868b1/mlir/test/Dialect/Affine/affine-data-copy.mlir#L292

`bin/mlir-opt ../mlir/test/Dialect/Affine/affine-data-copy.mlir -split-input-file -affine-data-copy-generate="generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops"

```
func.func @affine_parallel(%arg0: memref<2x5x4x2xi64>) {
    %c80 = arith.constant 80 : index
    %c0 = arith.constant 0 : index
    %c0_0 = arith.constant 0 : index
    %alloc = memref.alloc() : memref<2x5x4x2xi64>
    affine.for %arg1 = max #map() to min #map() {
      affine.for %arg2 = 0 to 5 {
        affine.for %arg3 = 0 to 4 {
          affine.for %arg4 = 0 to 2 {
            %0 = affine.load %arg0[%arg1, %arg2, %arg3, %arg4] : memref<2x5x4x2xi64>
 affine.store %0, %alloc[%arg1, %arg2, %arg3, %arg4] : memref<2x5x4x2xi64>
 }
        }
      }
    }
    affine.for %arg1 = 0 to 2 {
 affine.parallel (%arg2) = (0) to (5) {
        affine.parallel (%arg3) = (0) to (4) {
          affine.for %arg4 = #map1(%arg1, %arg2, %arg3) to #map2(%arg1, %arg2, %arg3) {
            %0 = affine.load %alloc[((%arg4 floordiv 2) floordiv 4) floordiv 5, ((%arg4 floordiv 2) floordiv 4) mod 5, (%arg4 floordiv 2) mod 4, %arg4 mod 2] : memref<2x5x4x2xi64>
          }
 }
      }
    }
    memref.dealloc %alloc : memref<2x5x4x2xi64>
 return
  }
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVs2O2zgMfhrmQjiQaTu2Dz5kmjVQYPbSFyhkS060lSVDkqfp2y_8k2RmmrTTxQJGIhEfP4kfKVHce3U0UlaQPQFRY404jcdRcyCC7LDhYzhZV93sm8aKH1VtHYaT8hikD9hyL4E-oTIvXCuBn7-g8thIZY54lEY6HqTA0bQn2X6TAoEKOwbpeusDamsHoNxjY0cjPPbKe2WOQCWw_SmEwUOyB6qB6qMKp7HZtrYHqrV-ufxFg7P_yDYA1Y22DVDNml0iuobtdmUheczzouGszNiuKxIei5RyXuyKJgaqe60cUD0FAlQfFNcL077rlJFANZ8HkeCBR60dfmwXj-SZSgK2n74da5RZuSI7BNxu_zMzRn7QKkTKDGOIOqUlRu-B0UVVSA5AdJlFoueQHDquvcSO-xD1so_8wNsJyNB_U0NkrIlGo0Lkg1NCRpP-fsr2JZT1Y_tuNO12-kFI2bKFrwN3XGupgQqgjLsjg2SPveyd7CD5ROfsnJ7prHYpJH8BlQj5E7A9IiJQ1hYMITkgdyqctq01PnATcLbuURkhz6_Ad7EPoF8_DuZa23ZGL9vezoY5oBJ_Fc3CsAix7azDRYF44eJnBEp6PqxMwWKvzFvbTYw7PDTzsMkxe4O8g01u2PQd9g46vaHpJ_Ssyare4qgtF3jJ7nQtzFFOB3zd6G2Y3IYpZIffybcu4IN1cl724j5n4H9dCvLDqzBfz27j2-hBUt9KtoIuRwCvZ4CWyjlMFrbmHqjI3qccH1Mk9ynSnyke5neptPhK-VDGlXxC00fQf1Ax1zwWV-IUO22tE-oFZ52us_TNLFsW_ahfb8Url3v4CZG-qpnZQB-oHHxXNL-rnfUWEXK9WG43zC-XcTKMzswcC9f16t2IKhFlUvKNrOI8Kcu8yOJ8c6oyxnjOZZo3nUjKsuW8lQk1qeCCi64tN6oiRhmjuIwzirN8G1OTyDZrRBG3rShbSJnsudLbqW1urTtulPejrGLKC1ZsNG-k9utbYGlf8yvAVXObbcajh5Rp5YO_MQQV9Px--Pv58xfIDpA9rR0uO-CztQN-V-F06euo7XfpkBuB4zBIt7R97Jzt8WGb24xOV3_8FphD80D1Gt1LRf8GAAD__0yZlkI">