optimizer misses flonum opportunities in `(apply + ...)` and `foldl`
Open
@stamourv is already working on this.
Since Apr 1, 2015.
enhancement
optimizer
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
The optimizer will use unsafe-fl+ for direct uses of + with flonums. Very nice. Even better, it even works variadically (which unsafe-fl+ ordinarily does not).
But when you change to (apply + ...) or foldl, you lose the optimization:
#lang typed/racket
(require math)
(+ 1.0 2.0) ; optimized
(+ 1.0 2.0 3.0) ; optimized
(apply + '(1.0 2.0 3.0)) ; not optimized
(foldl + 0.0 '(1.0 2.0 3.0)) ; not optimized
(foldl fl+ 0.0 '(1.0 2.0 3.0)) ; not optimized
The lower three lines could be better expanded to either
(unsafe-fl+ (unsafe-fl+ 1.0 2.0) 3.0)
or
(foldl unsafe-fl+ 0.0 '(1.0 2.0 3.0))
Though I think the apply form is the worthiest one to optimize, because it’s the more common idiom, and would subsume the foldl versions.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.