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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Assertion failure while lowering to LLVM
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:ir
      </td>
    </tr>

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

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

<pre>
    An assertion failure is hit while lowering to LLVM. The source-level reproducer is provided. An FIR level reproducer is not yet available.

Assertion (originally seen with cam4)
```
LLVMDialect.cpp:596: static void mlir::LLVM::GEPOp::build(mlir::OpBuilder &, mlir::OperationState &, mlir::Type, mlir::Type, mlir::Value, mlir::ValueRange, ArrayRef<int32_t>, ArrayRef<mlir::NamedAttribute>): Assertion `remainingIndices.size() == static_cast<size_t>(llvm::count( updatedStructIndices, kDynamicIndex)) && "expected as many index operands as dynamic index attr elements"' failed.
```
Reproducer
```
module prints
  integer, parameter :: z = 2
  integer :: b = 0
  integer :: e = -1

CONTAINS
  subroutine  outs
    implicit none
    real(8), dimension(z,b:e,1) :: pr
    real(8)   :: prmax
    prmax = maxval(pr(1:2,1,1))
  end subroutine
end module
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVF1v4yoQ_TXOy6iWg2M3efBDNtleVdrbrtpqX1cYJgl3MViA06a_fgecJlE3qyshY858HYYDrZWHZmmAe48uKGtgw5UeHILysFMBXndKI2j7ik6ZLQQL3779-DeHlx2Ct4MTeKNxjxoc9s7KQaCLofS_VxJlDpT87v4JrjkZG-CAAfieavJWY54V66xYjt_liVLG5taprTJc6wN4RAOvKuxA8G6WscUxqC6OIy0jy7XiGkXIRd9n5bJa1PQFH3hQAvZWSei0coTRiO7j3z9fvz_24287KC2p-Nntsf8SMaKfsTpjK7g0oeOR7jMVwD_tL4ce_w_5wfVwDXriZpvwpXP88ISbrFwpE0r2M2Tl10-Gc-wD71AuQ3CqHQImz0VswUVn68Jhx5Whs703Ugn0uVfvVGtOvpCVaxrHlv0U3FO5VbQf68613ndjLWEHEwiBoZe0f_kc3CDCMWdk-Gt9MLxTgiB8i0Ri_tikmiaGbz2dFEoSInTcHEBFN7CxqUb6CMsx_mjhtC1AjR2aQPlZxm6TdElyV_XwdFLeVXNHNtJ5TyKndAkCqhRwSwHEvueOmhniwaftwntsDrBPrh_WNlmLv1gxWW-ml2pfPT68LO8fnj9C_NA6OwRlEIDmEydK1vVaCbqaxho8ww65pv7PU2tXIBV1xtMZE_ZOQEuFo4Sm47kmHr27Gk6rk0PH384-aZm407xP_pSCzafky8bcKf_pTgKgkRdbGdGIjf3-dBQT2ZRyUS74JKigscmqL3eapJ9V6wvNfjxQ11-myeB0swuh93EP7I7Glt6Koc2F7WiRFDtON6SI_0h1tFTeD1Gmd1U9nU0nu-ZWFkRk02JV8mm5KVklblkx4yg4VgIXE3qvUPtIkcS3SSzLJV08UmK1nqiGFYwVNZtO2ex2xvK6XNSV5MhKttgIcpoV8d7pPBLJrdtOXJM4tcPWk1ErH_zZSM-z2hpMLYn5-RB21jW_FN0OsaMbQuq0NE_SRpq0i9_xo8uU">