Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007439OCamlback end (clambda to assembly)public2016-12-22 19:402017-03-06 16:23
Reportermarkghayden 
Assigned Togasche 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformAMD64 (others)OSMacOSOS Version10.12.2
Product Version4.04.0 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007439: optimizer always uses jump tables rather than lookup tables
DescriptionWhen 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 ReproduceCompile above code with 4.04.0+flambda with "-O3 -unbox-closures"
TagsNo tags attached.
Attached Files? file icon jt.ml [^] (271 bytes) 2016-12-22 19:40 [Show Content]

- Relationships

-  Notes
(0017042)
gasche (developer)
2016-12-22 19:48

This was already fixed in the development version by Stephen Dolan:
  https://github.com/ocaml/ocaml/pull/863 [^]

- Issue History
Date Modified Username Field Change
2016-12-22 19:40 markghayden New Issue
2016-12-22 19:40 markghayden File Added: jt.ml
2016-12-22 19:48 gasche Note Added: 0017042
2016-12-22 19:48 gasche Status new => resolved
2016-12-22 19:48 gasche Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-12-22 19:48 gasche Resolution open => fixed
2016-12-22 19:48 gasche Assigned To => gasche
2017-02-23 16:42 doligez Category Ocaml optimization => -Ocaml optimization
2017-03-06 16:23 doligez Category -Ocaml optimization => back end (clambda to assembly)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker