When you slouch and struggle to use good form in basic movement patterns, it can definitely be a product of inflexibility, but it’s just as often a product of poor integrity of the thoracic spine. The T-spine should have the capability of flexing and extending, along with the capability of going through rotation at each segment.
When either of these capacities are subpar, the lumbar spine takes on much more of a workload than it should. Before addressing anything muscular, it’s important to train that jimmied up portion of spine so that it extends and rotates freely without any load whatsoever.
Using your body plus gravity and a foam roller is a great way to make the spine feel extension without a real muscular force-feed. Being able to have the back and shoulders fold around the roller can help the body and spine connect the brain to the feeling of extension without too much muscular “fighting for position.” It’s actually more of a relaxing stretch. Using different arm positions can be a game changer to help understand how this translates to overhead exercises.