<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/133182>133182</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-cl does not support MSVC x86(64) div intrinsics
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidben
</td>
</tr>
</table>
<pre>
MSVC has intrinsics corresponding to the x86 DIV instruction:
https://learn.microsoft.com/en-us/cpp/intrinsics/udiv64?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/udiv128?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/div64?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/div128?view=msvc-170
These operations (well, the unsigned ones) are useful in implementing big integer arithmetic. Sadly, clang-cl does not seem to support them. (I'm having to special-case clang-cl from MSVC in some code right now.)
Even with a clang-cl special case, these are not easily accessible from LLVM without inline asm, from what I can tell, because the x86 instructions trap when the quotient doesn't fit in a single word. A priori, trying to divide, say, uint128_t by uint64_t may give a 128-bit result.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VEGPpDgP_TXhYhWCAFXUgUN_019JLc2cZtXXUUhc4FVI2Dihpv79KgzanpVWe9o5QWT5-fn52YqZJoc4iO5_onstVIqzD4NRG5kRXTF68xy-fH3_BLNiIBcDOSbNoH0IyKt3htwE0UOcEb73Z3h9ewdyHEPSkbwTzYuoXuYYV86_8ibkzaIKrlxIB8_-HkvtFyFv6E6JhbzpdRXy9lFKyFsytJ1b0dw2wodoXhfe9Km-VP8Nci37XwH9yzj_C2VRvfw2IyP4FYPK-jMI2T_QWiE_7TNKbp-4Ae-QhbyCCgiJ8Z4skANaVosLupjHOtKUZ44TBlCB4rxgJF3CV2XsMwNqq9x00haMRwbnIzDiku3AaV19iLnkUmYOb0JeFpjVdviFV9Sk7Ekrxg-ce_AL7H4jB-wXBO0NQqBpjuD8oxTy-qPP_2_o4EFxBvWRfoBCBj0aZtw7zNxQMdknKK2RmUaLP8p9_vz-ZUfyKQI5Sw5B8ZLz9_hjVhHeQCsH8RByRK0S41-m_8nwDDGoFR4zuj38R_KR0MVdIifkJcKdch1QwOQmi_DwwZTwAmsgH2jnHZ6HTIY2MnsvrHbJE7lYy_5bhPG5P87ttwiLesJEG4KCWvankSIE5GRjWZihMdfmqgoc6kvbVI2s-r6Yh9F0pu4bpS_ttbn3XWeas-parGvV1V0tCxpkJbuqkWfZNG17KS9mvBvTtKo1bXPXRrQVLopsae22lD5MBTEnHOqmqXtZWDWi5f2ySOnwAXtUSJkPTRhy0mlME4u2ssSRP2AiRYvDP5jrMNVukO_9Wcj-3GYPG9p-Ok5FCnb4-5JNFOc0HruV6xyf0xr876hj3rHMLu_XQX8b5J8BAAD__4aVtaA">