If my fast-math understanding is correct, 'reassoc' alone is not enough because that doesn't give us the freedom to get the negative number cases wrong.
I considered that we might not even need 'reassoc' here, but if we eliminate the sqrt calls, then we may differ in the last bit by eliminating the rounding that occurs in those calls.
Maybe add a test that we don't do this without the relevant fast-math flags?