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

Missed constant propagation #5595

Closed
vicuna opened this issue Apr 17, 2012 · 1 comment
Closed

Missed constant propagation #5595

vicuna opened this issue Apr 17, 2012 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Apr 17, 2012

Original bug ID: 5595
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2013-08-31T10:49:04Z)
Resolution: fixed
Priority: normal
Severity: minor
Category: back end (clambda to assembly)
Monitored by: @jmeber

Bug description

The following patch:

===================================================================
--- asmcomp/cmmgen.ml (revision 12366)
+++ asmcomp/cmmgen.ml (working copy)
@@ -78,7 +78,10 @@
(Nativeint.add (Nativeint.shift_left (Nativeint.of_int n) 1) 1n)

let add_const c n =

  • if n = 0 then c else Cop(Caddi, [c; Cconst_int n])
  • if n = 0 then c
  • else match c with
  • | Cconst_int x when no_overflow_add x n -> Cconst_int (x + n)
  • | c -> Cop(Caddi, [c; Cconst_int n])

let incr_int = function
Cconst_int n when n < max_int -> Cconst_int(n+1)

improves code generation, for instance for the following example:

===================================================================
let () =
let tr = Bigarray.(Array2.of_array int fortran_layout [| [|1|] |]) in
for i = 1 to 1000000000 do ignore tr.{1, 1} done

On my machine, runtime goes from 1.77s to 1.46s.

@vicuna
Copy link
Author

vicuna commented Apr 18, 2012

Comment author: @alainfrisch

Commit 12368.

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