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

    <tr>
        <th>Summary</th>
        <td>
            AggressiveInstCombine generating malformed IR
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:crash,
            llvm:optimizations
      </td>
    </tr>

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

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

<pre>
    Blame: https://reviews.llvm.org/D137201
https://github.com/llvm/llvm-project/blame/1fb99dedd711c343f01a959f1a843cc92a3002b0/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp#L794-L798

Test cases: https://godbolt.org/z/7rPs491bh

```
Instruction does not dominate all uses!
  %gep2 = getelementptr inbounds i8, ptr %p, i64 64
 %final_ptr = getelementptr inbounds i8, ptr %gep2, i64 4
Instruction does not dominate all uses!
  %gep2 = getelementptr inbounds i8, ptr %p, i64 68
  %ld2 = load i64, ptr %gep2, align 4
LLVM ERROR: Broken module found, compilation aborted!
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8k0tv3C4UxT8N3qCM4OLnwotJ5m8p0vzbapR2W2Fz7aHFYAFO1Xz6CmfyqJpK7aaS5ccFzrkH_JMh6MkitqS4JsUhk2s8O99-DLO076RCnLPeqe_ttZEzErGn5xiXQMSeQEeg83iv8VvYGXM_75yfCHQHLipgnLADYfufZ086ntd-N7iZQJeWXB5Xi3dfcIgEun7zgY6PfdMoVKrifBC5GBmXTdGMXNa5GIYGpGAMevZKSPcEujsvbRidnwOBbj9NHkPQ93hrQ7xxc68t_q6-G5aFgDhWTX51rJr6McDj_Q5DpIMMGH7dgsmp3pl4Sf9AoKv8h5A3vD-_liAlu1zbZzL26xC1s1Q5DNS6SJWbtZURqTSGrskNLvtIKYFiwgUoEQc6YUSDM9q4RE-17d1qVaC6JnBDU4lAsaR3Xea0zC8SBIpRW2k-bzP-UCZ5Pinl_7z1-pWEUY8KxkmVRt9oUho92ac2j8dP_9P_Tqf3p3Rm1959RUtnp1aDdEyuacXg5kUbuWWRvfMR1XPjzyeWqVaoRjQyw5aXdQ61qEWTnVvgSilRFYIVI-ZshEblUtQKyopzIfJMt8BAsIJXjImKNzsOBUBZVtCwIa97IDnDWWrzDFCmQ1ixLaEqyszIHk3Y0ATYfnOxH7wMZwIp70vRLVHP-mHLEdJgcch8u6HVr1MgOTM6xBdMs6ijwfZNDuiEFr2M2k50liaxhIrenrLVm_aved7iJBa3RD8CAAD__6srX4E">