Yes, hip opening exercises!
Yoga (and Feldenkrais exercise/lessons) can be very helpful to opening the hips and “stretching” the hip flexors without force. Tight hip flexors (as a result of too much sitting in a chair or a car seat) will result in the knee creeping up.
You need to practice the “kneeling seat”; you will want to grow your knees forward/down like you are kneeling on a church pew (not that this is anything I have personal experience with, LOL), and open your heel so that the inside of your thigh is placed against the horse; this will open your hips. Any time you roll onto the back of your leg it causes the knee to come up, so rotate your knee softly IN, and sink “down around” the horse.
Allow your heels to sink down and back with a light foot and a soft ankle; forcing the heels down will cause the leg to brace and the lower leg will creep forward, causing the hip flexors to tighten and the body to tip forward defensively.
You want to feel the front of your body opening (float the sternum up, open your ribcage, lift the belly button), and the lower body should sink down and fall into place when you “kneel” on the horse’s ribcage.
If you focus on lengthening your leg this way (heel out, thigh softly hugging, kneeling down, pelvis centered in the saddle), you should be able to lift your toes while weighting the stirrups and allowing the heel to drop back and down towards the horse’s hind toes.
Riding without stirrups can be helpful (especially during the first 10 minutes of walking warmup), but make sure you aren’t rolling onto the back of your thigh, since this just causes gripping and bracing patterns and puts you “behind” your leg.
Are you riding in a dressage saddle? Obviously all of this is more difficult if you’re in a jumping saddle since it wants to put your leg more in front of you and close your hip and knee angles based on the position of the flap and seat.
Avoid “jamming your heels down” to keep your stirrup. Losing stirrups is often the result of the knee creeping up (see above), so “allowing” the knees to grow forward/down will put the weight of your lower leg where it should be; back and under you.
Wendy Murdoch, Sally Swift and Mary Wanless are all GREAT resources for improving position and understanding biomechanics
They have transformed me (and my teaching!)