<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152325>152325</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed Optimization: eliminate redundant pointer alignment
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zxt5
</td>
</tr>
</table>
<pre>
```
define ptr @src(ptr %arg0) {
%2 = load ptr, ptr %arg0, align 8
%3 = ptrtoint ptr %2 to i64
%4 = and i64 %3, -8
%5 = inttoptr i64 %4 to ptr
%6 = getelementptr inbounds nuw i8, ptr %5, i64 40
ret ptr %6
}
define ptr @tgt(ptr %arg0) {
%2 = load ptr, ptr %arg0, align 8
%3 = getelementptr inbounds nuw i8, ptr %2, i64 40
ret ptr %3
}
```
Alive2: https://alive2.llvm.org/ce/z/2VSGnP
Godbolt: https://godbolt.org/z/4evE4f9EW
Found this pattern in https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/openusd/optimized/instanceAdapter.ll
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0U02P6zYM_DXyRdhAoSQnPvjg_fCeihYo0J5li3HUypJh0dnd_PpCTrJfBR7e5QFBQJHD8XAkmpTcEBBrpu-ZfizMQsc41-dX0kUX7VvNSnH9icbiwQXkE82cKZHmnsF-PYA28yAYVJzt7ploeE4BZ_KR-2hs7mDwwL9gH7jxbgh8f8PLFT_RTNEFuoGBU-SuVDeUWlEm2Jxc2zLV3TuLXusuEMXMcAWpzJJVXFHlihqQ0OOIgVZo6OISbOJheeFu_0mwznFmUmIlmPFdXslEw3aP-f-7PzTQL_DnZzXDV82fJMsPyZ_utvHuhMBkw49EU2KyYdAyaM2a33h_GjdxHhi0PTJozwxa-OvP5_AHE81ztF309P_m4VK4NuYehacndaie_r441mb1nI4u8ckQ4Ry4C99JHB2XbtPHkUFrqX89v70waLOiuzjRXYehP45m_pdB2_nYMWhH40I-5QqDNk4YlmTXiNzozphjFxKZ0GNjzUQ4b7wvbC1tJStTYL3daaUqpaUqjrXYgRKyLKXUnT6IrpMlIlS6shXutsYWrgYBWuxFudVSS7URqpfqoPdlabYS-4opgaNx_t3IwqW0YL3VIEEX3nTo07qEAAFf-FplAHkn53qdtVuGxJTwLlH6oCFHHuvfXEpo-e-X8Qy5GPJtoHejC4aQz2iXYE3eq7xdOF9eV35HxTL7-geW50_d_J7m-A_2lN3LAhOD9jrBqYb_AgAA__-V5Us2">