<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60754>60754</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed expression re-association
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeremy-rifkin
</td>
</tr>
</table>
<pre>
```cpp
int foo(int num) {
if ((num * 3 + 6) / 3 != num + 2) __builtin_unreachable();
return (num * 3 + 6) / 3 - num - 2;
}
int bar(int num) {
if ((num * 3 + 6) / 3 != num + 2) __builtin_unreachable();
return (num * 3 + 6) / 3 - (num + 2);
}
```
Both `foo` and `bar` are optimizable to `return 0;` but only `bar` is optimized fully <https://godbolt.org/z/v1qoqM1jq>, <https://alive2.llvm.org/ce/z/LhFsSL>.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMU8tu2zAQ_JrVZWGDWsqidNAhjqNTcuoHBJREW0wp0uEjaPL1BWXHDdqi5wICtIvZGc5wQRmCPlmlOtjtYXcoZIqz892L8mp533h9_K5tMbjpvYOaXb7xfAZ2AHanbcSjc0BNrmxagFoEsb-giIj6iEANUGPTgkB3yBFoj_U6SP3alsAPeMH3SBl5fh6SNlHb52S9kuMsB6NWnRb4F3WvYvIW_yW_WZU3SDciiMO1uGUYpP-_M9zQi_hfsnzu5mu0vYszQs3yimqG0k65y2Fz5xW6c9SL_sjOMLoMXt2wfELNcEgRnTXvX3g6fNLUhMdkMsjv5xjPAfgdUA_Un9w0OBO3zp-A-g-g_q18da9P5csr8Aeg-z8p0ug3RVtj3pYrbVRX7uPch2-PwB-2xdTxqeWtLFRX1qKuSia4KOZOUkttU06SD6VQrD1WouajkqUYd7uKU6E7YsQZlRWVvNmJ7XFkjWjKgU9VzVopoGJqkdrcHBQ6hKS6moldVRg5KBM-n4jv8tBmSKcAFTM6xPCLFnU0qnvSIagJ1Y-zVyFoZ9GrjQzBjVpG7WyRvOl-uzQd5zRsR7cA9Vnu-tucvXtRYwTqV0sBqF9d_QwAAP__OuoPMw">