Motion compensation is vital for cardiac diffusion MRI. In this paper we propose an optimized gradient waveform design that allows tensor-valued diffusion encoding with motion compensation. We demonstrate that it works for in vivo cardiac imaging and we show that it is more efficient than previous designs.