mirror of
https://github.com/golang/go.git
synced 2025-11-01 17:20:56 +00:00
cmd/compile: avoid ANDCCconst on PPC64 if condition not needed
In the PPC64 ISA, the instruction to do an 'and' operation using an immediate constant is only available in the form that also sets CR0 (i.e. clobbers the condition register.) This means CR0 is being clobbered unnecessarily in many cases. That affects some decisions made during some compiler passes that check for it. In those cases when the constant used by the ANDCC is a right justified consecutive set of bits, a shift instruction can be used which has the same effect if CR0 does not need to be set. The rule to do that has been added to the late rules file after other rules using ANDCCconst have been processed in the main rules file. Some codegen tests had to be updated since ANDCC is no longer generated for some cases. A new test case was added to verify the ANDCC is present if the results for both the AND and CR0 are used. Change-Id: I304f607c039a458e2d67d25351dd00aea72ba542 Reviewed-on: https://go-review.googlesource.com/c/go/+/531435 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Paul Murphy <murp@ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
144252d2e6
commit
80834af206
7 changed files with 120 additions and 249 deletions
|
|
@ -70,7 +70,7 @@ func rshConst64x32(v int64) int64 {
|
|||
|
||||
func lshMask64x64(v int64, s uint64) int64 {
|
||||
// arm64:"LSL",-"AND"
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SLL",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v << (s & 63)
|
||||
|
|
@ -78,7 +78,7 @@ func lshMask64x64(v int64, s uint64) int64 {
|
|||
|
||||
func rshMask64Ux64(v uint64, s uint64) uint64 {
|
||||
// arm64:"LSR",-"AND",-"CSEL"
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SRL\t",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> (s & 63)
|
||||
|
|
@ -86,7 +86,7 @@ func rshMask64Ux64(v uint64, s uint64) uint64 {
|
|||
|
||||
func rshMask64x64(v int64, s uint64) int64 {
|
||||
// arm64:"ASR",-"AND",-"CSEL"
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SRA",-"OR",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> (s & 63)
|
||||
|
|
@ -123,7 +123,7 @@ func rshMask32x64(v int32, s uint64) int32 {
|
|||
|
||||
func lshMask64x32(v int64, s uint32) int64 {
|
||||
// arm64:"LSL",-"AND"
|
||||
// ppc64x:"ANDCC",-"ORN"
|
||||
// ppc64x:"RLDICL",-"ORN"
|
||||
// riscv64:"SLL",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v << (s & 63)
|
||||
|
|
@ -131,7 +131,7 @@ func lshMask64x32(v int64, s uint32) int64 {
|
|||
|
||||
func rshMask64Ux32(v uint64, s uint32) uint64 {
|
||||
// arm64:"LSR",-"AND",-"CSEL"
|
||||
// ppc64x:"ANDCC",-"ORN"
|
||||
// ppc64x:"RLDICL",-"ORN"
|
||||
// riscv64:"SRL\t",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> (s & 63)
|
||||
|
|
@ -139,28 +139,28 @@ func rshMask64Ux32(v uint64, s uint32) uint64 {
|
|||
|
||||
func rshMask64x32(v int64, s uint32) int64 {
|
||||
// arm64:"ASR",-"AND",-"CSEL"
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SRA",-"OR",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> (s & 63)
|
||||
}
|
||||
|
||||
func lshMask64x32Ext(v int64, s int32) int64 {
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SLL",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v << uint(s&63)
|
||||
}
|
||||
|
||||
func rshMask64Ux32Ext(v uint64, s int32) uint64 {
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SRL\t",-"AND\t",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> uint(s&63)
|
||||
}
|
||||
|
||||
func rshMask64x32Ext(v int64, s int32) int64 {
|
||||
// ppc64x:"ANDCC",-"ORN",-"ISEL"
|
||||
// ppc64x:"RLDICL",-"ORN",-"ISEL"
|
||||
// riscv64:"SRA",-"OR",-"SLTIU"
|
||||
// s390x:-"RISBGZ",-"AND",-"LOCGR"
|
||||
return v >> uint(s&63)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue