Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007439OCaml-Ocaml optimizationpublic2016-12-22 19:402016-12-22 19:48
Reportermarkghayden 
Assigned Togasche 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformAMD64 (others)OSMacOSOS Version10.12.2
Product Version4.04.0 
Target VersionFixed in Version4.05.0+dev 
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
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker