Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004555OCamlOCaml generalpublic2008-05-19 18:342008-08-27 12:24
Reporterpzimmer 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.10.2 
Target VersionFixed in Version3.11+dev 
Summary0004555: Compilation of equality involving polymorphic variants not optimized
DescriptionThe following code:

let f x = x = `Test

generates a call to caml_equal for the comparison. Equivalent code using pattern matching or (==) generates optimized code with an integer comparison. This looks like one trivial optimization case is missing in the compiler.

Here is a proposed patch (contributed by Mark Shinwell) that seems to be correct and fixes the problem:

--- ocaml-3.10.2/bytecomp/translcore.ml 2007-02-09 08:31:15.000000000 -0500
+++ ocaml-3.10.2-patched/bytecomp/translcore.ml 2008-05-16 18:46:48.000076000 -0400
@@ -279,6 +279,12 @@ let transl_prim prim args =
     | [{exp_desc = Texp_construct({cstr_tag = Cstr_constant _}, _)}; arg2]
       when simplify_constant_constructor ->
         intcomp
+ | [arg1; {exp_desc = Texp_variant(_, None)}]
+ when simplify_constant_constructor ->
+ intcomp
+ | [{exp_desc = Texp_variant(_, None)}; exp2]
+ when simplify_constant_constructor ->
+ intcomp
     | [arg1; arg2] when has_base_type arg1 Predef.path_int
                      || has_base_type arg1 Predef.path_char ->
         intcomp
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004511)
pzimmer (reporter)
2008-05-28 15:45

Note that I accidentally miscategorized this entry: it should be in "OCaml general" and not in "Caml-light". If one of the admins could fix it, that would be great. Thanks.
(0004588)
garrigue (manager)
2008-08-27 12:24

Fixed as suggested in CVS head (for 3.11)

- Issue History
Date Modified Username Field Change
2008-05-19 18:34 pzimmer New Issue
2008-05-28 15:45 pzimmer Note Added: 0004511
2008-05-28 16:17 doligez Status new => acknowledged
2008-05-28 16:17 doligez Category Caml-light => OCaml general
2008-08-27 12:24 garrigue Status acknowledged => closed
2008-08-27 12:24 garrigue Note Added: 0004588
2008-08-27 12:24 garrigue Resolution open => fixed
2008-08-27 12:24 garrigue Fixed in Version => 3.11+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker