Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: -race instrumentation leads to different behaviour due to 16 to 32-bit expansion #21963
What version of Go are you using (
Thanks for the detailed bug report.
I can reproduce the problem. Mostly to record this for myself, do:
Near the top of the listing there is:
An unsigned 16-bit load followed by a signed multiply, no extension between.
I have no idea why -race is relevant.
If we have y = <int16> (MOVBQSX x) z = <int32> (MOVWQSX y) We used to use this rewrite rule: (MOVWQSX x:(MOVBQSX _)) -> x But that resulted in replacing z with a value whose type is only int16. Then if z is spilled and restored, it gets zero extended instead of sign extended. Instead use the rule (MOVWQSX (MOVBQSX x)) -> (MOVBQSX x) The result is has the correct type, so it can be spilled and restored correctly. It might mean that a few more extension ops might not be eliminated, but that's the price for correctness. Fixes #21963 Change-Id: I6ec82c3d2dbe43cc1fee6fb2bd6b3a72fca3af00 Reviewed-on: https://go-review.googlesource.com/65290 Reviewed-by: Cherry Zhang <firstname.lastname@example.org> Run-TryBot: Cherry Zhang <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-on: https://go-review.googlesource.com/70986 Run-TryBot: Russ Cox <email@example.com> Reviewed-by: Keith Randall <firstname.lastname@example.org>