It is narrated from Sayyiduna Amir bin Rabi'ah (may Allah be pleased with him) that he said: I saw the Messenger of Allah (peace and blessings be upon him) offering voluntary prayer on his mount. He was making gestures with his head and was not paying attention to the qiblah. But he (peace and blessings be upon him) did not do this in the obligatory prayers.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2220