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

    <tr>
        <th>Summary</th>
        <td>
            [ABI] Use too many sub instruction to adjust large alloc stack pointer
        </td>
    </tr>

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

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

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

<pre>
    test case, see detail https://gcc.godbolt.org/z/eoPsPfeWK
```
int foo (int index){
    int aLength = 0x7fffff1f;
    int a[aLength];

    for(float i = 100000; i > 0; i--){
        a[(int)i] = (int)(i);
    }

    return a[index];
}
```

we can see that, the gcc use  **add     sp, sp, x1** to adjust the sp, while llvm use too much sub instruction, so may be there need a  threshold to generate code similar to gcc.
```
foo(int):                                // @foo(int)
        str     x29, [sp, #-16]!                // 8-byte Folded Spill
        sub     sp, sp, #4095, lsl #12          // =16773120
        sub     sp, sp, #4095, lsl #12          // =16773120
        sub     sp, sp, #4095, lsl #12          // =16773120
        sub     sp, sp, #4095, lsl #12          // =16773120
        sub     sp, sp, #4095, lsl #12          // =16773120
        ....
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVEtv3CAQ_jX4gnaF8fp18GGTbaSqPUSqqp6xGdukrFkBTnb76zvgdJM4zbG3jmwzeOCbbx7QGnlpPDhPO-GA8FvqAKgEL5Smo_cnR7I94Xf4DF23HYxsjfZbYwf88wtfMPfuvocfXwg7ELYnBXt-4lRNnvbGUMKroKpJwpnwmpQ3i52iBIP4CtPgR0qyA2Xnsg-S9iRbLyP5zfNSkh-u5pdFvbHoqtdGoLOIlrIguDTOP9FF3WzWLIIE-IUpWhV6iAjXP0EJw2tWpDysOVjws50i2BLva6bX5W_ztHyfAKswxQr4UfhQDT8CxcTT2QE641iKvZAysnWnWK74PaeLjXpDhXyYsZ5h52J8GpUGqvXjMcJ4rMdx7kbq5haz6rydO6_MFNHQJC60DQTAAp0AJBUUZxbcaLQMDgaYwAqPZI1EH-qotLDRgB3y1_CwBV6ymF3z_ZEs_UbJjr3Z-KZWSDuO51CXW4rJXoIlPNukRcg5Tz_ArTbtBdnfYTgY3beT0nqFjYlZZxhxd6zOg6qdDtOUv2ecHdKiLNHE_iP-C8QtyqrDEtlkss5qkXjlNTTYCfubz-Hwfv_T7GK6rJv91UHB5h2ACq1Nh10lup_0ZLDjwCaz1c3qDlR-nNttZ444CSfqedicrHmADtv0Tjk3g0MlL3hdJWPTp7XMS7HjrOCiTTnPK9nztsrabFdXokq0aEG7Jl4-fIInGiFQxyAS1XDGcWvGGM-LXbXlZcFYVZY1sI5leY2nBI54W28Dj3AxJ7aJlNp5cGjUynn3YhTOqQGPdXSH-GL2o7HNYy_7PomOm0j8N23nnok">