diff options
| author | Jorropo <jorropo.pgm@gmail.com> | 2026-03-29 05:19:58 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-04-03 13:21:37 -0700 |
| commit | 0a36b58888cc41b276362673f70be87efd7e55ad (patch) | |
| tree | 4e23a040eca0b800599113ffdd20d9c5f641c637 /src/cmd/internal/script | |
| parent | 142f2376017887a3ed02dc1bc91542d39cfe2ecd (diff) | |
| download | go-0a36b58888cc41b276362673f70be87efd7e55ad.tar.xz | |
cmd/compile: extend all the cmov into math generic rules with their contrary
If the bool comes from a local operation this is foldable into the comparison.
if a == b {
} else {
x++
}
becomes:
x += !(a == b)
becomes:
x += a != b
If the bool is passed in or loaded rather than being locally computed
this adds an extra XOR ^1 to invert it.
But at worst it should make the math equal to the compute + CMP + CMOV
which is a tie on modern CPUs which can execute CMOV on all int ALUs
and a win on the cheaper or older ones which can't.
Change-Id: Idd2566c7a3826ec432ebfbba7b3898aa0db4b812
Reviewed-on: https://go-review.googlesource.com/c/go/+/760922
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'src/cmd/internal/script')
0 files changed, 0 insertions, 0 deletions
