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
// bucketShift returns 1<<b, optimized for code generation.funcbucketShift(buint8) uintptr {
ifsys.GoarchAmd64|sys.GoarchAmd64p32|sys.Goarch386!=0 {
b&=sys.PtrSize*8-1// help x86 archs remove shift overflow checks
}
returnuintptr(1) <<b
}
IIRC, s390x also makes use of masks to remove shift overflow checks. @mundaym care to send a CL adding s390x if that's correct? (And close this issue if not?)
The text was updated successfully, but these errors were encountered:
Yes, s390x does (and so does ppc64{,le} as well actually). My vote would be just to get rid of the if statement since in the worst case it just adds one extra AND instruction, and most architectures can generate better code with the mask even if they don't currently.
If we are particularly worried about this code path for some reason we could add an extra bunch of generic rules to detect this pattern and turn it into a rotate instruction, since rotate and shift are equivalent operations when the input is 1 and the shift amount is masked to the bit-width of the input.
IIRC, s390x also makes use of masks to remove shift overflow checks. @mundaym care to send a CL adding s390x if that's correct? (And close this issue if not?)
The text was updated successfully, but these errors were encountered: