mirror of
https://github.com/golang/go
synced 2025-05-30 15:30:51 +00:00
cmd/compile: generate subfic on ppc64
This merges an lis + subf into subfic, and for 32b constants lwa + subf into oris + ori + subf. The carry bit is no longer used in code generation, therefore I think we can clobber it as needed. Note, lowered borrow/carry arithmetic is self-contained and thus is not affected. A few extra rules are added to ensure early transformations to SUBFCconst don't trip up earlier rules, fold constant operations, or otherwise simplify lowering. Likewise, tests are added to ensure all rules are hit. Generic constant folding catches trivial cases, however some lowering rules insert arithmetic which can introduce new opportunities (e.g BitLen or Slicemask). I couldn't find a specific benchmark to demonstrate noteworthy improvements, but this is generating subfic in many of the default bent test binaries, so we are at least saving a little code space. Change-Id: Iad7c6e5767eaa9dc24dc1c989bd1c8cfe1982012 Reviewed-on: https://go-review.googlesource.com/c/go/+/249461 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
This commit is contained in:
committed by
Lynn Boger
parent
2013f70256
commit
7615b20d06
src/cmd/compile/internal
test/codegen
@ -347,3 +347,24 @@ func InitNotSmallSliceLiteral() []int {
|
||||
42,
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------- //
|
||||
// Test PPC64 SUBFCconst folding rules //
|
||||
// triggered by slice operations. //
|
||||
// --------------------------------------- //
|
||||
|
||||
func SliceWithConstCompare(a []int, b int) []int {
|
||||
var c []int = []int{1, 2, 3, 4, 5}
|
||||
if b+len(a) < len(c) {
|
||||
// ppc64le:-"NEG"
|
||||
// ppc64:-"NEG"
|
||||
return c[b:]
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func SliceWithSubtractBound(a []int, b int) []int {
|
||||
// ppc64le:"SUBC",-"NEG"
|
||||
// ppc64:"SUBC",-"NEG"
|
||||
return a[(3 - b):]
|
||||
}
|
||||
|
Reference in New Issue
Block a user