Simple question: Why did the Late Roman infantry adopt the spatha over the gladius? I understand that the infantry transitioned to using the spear as their primary weapon but it seems to me that that would be a case for keeping the gladius as a secondary weapon, not adopting the spatha instead. Since the spear is a longer weapon it seems like the better backup to it would be a short sword since if the enemy has gotten past the reach of a spear they'll be in close, where a shorter weapon will have an advantage over a longer one. Similarly, the spear could be used in dense formations, to poke between gaps in shield. A longer sword like a spatha could still be used to stab in a formation like that, but it was too long to swing, while a short sword could do both.
So, what am I missing? Why did the Late Roman army use the spatha?