In short
To talk about a past that you cannot change, we use if + Past Perfect in one part and would have + past participle in the other: If I'd known, I would have come. It is about something that did not really happen: I didn't know, and I didn't come.
The parts can change places: She would have called if she'd had time. The short form 'd can mean had or would. After if, it is had. In the other part, it is would: If you'd told me, I'd have come = If you had told me, I would have come. More about had + past participle on the page Past Perfect.
When we use the third conditional
- Something that did not happen in the past: We missed the train. If we had left earlier, we would have caught it.
- A different result in the past: Tom didn't pass the exam. If he had worked harder, he would have passed it.
- With a negative after if: If it hadn't rained, we'd have played.
Instead of would have, we can also use could have or might have: If I'd known, I could have visited you. In speech, would have is often would've or 'd have: I'd have visited you.
When a past event changes the present, as in If I'd slept more, I wouldn't be tired now, the forms are mixed. That is a separate topic.
The rule with examples
01if + Past Perfect, would have: the past
To talk about a past that you cannot change, use the Past Perfect after if. In the other part, use would have + past participle.
It is about something that did not really happen.
IfI'dknown,Iwould have come
- She would have called if she'd had time.
The short form 'd can be had or would. After if, it is had. In the other part, it is would.
- We'd have won if you'd played.
- If you'd told me, I'd have come.
Don't use would after if here either: If I had known, not If I would have known.
Common mistakes
Past Simple after if. For the past, the part with if has the Past Perfect: If I had known about the problem yesterday, I would have helped (not: If I knew about the problem yesterday).
would in the part with if. Don't use would after if: If I had known (not: If I would have known).
Past Perfect in both parts. The other part has would have + past participle: If you had told me earlier, I would have helped you (not: If you had told me earlier, I had helped you).
will in a sentence about the past. When the part with if has the Past Perfect, the other part doesn't have will: I would have helped you (not: I will help you).
Third conditional or second conditional
The forms show the time. With if + Past Simple and would, we talk about something unreal now or unlikely later: If I had more time, I'd learn Spanish. With if + Past Perfect and would have, we talk about the past: If I'd had time, I'd have called. Compare If I have time, I'll call: this can really happen. More about if + Past Simple and would on the page Second conditional.
See also: Sentences with if 2: would, I wish