<p><span class="h-card"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> </p><p>All compilers I've seen can do this optimization. See for example <a href="https://godbolt.org/z/v34E58deK" target="_blank" rel="nofollow noopener noreferrer"><span class="invisible">https://</span><span class="">godbolt.org/z/v34E58deK</span><span class="invisible"></span></a>, which has the "add a fixup from the upper word of the multiplication result". The reason why it's necessary is that you don't actually want multiplicative inverse modulo 2^wordsize in the case when the input value is not divisible by the constant.</p>