According to Murphy's English Grammar in Use you can use "have to" in all forms, and he offers an example in the past simple and another one in the present perfect tense. Hence, I was wondering if had to followed by a perfect infinitive would be feasible.
In Spanish, there are two constructions very similar in meaning:
-Si querías aprobar el examen, deberías haber estudiado más ("If you wanted to pass the exam, you should have studied harder.)
-Si querías aprobar el examen tenías que haber estudiado más.("If you wanted to pass the exam, you had to have studied harder.) However, this one sounds odd to me, and wanted confirmation.
Given the tendency the English language has to simplify (He apologised for being rude is far more common than He apologised for having been rude) I thought that perhaps "If you wanted to pass the exam, you had to study harder." might also be consired as correct.