2020-04-23 00:21:59 -07:00
|
|
|
// asmcheck
|
|
|
|
|
|
|
|
|
|
// Copyright 2020 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
|
|
|
|
|
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
import (
|
|
|
|
|
"math/bits"
|
|
|
|
|
)
|
|
|
|
|
|
2020-04-23 00:21:59 -07:00
|
|
|
// This file contains codegen tests related to boolean simplifications/optimizations.
|
|
|
|
|
|
|
|
|
|
func convertNeq0B(x uint8, c bool) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// amd64:"ANDL [$]1" -"SETNE"
|
|
|
|
|
// ppc64x:"RLDICL" -"CMPW" -"ISEL"
|
2020-04-23 00:21:59 -07:00
|
|
|
b := x&1 != 0
|
|
|
|
|
return c && b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertNeq0W(x uint16, c bool) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// amd64:"ANDL [$]1" -"SETNE"
|
|
|
|
|
// ppc64x:"RLDICL" -"CMPW" -"ISEL"
|
2020-04-23 00:21:59 -07:00
|
|
|
b := x&1 != 0
|
|
|
|
|
return c && b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertNeq0L(x uint32, c bool) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// amd64:"ANDL [$]1" -"SETB"
|
|
|
|
|
// ppc64x:"RLDICL" -"CMPW" -"ISEL"
|
2020-04-23 00:21:59 -07:00
|
|
|
b := x&1 != 0
|
|
|
|
|
return c && b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertNeq0Q(x uint64, c bool) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// amd64:"ANDL [$]1" -"SETB"
|
|
|
|
|
// ppc64x:"RLDICL" -"CMP" -"ISEL"
|
2020-04-23 00:21:59 -07:00
|
|
|
b := x&1 != 0
|
|
|
|
|
return c && b
|
|
|
|
|
}
|
2022-08-08 09:36:07 -05:00
|
|
|
|
|
|
|
|
func convertNeqBool32(x uint32) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x:"RLDICL" -"CMPW" -"ISEL"
|
2023-01-24 11:38:29 -06:00
|
|
|
return x&1 != 0
|
2022-08-08 09:36:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertEqBool32(x uint32) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x:"RLDICL" -"CMPW" "XOR" -"ISEL"
|
|
|
|
|
// amd64:"ANDL" "XORL" -"BTL" -"SETCC"
|
2023-01-24 11:38:29 -06:00
|
|
|
return x&1 == 0
|
2022-08-08 09:36:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertNeqBool64(x uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x:"RLDICL" -"CMP" -"ISEL"
|
2023-01-24 11:38:29 -06:00
|
|
|
return x&1 != 0
|
2022-08-08 09:36:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertEqBool64(x uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x:"RLDICL" "XOR" -"CMP" -"ISEL"
|
|
|
|
|
// amd64:"ANDL" "XORL" -"BTL" -"SETCC"
|
2023-01-24 11:38:29 -06:00
|
|
|
return x&1 == 0
|
2022-08-08 09:36:07 -05:00
|
|
|
}
|
2022-11-11 06:10:59 -06:00
|
|
|
|
2025-04-19 12:31:26 +02:00
|
|
|
func phiAnd(a, b bool) bool {
|
|
|
|
|
var x bool
|
|
|
|
|
// amd64:-"TESTB"
|
|
|
|
|
if a {
|
|
|
|
|
x = b
|
|
|
|
|
} else {
|
|
|
|
|
x = a
|
|
|
|
|
}
|
|
|
|
|
// amd64:"ANDL"
|
|
|
|
|
return x
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func phiOr(a, b bool) bool {
|
|
|
|
|
var x bool
|
|
|
|
|
// amd64:-"TESTB"
|
|
|
|
|
if a {
|
|
|
|
|
x = a
|
|
|
|
|
} else {
|
|
|
|
|
x = b
|
|
|
|
|
}
|
|
|
|
|
// amd64:"ORL"
|
|
|
|
|
return x
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 06:10:59 -06:00
|
|
|
func TestSetEq64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0EQ"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x == y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetNeq64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0EQ"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x != y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetLt64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0GT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0GT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0GT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x < y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetLe64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0LT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x <= y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetGt64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x > y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetGe64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0GT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0GT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0GT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x >= y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetLtFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x < y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetLeFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" "SETBC CR0EQ" "OR" -"ISEL" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"ISEL" "ISEL" -"SETBC CR0LT" -"SETBC CR0EQ" "OR"
|
|
|
|
|
// ppc64x/power8:"ISEL" "ISEL" -"SETBC CR0LT" -"SETBC CR0EQ" "OR"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x <= y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetGtFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x > y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetGeFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" "SETBC CR0EQ" "OR" -"ISEL" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"ISEL" "ISEL" -"SETBC CR0LT" -"SETBC CR0EQ" "OR"
|
|
|
|
|
// ppc64x/power8:"ISEL" "ISEL" -"SETBC CR0LT" -"SETBC CR0EQ" "OR"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := x >= y
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvEq64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0EQ"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x == y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvNeq64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0EQ"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x != y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvLt64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0GT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0GT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0GT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x < y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvLe64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x <= y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvGt64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBCR CR0LT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBCR CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x > y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvGe64(x uint64, y uint64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0GT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"CMP" "ISEL" -"SETBC CR0GT"
|
|
|
|
|
// ppc64x/power8:"CMP" "ISEL" -"SETBC CR0GT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x >= y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSetInvEqFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBCR CR0EQ"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBCR CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x == y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvNeqFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0EQ" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBC CR0EQ"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBC CR0EQ"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x != y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvLtFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBCR CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBCR CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x < y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvLeFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x <= y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvGtFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBCR CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBCR CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBCR CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x > y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
func TestSetInvGeFp64(x float64, y float64) bool {
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x/power10:"SETBC CR0LT" -"ISEL"
|
|
|
|
|
// ppc64x/power9:"FCMP" "ISEL" -"SETBC CR0LT"
|
|
|
|
|
// ppc64x/power8:"FCMP" "ISEL" -"SETBC CR0LT"
|
2022-11-11 06:10:59 -06:00
|
|
|
b := !(x >= y)
|
|
|
|
|
return b
|
|
|
|
|
}
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
func TestLogicalCompareZero(x *[64]uint64) {
|
|
|
|
|
// ppc64x:"ANDCC",^"AND"
|
2024-07-11 19:38:33 -07:00
|
|
|
b := x[0] & 3
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[0] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"ANDCC",^"AND"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[1] & x[2]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[1] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"ANDNCC",^"ANDN"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[1] &^ x[2]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[1] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"ORCC",^"OR"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[3] | x[4]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[3] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"SUBCC",^"SUB"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[5] - x[6]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[5] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"NORCC",^"NOR"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = ^(x[5] | x[6])
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[5] = b
|
2023-09-27 12:15:04 -05:00
|
|
|
}
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
// ppc64x:"XORCC",^"XOR"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[7] ^ x[8]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[7] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"ADDCC",^"ADD"
|
2024-07-11 19:38:33 -07:00
|
|
|
b = x[9] + x[10]
|
|
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[9] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"NEGCC",^"NEG"
|
|
|
|
|
b = -x[11]
|
2024-07-11 19:38:33 -07:00
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[11] = b
|
|
|
|
|
}
|
|
|
|
|
// ppc64x:"CNTLZDCC",^"CNTLZD"
|
|
|
|
|
b = uint64(bits.LeadingZeros64(x[12]))
|
2024-07-11 19:38:33 -07:00
|
|
|
if b != 0 {
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
x[12] = b
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-26 22:51:14 -04:00
|
|
|
// ppc64x:"ADDCCC [$]4,"
|
cmd/compile/internal/ssa: on PPC64, merge (CMPconst [0] (op ...)) more aggressively
Generate the CC version of many opcodes whose result is compared against
signed 0. The approach taken here works even if the opcode result is used in
multiple places too.
Add support for ADD, ADDconst, ANDN, SUB, NEG, CNTLZD, NOR conversions
to their CC opcode variant. These are the most commonly used variants.
Also, do not set clobberFlags of CNTLZD and CNTLZW, they do not clobber
flags.
This results in about 1% smaller text sections in kubernetes binaries,
and no regressions in the crypto benchmarks.
Change-Id: I9e0381944869c3774106bf348dead5ecb96dffda
Reviewed-on: https://go-review.googlesource.com/c/go/+/538636
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-10-24 16:04:42 -05:00
|
|
|
c := int64(x[12]) + 4
|
|
|
|
|
if c <= 0 {
|
|
|
|
|
x[12] = uint64(c)
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-27 16:03:11 -05:00
|
|
|
// ppc64x:"MULHDUCC",^"MULHDU"
|
|
|
|
|
hi, _ := bits.Mul64(x[13], x[14])
|
|
|
|
|
if hi != 0 {
|
|
|
|
|
x[14] = hi
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-27 12:15:04 -05:00
|
|
|
}
|
2024-07-11 19:38:33 -07:00
|
|
|
|
|
|
|
|
func constantWrite(b bool, p *bool) {
|
|
|
|
|
if b {
|
2025-10-26 22:51:14 -04:00
|
|
|
// amd64:`MOVB [$]1, \(`
|
2024-07-11 19:38:33 -07:00
|
|
|
*p = b
|
|
|
|
|
}
|
|
|
|
|
}
|