Ticket #5161 (closed bug: fixed)
Poor performance of division; unnecessary branching
| Reported by: | rtvd | Owned by: | igloo |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2.1 |
| Component: | libraries/base | Version: | 7.0.3 |
| Keywords: | div quot rem mod performance slow branching | Cc: | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime performance bug | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
In case an Int* is divided by a constant the compiled code contains unnecessary checks whether the value being divided is minBound. This check is necessary only if a value is being divided by -1 so that an exception would be thrown.
The branch can be removed by the GHC's optimiser after a small change: the two parts of the corresponding condition have to be flipped. This provides an opportunity to short-circuit this condition to 'false' without knowing the first argument (patch is attached).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

