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

    <tr>
        <th>Summary</th>
        <td>
            LLVM fails to optimize out unnecessary check for greater than or equal to zero in loop
        </td>
    </tr>

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

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

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

<pre>
    Here is a snippet that demonstrates a missed optimization with LLVM: https://alive2.llvm.org/ce/z/WOvYip

LLVM fails to optimize out the unnecessary `%j < %num_to_process` check at the beginning of the inner loop in `@src` in the above LLVM IR snippet as the LLVM optimizer fails to detect that `%remaining_len` is greater than zero as `%i` is known to be less than `%argc` in all iterations of the outer loop due to the `icmp sgt` checks at the beginning of the outer loop.

alive-tv also determined that the transformation of `@src` to `@tgt` in the above snippet appears to be correct.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U82OnDwQfBpzae2IMT_zceAwXyKUSBtFyiFRTisDDXjX2MTdzGr36SOb-ckcktNo7OqiqrqsiPRoEWtR_C-Kj4laeXK-fnaTXYxipqR1_Vv9CT2CJlBAVi8LMvCkGHqcnSX2ijHczZoIe3AL61m_K9bOwqvmCR4fv38R2REm5oVEdhSyEbJRRp9Q7ow5zTvnRyGbDoVs3oVsfnw9_dSLSI8iPYZhGJQ2BOwu5AhuDSIQVmuxQyLl30CUqZDFM4jsAwhZ2HV-Yve0eBcAokyhm7B7AbVNtjhqa7UdwQ3xQFuLHoxzC2gbyfKUfBcGtY0I1boTRjvw-ds1C0XxMh5f9Pmb5B4Zu3Nim0KPs9Lhy08GbaQnGD0qRh9gFt7Ru0C7wfUZ8mLdqw2MLYJBog27YZQfL0KVMaAZfVwAXcy5lS_m-hUDSzgVZaq7eQEa-ZoP_TWgG8du201c4QOfQBnajPpZW-w3s2GEvbI0OD9vdXDDfa7szv95E3CX8zXfZUHl6ey8c95jx0FB0tdZX2WVSrDeH4pMyjzPDslU99WhTLO2K6qybQfc59l_-6rviqrIqqEqMdG1TGWRHqSUMj_sD7u8zatyKLKqQNmmWIo8DUsy13ommmjFel-k-yxPjGrRUHw1Ulp8hXgrpAyPyNdh6KFdRxJ5ajQx3WhYs8H6H6X-s9BbXwfn7-vhPOCvVZkwG6uibdxKsnpT3z-yUfO0trvOzUI2QcT552Hx7hk7FrKJ0knI5uztVMvfAQAA__836l21">