compiler: implement composite_function::optimize