mirror of
https://github.com/golang/go
synced 2024-11-11 19:11:35 -07:00
Revert "cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero"
This reverts commit c1dfbf72e1
.
Reason for revert: TESTL rule is wrong when the result is used for an ordered comparison.
Fixes #62360
Change-Id: I4d5b6aca24389b0a2bf767bfbc0a9d085359eb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/524255
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
1f8f2ab966
commit
0e02baa59a
@ -1449,10 +1449,6 @@
|
||||
(TESTW (MOVLconst [c]) x) => (TESTWconst [int16(c)] x)
|
||||
(TESTB (MOVLconst [c]) x) => (TESTBconst [int8(c)] x)
|
||||
|
||||
// shorten bitwise AND/TESTQ if upper 32 bits are known to be zero.
|
||||
(ANDQ x y) && (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) => (ANDL x y)
|
||||
(TESTQ x y) && (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) => (TESTL x y)
|
||||
|
||||
// TEST %reg,%reg is shorter than CMP
|
||||
(CMPQconst x [0]) => (TESTQ x x)
|
||||
(CMPLconst x [0]) => (TESTL x x)
|
||||
|
@ -3094,22 +3094,6 @@ func rewriteValueAMD64_OpAMD64ANDQ(v *Value) bool {
|
||||
v.copyOf(x)
|
||||
return true
|
||||
}
|
||||
// match: (ANDQ x y)
|
||||
// cond: (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3))
|
||||
// result: (ANDL x y)
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
x := v_0
|
||||
y := v_1
|
||||
if !(zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) {
|
||||
continue
|
||||
}
|
||||
v.reset(OpAMD64ANDL)
|
||||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (ANDQ x l:(MOVQload [off] {sym} ptr mem))
|
||||
// cond: canMergeLoadClobber(v, l, x) && clobber(l)
|
||||
// result: (ANDQload x [off] {sym} ptr mem)
|
||||
@ -22718,22 +22702,6 @@ func rewriteValueAMD64_OpAMD64TESTQ(v *Value) bool {
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (TESTQ x y)
|
||||
// cond: (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3))
|
||||
// result: (TESTL x y)
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
x := v_0
|
||||
y := v_1
|
||||
if !(zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) {
|
||||
continue
|
||||
}
|
||||
v.reset(OpAMD64TESTL)
|
||||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (TESTQ l:(MOVQload {sym} [off] ptr mem) l2)
|
||||
// cond: l == l2 && l.Uses == 2 && clobber(l)
|
||||
// result: @l.Block (CMPQconstload {sym} [makeValAndOff(0, off)] ptr mem)
|
||||
|
24
test/fixedbugs/issue62360.go
Normal file
24
test/fixedbugs/issue62360.go
Normal file
@ -0,0 +1,24 @@
|
||||
// run
|
||||
|
||||
// Copyright 2023 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.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
//go:noinline
|
||||
func f(x uint32) *big.Int {
|
||||
return big.NewInt(int64(x))
|
||||
}
|
||||
func main() {
|
||||
b := f(0xffffffff)
|
||||
c := big.NewInt(0xffffffff)
|
||||
if b.Cmp(c) != 0 {
|
||||
panic(fmt.Sprintf("b:%x c:%x", b, c))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user