Skip to content

Commit fb5bdb4

Browse files
committed
cmd/compile: absorb InvertFlags into Noov comparisons
Unfortunately, there isn't a single op that provides the resulting computation. At least, I couldn't find one. Fixes #62469 Change-Id: I236f3965b827aaeb3d70ef9fe89be66b116494f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/526276 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 0725410 commit fb5bdb4

3 files changed

Lines changed: 77 additions & 14 deletions

File tree

src/cmd/compile/internal/ssa/_gen/ARM64.rules

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,20 +1555,22 @@
15551555
(GreaterEqualU (FlagConstant [fc])) => (MOVDconst [b2i(fc.uge())])
15561556

15571557
// absorb InvertFlags into boolean values
1558-
(Equal (InvertFlags x)) => (Equal x)
1559-
(NotEqual (InvertFlags x)) => (NotEqual x)
1560-
(LessThan (InvertFlags x)) => (GreaterThan x)
1561-
(LessThanU (InvertFlags x)) => (GreaterThanU x)
1562-
(GreaterThan (InvertFlags x)) => (LessThan x)
1563-
(GreaterThanU (InvertFlags x)) => (LessThanU x)
1564-
(LessEqual (InvertFlags x)) => (GreaterEqual x)
1565-
(LessEqualU (InvertFlags x)) => (GreaterEqualU x)
1566-
(GreaterEqual (InvertFlags x)) => (LessEqual x)
1567-
(GreaterEqualU (InvertFlags x)) => (LessEqualU x)
1568-
(LessThanF (InvertFlags x)) => (GreaterThanF x)
1569-
(LessEqualF (InvertFlags x)) => (GreaterEqualF x)
1570-
(GreaterThanF (InvertFlags x)) => (LessThanF x)
1571-
(GreaterEqualF (InvertFlags x)) => (LessEqualF x)
1558+
(Equal (InvertFlags x)) => (Equal x)
1559+
(NotEqual (InvertFlags x)) => (NotEqual x)
1560+
(LessThan (InvertFlags x)) => (GreaterThan x)
1561+
(LessThanU (InvertFlags x)) => (GreaterThanU x)
1562+
(GreaterThan (InvertFlags x)) => (LessThan x)
1563+
(GreaterThanU (InvertFlags x)) => (LessThanU x)
1564+
(LessEqual (InvertFlags x)) => (GreaterEqual x)
1565+
(LessEqualU (InvertFlags x)) => (GreaterEqualU x)
1566+
(GreaterEqual (InvertFlags x)) => (LessEqual x)
1567+
(GreaterEqualU (InvertFlags x)) => (LessEqualU x)
1568+
(LessThanF (InvertFlags x)) => (GreaterThanF x)
1569+
(LessEqualF (InvertFlags x)) => (GreaterEqualF x)
1570+
(GreaterThanF (InvertFlags x)) => (LessThanF x)
1571+
(GreaterEqualF (InvertFlags x)) => (LessEqualF x)
1572+
(LessThanNoov (InvertFlags x)) => (BIC (GreaterEqualNoov <typ.Bool> x) (Equal <typ.Bool> x))
1573+
(GreaterEqualNoov (InvertFlags x)) => (OR (LessThanNoov <typ.Bool> x) (Equal <typ.Bool> x))
15721574

15731575
// Boolean-generating instructions (NOTE: NOT all boolean Values) always
15741576
// zero upper bit of the register; no need to zero-extend

src/cmd/compile/internal/ssa/rewriteARM64.go

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixedbugs/issue62469.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile
2+
3+
// Copyright 2023 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
func sign(p1, p2, p3 point) bool {
10+
return (p1.x-p3.x)*(p2.y-p3.y)-(p2.x-p3.x)*(p1.y-p3.y) < 0
11+
}
12+
13+
type point struct {
14+
x, y int
15+
}

0 commit comments

Comments
 (0)