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

    <tr>
        <th>Summary</th>
        <td>
            gep with large array size triggers assertion failure in APInt constructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    With this [test case](https://github.com/user-attachments/files/17830224/r.txt) I get:
```sh
$ opt -disable-output -passes=instcombine r.txt
opt: /home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/APInt.h:128: llvm::APInt::APInt(unsigned int, uint64_t, bool, bool): Assertion `llvm::isUIntN(BitWidth, val) && "Value is not an N-bit unsigned value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```
I assume this is related to #106524.

I used this one-liner to try to provoke similar assertion failures in the LLVM test suite:
```sh
$ sed -Ei 's/\[[0-9]+ x /[4294967295 x /g' $(find test/ -name "*.ll")
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2P4zYM_TXKhXBgU86HDz4kmwkwwHSxQNvdYyHbjK0dWTIkKrvTX19IyXSKKTCHBQxLIsUn8j1KKgQ9WqJWbI4C0epn3QtEsTmtVOTJ-fa7erk4Naw6N7y03zRPwJMOIDZHpsDQq0BicxK4n5iXIORB4FngedQ8xW7du1ngOQbyhWJW_TST5SDwfNGG0ljt9rJErAWe_Zp_ssAGHmEkTkjlSZQHsS1vX5juBqzBLQzFoIPqDBUu8hIZikWFQEHIk7aBezd32hLcUHOgWxIqCDxPbiaB53tteMtX4NmY61ws3n2n_nUp8Kxtb-JAb4bD6Y_0__JoeT0Jeahwn4CzVx6EPGTXf6e4jzYzPYBOy08QteVt_Veed86Zt7FJWIcQyLN2FsS2fAPW4c9Hy58F7o-av-mBpxR3VSkMBG4FbkEgflUmEugA1jEoC5-LTjP8m8I1uZPMuIOL0oaG9Y2hL08Ph98fIMRu1gwKujiCp8V5BnbwgcJ3Yt7xp0OIWWVQNhWeaQSeCHqvwgSd6p_Zq57W76S-LR9BhRBnunWcDuDJKKYh5SJQVuV2g_Vr6D0ihuRP-52lwmhLPm1n_5KGxbureyYIetZG-YR_ZznRED0F0DYn-PT09TfIHR6iZvq4G9OZxYMGgbtUrdh8StdpcyyLJt-NI_yEbD_W2NTNdofN5mYakwQitf_-ou2QT0x8FVbNBFmiw9qYPGneZbAaWjk0slEraqudxKqs602zmtquGna7Zt8PdaVk3yspZVPLvq5VJfey3q90iyXWVYVlheVONuuukmVfXqhHiSQHFHVJs9JmnQRdOz-uspRtVW2bbbkyqiMTXt8M-gHZe383fJu7oItjEHVpdODwBsOaDbUjLfAjPSVG-ZFAea9eIOi_CdjrcSQf_q9MEibfJeidDexjz86vojftr7flvZxri_8EAAD__w8ujcc">