It depends on the particular IIM. IIM Indore places a lot of emphasis on class 12 scores while some IIMs like IIM Calcutta do not give much importance to past academic scores and solely evaluate you on the basis of your CAT scores.
It would be wrong to say that 12th grades don’t matter at all for admission to IIMs but yes they give you a bit of an advantage over those who have performed poorly in class 12th. Some IIMs give weightage to class 12th marks for shortlisting candidates for admission while some don't. But if you have scored well in CAT, your class 12th score does not matter much.