<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/82176>82176</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Regression: Very bad codegen for 64-bit remainder on x86_64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/81E7hY79n
```cpp
unsigned long long rem(unsigned long long x, unsigned long long y) {
return x % y;
}
```
## Expected output (clang 10)
```asm
rem(unsigned long long, unsigned long long):
mov rax, rdi
xor edx, edx
div rsi
mov rax, rdx
ret
```
## Actual output (clang 11+, GCC)
```asm
rem(unsigned long long, unsigned long long):
mov rax, rdi
mov rcx, rdi
or rcx, rsi
shr rcx, 32
je .LBB0_1
xor edx, edx
div rsi
mov rax, rdx
ret
.LBB0_1:
xor edx, edx
div esi
mov eax, edx
ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVE9v2z4M_TT0hWgg0_8PPiRt87v8TjsM2KmQLcZR4UiBJLfJPv0gJ0vXNMUw7LAgEAE-k3x8BJ70Xg-GuYViBcVDIqewta591J7Nq3zhpLPq2G5D2HvIlkBroPVgVWfHsLBuAFp_B1rX6WO1_VY1BsQDiOX5LcXp3-_3p8xk5mEKR2uG0-N4B1TfAA5A93gjfwRqEKrVqSMiouMwOYMHBCrwCNkZgurhisc7cpQBZfh42HMfWKGdwn4KCFT3ozQDpgKoubmN9LtT5jPqt4nHdtm5F-7sC87U5bymU_ptnfg7WDdHVjMewztc6XO91591vKpwHH6vxrIPkxw_apECrWLX_-7v_6UqF7y_jZ9Fu-AXcfzW_Qpk9L7umU9x8f9qJZ7Svz3FNdvri1xO8XPeRYA_HMkfrs_ydsXH6yeqzVSTNTLhNq1ETVVRZkWybUnKqt6UGyrzhjddn5aUssqpqbpGKNokuiVBuaC0TishsmJRxs-ooqIuizzPCXLBO6nHxTi-7KJJJNr7idua0qpMRtnx6Ge7ITL8ijMIRNF9XBtr7rpp8JCLUfvg37oEHUZuv_Dg2HttDWRL_MruiJ1U2FvFAxvcWIdlftfpEK1FaqPYoTV4qMunMk8mN16bmQ7bqVv0dge0jrPO4W7v7DP3AWg9M_TR5uIGPwIAAP__yHdxyA">