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

optimizer always uses jump tables rather than lookup tables #7439

Closed
vicuna opened this issue Dec 22, 2016 · 1 comment
Closed

optimizer always uses jump tables rather than lookup tables #7439

vicuna opened this issue Dec 22, 2016 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Dec 22, 2016

Original bug ID: 7439
Reporter: markghayden
Assigned to: @gasche
Status: resolved (set by @gasche on 2016-12-22T18:48:43Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: AMD64 (others)
OS: MacOS
OS Version: 10.12.2
Version: 4.04.0
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: back end (clambda to assembly)

Bug description

When pattern matching constant values, the optimizer uses jump tables even if all the resulting values are themselves constants. Now that Ocaml is so much better about identifying constants, wouldn't it be better to use lookup tables when the results are all constants. The examples below all use jump-tables where each target simply loads a constant value and returns.

type t = A | B | C | D ;;

let f = function
| A -> 0
| B -> 1
| C -> 2
| D -> 3
;;

let g = function
| A -> "A"
| B -> "B"
| C -> "C"
| D -> "D"
;;

let h v =
match v with
| A -> f
| B -> (fun _ -> 1)
| C -> (fun _ -> 2)
| D -> (fun _ -> 3)
;;

Steps to reproduce

Compile above code with 4.04.0+flambda with "-O3 -unbox-closures"

File attachments

@vicuna
Copy link
Author

vicuna commented Dec 22, 2016

Comment author: @gasche

This was already fixed in the development version by Stephen Dolan:
#863

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