Bug 15249 – Floating-point division should multiply by inverse if lossless.

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2015-10-26T14:25:25Z
Last change time
2024-12-13T18:45:33Z
Keywords
performance
Assigned to
No Owner
Creator
Marco Leise
Moved to GitHub: dmd#17731 →

Comments

Comment #0 by Marco.Leise — 2015-10-26T14:25:25Z
For ages we have been writing "x * 0.5f" because it would be faster than division by 2. I've just checked back with what GDC and LDC2 and they generate the same code for "* 0.5" and "/ 2", recognizing that the inverse is lossless, while DMD still uses division for the latter. This applies to all divisions by powers of two up to a practical limit like the range limit of a ulong 1/2⁶⁴ or the smallest normalized single-precision value 1/2¹²⁶ in case 128-bit cent/ucent are fully implemented.
Comment #1 by robert.schadek — 2024-12-13T18:45:33Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17731 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB