2 ms·
Yes, except that's one more trap handler to implement. And it's a lot slower than inlining the division code when you need it.
by pclmulqdq 4y ago
Yes, except that's one more trap handler to implement. And it's a lot slower than inlining the division code when you need it.
- prettyStandard 4y agoYes but this is better than not implementing the trap.
- pclmulqdq 4y agoWait, having no DIV instruction will result in faster code than having a DIV that traps. The compiler picks up the code that happens in the trap and can optimize it. For example, the code for an 8-bit division can be a lot faster than a 32-bit DIV on a microcontroller.
- Someone 4y agoThere’s also the overhead of trapping (registers get saved, the CPU may switch to kernel mode). For a single integer division, chances are that adds significant overhead compared to a subroutine call (let alone inlined code)
- avianes 4y agoDIV that traps is for binary compatibility, not performance.