diff --git a/compiler/obc/main/obc_compiler.ml b/compiler/obc/main/obc_compiler.ml index 43a6788..65bf8a3 100644 --- a/compiler/obc/main/obc_compiler.ml +++ b/compiler/obc/main/obc_compiler.ml @@ -14,8 +14,6 @@ open Compiler_options let pp p = if !verbose then Obc_printer.print stdout p let compile_program p = - (*Control optimization*) - let p = pass "Control optimization" true Control.program p pp in (* Memory allocation application *) let p = pass "Application of Memory Allocation" @@ -25,4 +23,7 @@ let compile_program p = let p = pass "Dead code removal" (!do_mem_alloc or !do_linear_typing) Deadcode.program p pp in + (*Control optimization*) + let p = pass "Control optimization" true Control.program p pp in + p diff --git a/test/image_filters/downscale.ept b/test/image_filters/downscale.ept new file mode 100644 index 0000000..519472b --- /dev/null +++ b/test/image_filters/downscale.ept @@ -0,0 +1,44 @@ + +type pixel = float^3 + +node nat() returns (n :int) +let + n = 0 fby n+1 +tel + +fun pix_sum(x1,x2 :pixel) returns (r :pixel) +let + r = map<<3>> (+.) (x1,x2); +tel + +fun pix_div(x :pixel; c :float) returns (r :pixel) +let + r = map<<3>> (/.) (x, c^3); +tel + +node counter(res :bool) returns (cpt :int) +let + reset + cpt = (0 fby cpt) + 1 + every res +tel + +(* down par region +node down(x :pixel; out :bool) returns (r :pixel) +var cpt :float; sum :pixel; +let + reset + cpt = (0.0 fby cpt) +. 1.0; + sum = x -> pix_sum(pre sum, x); + every out; + r = pix_div(sum when out, cpt when out); +tel +*) + +node down(x :pixel; out :bool) returns (r :pixel :: . on out) +var x1, x2 : pixel; +let + x1 = x fby x; + x2 = x fby x1; + r = pix_div(pix_sum(x when out, pix_sum(x1 when out, x2 when out)), 3.0 ); +tel