Implicit and explicit optimizations for stencil computations