I heard of a study many years ago that concluded that listening to music you like made you drive your car a bit faster, regardless of the pace of your preferred music. Not sure that translates to cognitive performance, but might suggest listening to music at the gym is useful.
Also now wondering if there’s any research on how music affects (cognitive) performance.