Ticket #5598 (closed task: fixed)
Function quotRem is inefficient
| Reported by: | boris | Owned by: | igloo |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.1 |
| Component: | Compiler | Version: | 7.0.3 |
| Keywords: | division, performance, primop | Cc: | kazu@…, pumpkingod@…, dterei |
| Operating System: | Unknown/Multiple | Architecture: | x86 |
| Type of failure: | Runtime performance bug | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Function quotRem gets compiled into two div instructions although div computes both quotient and remainder. This inefficiency exists both with NCG and LLVM backends. Thus, quotRem is at least twice as slow as it could be.
As far as I understand, quotRem is decomposed into two primops quotInt# and remInt# (or quotWord# and remWord#) and each of them is compiled independently into code which has div instruction. I propose to add new primops quotRemInt# and quotRemWord# to address this flaw.
Please see the sample code and corresponding assembly.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

