On 11/12/2020 07:12, Marc Glisse wrote: > On Thu, 10 Dec 2020, Lucas de Almeida via Gcc wrote: > >> when performing (int64_t) foo / (int32_t) bar in gcc under x86, a call to >> __divdi3 is always output, even though it seems the use of the idiv >> instruction could be faster. > > IIRC, idiv requires that the quotient fit in 32 bits, while your C code > doesn't. (1LL << 60) / 3 would cause an error with idiv.
Isn't that an integer overflow, which is undefined behaviour? -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671