Optimize affine input/output case again