Update res after operation only when it is optimized case

Normally, res is updated before operation.