mirror of
https://github.com/golang/go
synced 2025-06-29 19:37:35 +00:00
cmd/compile: optimize absorbing InvertFlags into Noov comparisons for arm64
Previously (LessThanNoov (InvertFlags x)) is lowered as: CSET CSET BIC With this CL it's lowered as: CSET CSEL This saves one instruction. Similarly (GreaterEqualNoov (InvertFlags x)) is now lowered as: CSET CSINC $ benchstat old.bench new.bench goos: linux goarch: arm64 │ old.bench │ new.bench │ │ sec/op │ sec/op vs base │ InvertLessThanNoov-160 2.249n ± 2% 2.190n ± 1% -2.62% (p=0.003 n=10) Change-Id: Idd8979b7f4fe466e74b1a201c4aba7f1b0cffb0b Reviewed-on: https://go-review.googlesource.com/c/go/+/526237 Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Eric Fang <eric.fang@arm.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
@ -788,3 +788,16 @@ func cmp7() {
|
||||
cmp5[string]("") // force instantiation
|
||||
cmp6[string]("") // force instantiation
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
X, Y int
|
||||
}
|
||||
|
||||
// invertLessThanNoov checks (LessThanNoov (InvertFlags x)) is lowered as
|
||||
// CMP, CSET, CSEL instruction sequence. InvertFlags are only generated under
|
||||
// certain conditions, see canonLessThan, so if the code below does not
|
||||
// generate an InvertFlags OP, this check may fail.
|
||||
func invertLessThanNoov(p1, p2, p3 Point) bool {
|
||||
// arm64:`CMP`,`CSET`,`CSEL`
|
||||
return (p1.X-p3.X)*(p2.Y-p3.Y)-(p2.X-p3.X)*(p1.Y-p3.Y) < 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user