Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[github patch] cmm arithmetic optimizations #6354

Closed
vicuna opened this issue Mar 26, 2014 · 1 comment
Closed

[github patch] cmm arithmetic optimizations #6354

vicuna opened this issue Mar 26, 2014 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Mar 26, 2014

Original bug ID: 6354
Reporter: @gasche
Assigned to: @mshinwell
Status: resolved (set by @mshinwell on 2016-12-07T13:00:21Z)
Resolution: fixed
Priority: normal
Severity: feature
Category: back end (clambda to assembly)
Monitored by: @jmeber @yallop

Bug description

Patch and description at:
#17

Some optimisations on Cmm expressions involving tagging or constants. Here's a (best-case) example:

let int_of_digits a b c =
100 * (Char.code a - Char.code '0') +
10 * (Char.code b - Char.code '0') +
1 * (Char.code c - Char.code '0')

Trunk compiles this to:

(+
(+ (+ (* 200 (>>s (+ a/1020 -96) 1)) (* 20 (>>s (+ b/1021 -96) 1)))
(* 2 (>>s (+ c/1022 -96) 1)))
1)

This branch compiles this to:

(+ (+ (+ ( * a/1020 100) ( * b/1021 10)) c/1022) -10766)

Floating all of the constant operations, tags, etc. out of arithmetic means they can be merged into one addition.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @mshinwell

This has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants