From: Keith Randall Date: Mon, 24 Sep 2018 17:23:53 +0000 (-0700) Subject: cmd/compile: fix precedence order bug X-Git-Tag: go1.12beta1~1030 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9774fa6f4020dba924d63991f572aa89325e1c9c;p=gostls13.git cmd/compile: fix precedence order bug &^ and << have equal precedence. Add some parentheses to make sure we shift before we andnot. Fixes #27829 Change-Id: Iba8576201f0f7c52bf9795aaa75d15d8f9a76811 Reviewed-on: https://go-review.googlesource.com/136899 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index 76a4fc9ab7..f9ac5e4dce 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -709,8 +709,8 @@ (ANDL x (MOVLconst [c])) -> (ANDLconst [c] x) (AND(L|Q)const [c] (AND(L|Q)const [d] x)) -> (AND(L|Q)const [c & d] x) -(BTR(L|Q)const [c] (AND(L|Q)const [d] x)) -> (AND(L|Q)const [d &^ 1< (AND(L|Q)const [c &^ 1< (AND(L|Q)const [d &^ (1< (AND(L|Q)const [c &^ (1< (AND(L|Q)const [^(1< (XOR(L|Q)const [c ^ d] x) (BTC(L|Q)const [c] (XOR(L|Q)const [d] x)) -> (XOR(L|Q)const [d ^ 1<> 48) &^ (uint64(0x4000)) +} + +func main() { + bad := false + if got, want := f(^uint64(0)), uint64(0xbfff); got != want { + fmt.Printf("got %x, want %x\n", got, want) + bad = true + } + if bad { + panic("bad") + } +}