(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<<uint32(c)] x)
-(AND(L|Q)const [c] (BTR(L|Q)const [d] x)) -> (AND(L|Q)const [c &^ 1<<uint32(d)] x)
+(BTR(L|Q)const [c] (AND(L|Q)const [d] x)) -> (AND(L|Q)const [d &^ (1<<uint32(c))] x)
+(AND(L|Q)const [c] (BTR(L|Q)const [d] x)) -> (AND(L|Q)const [c &^ (1<<uint32(d))] x)
(BTR(L|Q)const [c] (BTR(L|Q)const [d] x)) -> (AND(L|Q)const [^(1<<uint32(c) | 1<<uint32(d))] x)
(XOR(L|Q)const [c] (XOR(L|Q)const [d] x)) -> (XOR(L|Q)const [c ^ d] x)
(BTC(L|Q)const [c] (XOR(L|Q)const [d] x)) -> (XOR(L|Q)const [d ^ 1<<uint32(c)] x)
}
// match: (ANDLconst [c] (BTRLconst [d] x))
// cond:
- // result: (ANDLconst [c &^ 1<<uint32(d)] x)
+ // result: (ANDLconst [c &^ (1<<uint32(d))] x)
for {
c := v.AuxInt
v_0 := v.Args[0]
d := v_0.AuxInt
x := v_0.Args[0]
v.reset(OpAMD64ANDLconst)
- v.AuxInt = c &^ 1 << uint32(d)
+ v.AuxInt = c &^ (1 << uint32(d))
v.AddArg(x)
return true
}
}
// match: (ANDQconst [c] (BTRQconst [d] x))
// cond:
- // result: (ANDQconst [c &^ 1<<uint32(d)] x)
+ // result: (ANDQconst [c &^ (1<<uint32(d))] x)
for {
c := v.AuxInt
v_0 := v.Args[0]
d := v_0.AuxInt
x := v_0.Args[0]
v.reset(OpAMD64ANDQconst)
- v.AuxInt = c &^ 1 << uint32(d)
+ v.AuxInt = c &^ (1 << uint32(d))
v.AddArg(x)
return true
}
}
// match: (BTRLconst [c] (ANDLconst [d] x))
// cond:
- // result: (ANDLconst [d &^ 1<<uint32(c)] x)
+ // result: (ANDLconst [d &^ (1<<uint32(c))] x)
for {
c := v.AuxInt
v_0 := v.Args[0]
d := v_0.AuxInt
x := v_0.Args[0]
v.reset(OpAMD64ANDLconst)
- v.AuxInt = d &^ 1 << uint32(c)
+ v.AuxInt = d &^ (1 << uint32(c))
v.AddArg(x)
return true
}
}
// match: (BTRQconst [c] (ANDQconst [d] x))
// cond:
- // result: (ANDQconst [d &^ 1<<uint32(c)] x)
+ // result: (ANDQconst [d &^ (1<<uint32(c))] x)
for {
c := v.AuxInt
v_0 := v.Args[0]
d := v_0.AuxInt
x := v_0.Args[0]
v.reset(OpAMD64ANDQconst)
- v.AuxInt = d &^ 1 << uint32(c)
+ v.AuxInt = d &^ (1 << uint32(c))
v.AddArg(x)
return true
}
--- /dev/null
+// run
+
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Bad AND/BTR combination rule.
+
+package main
+
+import "fmt"
+
+//go:noinline
+func f(x uint64) uint64 {
+ return (x >> 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")
+ }
+}