optimization of m5d multiplication