What is the purpose of these two diamonds in Celeste chapter 9 (Farewell)?

Those diamonds are part of an alternative route. You can use the route, but you have to waste some time before jumping towards the diamonds (I did it by dashing up):

To get there a bit earlier and in phase, you'd have to also use the other alternatives:

This route is faster than using the bird, so it would be preferable for a speedrunner.
I died way more than I'd like to admit while trying and routing through that. I didn't actually count my deaths though.