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

    <tr>
        <th>Summary</th>
        <td>
            [Loop][PointerAlias] Missed optimization due to wide.trip.count widening bitwidth
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:optimizations,
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    Alive2 proof: https://alive2.llvm.org/ce/z/Nbokci
Godbolt missed example: https://godbolt.org/z/7c7KdEjeb

In this IR, the original `i32` indvar are transformed into `i64` type, therefore creating `and 0xffffffff` mask for indvar at the use of `getelementptr`. And further, it prevents PointerAlias analysis (or MemorySSA?) to identify unneccessary loads.

Real-world motivation: This snippet of IR is derived from FFmpeg/.../extr_asfdec_o.c_asf_read_payload.c
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxkU02PpDYQ_TXmUhoE5qObAwd2OkSjZKNoNofcRgYXTe0aG9lFz7C_PjI9mowSDnyont-jXr1SIdDVIrai-iKqS6I2np1v_36c92Rwem87QzeUsHrnJlF0MDOvQRSdkL2QvTqqqTG3JXX-KmQ_opD9TyH7Pwb3YySRXUTW_er04AzDQiGgBnxTy2rw_3TXO-6dKrKcxtNv-pfvONyJ7vcnCzxTgKdnIR-BZwTn6UpWGRB1RoUUdQZk9U15UB6BvbJhcn5BDWTZHai6jCjeV3wn8Tg5jzB6VEz2GkHKasjepvcr4hcVfsDk_Ac9H_pbQHBTPHJFRoMLWl7ZizpLobMaps1HhahEDKvHG1oO8Kcjy-g7QyqAssrsgQIIeXYevuLi_P7tWyeKXsgG2AFptEzTDpu1OI4YgvI7GKd0SD_784zKPLw6bzQsjummmJyNbv8VXQuW1hU5_u_TM1AAjZ5uqGHyboG-X1aM7qdpKmSPb-xfVJg0ji8uHePri0elX1a1R-F0THRb6KZoVIJtXjdNU5ZFcUrmdszrOm_0dC7rsajPZV6f5agwO2mZZ7JpEmplJos8z8usLqvilCLqsmlUVdbTuVb6LMoMF0XmI18JhbBhe5Iyl4lRA5pwBFfKiBBF51amhX4eDQchpZCPQsp77B4-F2OtuiS-jQcfhu0aRJkZChz-FWNicyzG786torqI6svngYnqAl_vgf7MDHrDOKxX0piypzUd3Wb5-LYxVwPxK2mek82b9j_5J563IR3dImR_tHR_PKzefceRhewPB0LcjGjCPwEAAP__BU48CQ">