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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Incorrect array bound after remapping
        </td>
    </tr>

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

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

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

<pre>
    Consider the following reducer:
```
   program main

        double precision, target :: tar2(100)
        double precision, pointer :: ptr(:,:,:)

 i = -2
        call sub (i)

        contains
            function set_bd(i)
                integer i, set_bd
                allocatable set_bd
                allocate(set_bd, source = i)
            end function

            subroutine sub(i)
                integer i
 ptr(i:i-1, 1:set_bd(0), int(3.2):i) => tar2
                print*, lbound(ptr)
                print*, ubound(ptr)
            end subroutine
        End program
```

Flang outpus
```
> a.out
 1 1 3
 0 0 -2
```

The expected output should be
```
> a.out
 1 1 1
 0 0 0
```

All ifort, gfortran and XLF produces the correct result.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVMuO6zYM_Rp5QyTQI07shRduMgEKdNlFd4Vs07YKRTL0uO38fUEnmaSZQecSQSyJ5NHhQ9QxmskhNqz8hZWnQuc0-9CctDNoj8cZXdH54b05ehfNgAHSjDB6a_3fxk0QcMg9BqZaxlu257cfbwFgCX4K-gIXbRxp18NVBp87i7AE7E003jF5hKTDhAkISbW0k0xWgnMm6288F29cwnB3XVJgsqKNPD791zcKBpg6wUY-gfbaWoi5AyYr87C8a71L2rj4dEQyZtcn4x1ETH92w8MVXoTITRjAENeb8Wcrba3vddIU3XdGyGR1v_UI0efQ4xrVFwzQDR9U_xsXScxd8DkZh7T8mRj4PcGGqdZsBDEQTLUfWVgLJo_kwmSltpL2qiVg4sjU27W4ny9ZwupDFQPb-ewIbr3sK0rP1vl_rSkFj0CflG9uuDfpS_cy3p6tdhP4nJYcX7XqDfTW50RYAgQoWnDg17Z6Afp9RsB_FuwTDle8BHH22Q7Q4XfI4o7MPwO31oIZfUiUgokWQTvQboA_fjtTYPQ04_pgex8C9gkCxmzTthgaNdSq1gU24lCWXJS7uirmpla7EcdedGqHY9XxSsvDYS9FKetBqEoWppFclrwSUuxFJaqtOpSiPlSVHnayV_ue7ThetLFba39ctj5MhYkxYyNKJaUorO7QxnXYSDlSiplqx-BdQiqgpBEUGvLddHmKbMetiSk-0JJJdh1WV-fyBL-6e3Q6BP0Oay-AHmkkBLzoZTFuKnKwzZzSEtdhcGbyPJk0527b-wuTZ8K_fTZL8H9hn5g8r9Qjk-cb-x-N_DcAAP__4ZB2fg">