mirror of
https://github.com/golang/go
synced 2024-11-17 01:24:50 -07:00
f959fb3872
The SPanchored opcode is identical to SP, except that it takes a memory argument so that it (and more importantly, anything that uses it) must be scheduled at or after that memory argument. This opcode ensures that a LEAQ of a variable gets scheduled after the corresponding VARDEF for that variable. This may lead to less CSE of LEAQ operations. The effect is very small. The go binary is only 80 bytes bigger after this CL. Usually LEAQs get folded into load/store operations, so the effect is only for pointerful types, large enough to need a duffzero, and have their address passed somewhere. Even then, usually the CSEd LEAQs will be un-CSEd because the two uses are on different sides of a function call and the LEAQ ends up being rematerialized at the second use anyway. Change-Id: Ib893562cd05369b91dd563b48fb83f5250950293 Reviewed-on: https://go-review.googlesource.com/c/go/+/452916 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Martin Möhrmann <moehrmann@google.com> Reviewed-by: Martin Möhrmann <martin@golang.org> Reviewed-by: Keith Randall <khr@google.com>
29 lines
807 B
Go
29 lines
807 B
Go
// asmcheck
|
|
|
|
// 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.
|
|
|
|
package codegen
|
|
|
|
// Test to make sure that (CMPQ (ANDQ x y) [0]) does not get rewritten to
|
|
// (TESTQ x y) if the ANDQ has other uses. If that rewrite happens, then one
|
|
// of the args of the ANDQ needs to be saved so it can be used as the arg to TESTQ.
|
|
func andWithUse(x, y int) int {
|
|
z := x & y
|
|
// amd64:`TESTQ\s(AX, AX|BX, BX|CX, CX|DX, DX|SI, SI|DI, DI|R8, R8|R9, R9|R10, R10|R11, R11|R12, R12|R13, R13|R15, R15)`
|
|
if z == 0 {
|
|
return 77
|
|
}
|
|
// use z by returning it
|
|
return z
|
|
}
|
|
|
|
// Verify (OR x (NOT y)) rewrites to (ORN x y) where supported
|
|
func ornot(x, y int) int {
|
|
// ppc64:"ORN"
|
|
// ppc64le:"ORN"
|
|
z := x | ^y
|
|
return z
|
|
}
|