https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106574
--- Comment #11 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- On Wed, 10 Aug 2022, michael.hudson at canonical dot com via Gcc-bugs wrote: > I just changed > > z = xx * xx; > > to > > z = math_opt_barrier(xx * xx); > > which perhaps isn't sufficient. That wouldn't prevent the multiplication being moved before SET_RESTORE_ROUNDL, though it should suffice for the later computations as they all depend on z. > But my reading of the assembly is that the issue is that some of the math code > is being moved _after_ the restore of the fpu state implied by > SET_RESTORE_ROUNDL (FE_TONEAREST). To avoid code being moved after the restore, "math_force_eval (p);" just before the return would be appropriate.