Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: uint16 arithmetic results different on arm between go 1.8 and go 1.7.5 #19270
On 32-bit arm linux I've found some code that produces an incorrect result when compiled with go 1.8.
This is illustrated by the little example at
The correct output is 0x888e. But the executable produced by
changed the title
uint16 arithmetic results different on arm between go 1.8 and go 1.7.5
Feb 24, 2017
This rule was wrong. It should zero-extend x before right shift. On the other hand, it should use rotation instruction at first place. This is already fixed in Go 1.9 (Keith's CL on moving rotation generation to SSA). For fixing Go 1.8, I'll add a zero-extension there.
Correction: there is no sub-word rotation instruction. So lowering to left-shift OR right-shift (with zero-extension) is the right way.
Other architectures are correct. 386/AMD64 uses rotation instruction; ARM64 has a similar rule as ARM but does have zero-extension; Lrot8/16 are not generated on other architectures.