[Issue 15249] New: Floating-point division should multiply by inverse if lossless.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 26 07:25:25 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15249
Issue ID: 15249
Summary: Floating-point division should multiply by inverse if
lossless.
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: Marco.Leise at gmx.de
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.
--
More information about the Digitalmars-d-bugs
mailing list