You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently cmd/internal/obj replaces MOV* $0, r with XOR* r, r for 386 and amd64 as an "optimization". However, this is not a semantics-preserving transformation since XOR clobbers registers, while MOV does not.
This has caused pain in several places:
The compiler sets a special PRESERVEFLAGS bit when it creates MOV Progs at points where the flags are live.
The assembly in math/big has the ominous comment "CAUTION: Note that MOVQ $0, Rx is translated to XORQ Rx, Rx which clears the carry bit!".
It caused bugs in CL 71270 that were very difficult to track down and required restructuring the assembly to work around.
We should consider removing this transformation from obj and instead just doing it in the compiler. There are only a handful of instances of this in hand-written assembly in the standard library. We could rewrite these to XOR by hand, or just not bother.
Currently cmd/internal/obj replaces
MOV* $0, r
withXOR* r, r
for 386 and amd64 as an "optimization". However, this is not a semantics-preserving transformation since XOR clobbers registers, while MOV does not.This has caused pain in several places:
The compiler sets a special PRESERVEFLAGS bit when it creates MOV Progs at points where the flags are live.
The assembly in
math/big
has the ominous comment "CAUTION: Note that MOVQ $0, Rx is translated to XORQ Rx, Rx which clears the carry bit!".It caused bugs in CL 71270 that were very difficult to track down and required restructuring the assembly to work around.
We should consider removing this transformation from obj and instead just doing it in the compiler. There are only a handful of instances of this in hand-written assembly in the standard library. We could rewrite these to XOR by hand, or just not bother.
/cc @randall77 @iant
The text was updated successfully, but these errors were encountered: