OCamlPro / flambda-task-force

13 stars 1 forks source link

Approximation of float arrays #106

Closed chambart closed 8 years ago

chambart commented 8 years ago

Constant float arrays can now propagate their contents. This is sufficient for constant propagation but does not allow alias based optimisation:

type complex = { re: float; im: float }
let one = { re = 1.0; im = 0.0 }
let add x y = { re = x.re +. y.re; im = x.im +. y.im }
let two = add one one

let norm2 x = x.re *. x.re +. x.im *. x.im
let foo x =
  let c = add x x in
  norm2 c

two can be statically computed, but the intermediate allocation of c in foo cannot be eliminated. To allow that float array approximation need to contain a Simple_value_approx.t instead of a float.

mshinwell commented 8 years ago

Pierre is going to push this to trunk now, for 4.04

mshinwell commented 8 years ago

Pushed