WIP: speed up convolve2d a tiny bit

This is a more or less failed experiment to prematurely optimize convolve2d.  I'm not convinced that breaking the convolve2d loops into 18 cases to get rid of the within-loop branching will significantly speed up the implementation.  It may be better to break it up by data type instead of by mode, possibly by using actual c++ templates.  Or just leave it alone.