mirror of https://github.com/golang/go.git
cmd/compile/internal/ssagen: use an alias for math/bits.Len
Rather than using a specific intrinsic for math/bits.Len, use a pair of aliases instead. This requires less code and automatically adapts when platforms have a math/bits.Len32 or math/bits.Len64 intrinsic. Change-Id: I28b300172daaee26ef82a7530d9e96123663f541 Reviewed-on: https://go-review.googlesource.com/c/go/+/656995 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
This commit is contained in:
parent
a812e5f3c3
commit
7e8ceadf85
|
|
@ -938,14 +938,9 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
|
|||
return s.newValue1(ssa.OpBitLen8, types.Types[types.TINT], args[0])
|
||||
},
|
||||
sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm)
|
||||
addF("math/bits", "Len",
|
||||
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
|
||||
if s.config.PtrSize == 4 {
|
||||
return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0])
|
||||
}
|
||||
return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], args[0])
|
||||
},
|
||||
sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm)
|
||||
alias("math/bits", "Len", "math/bits", "Len64", p8...)
|
||||
alias("math/bits", "Len", "math/bits", "Len32", p4...)
|
||||
|
||||
// LeadingZeros is handled because it trivially calls Len.
|
||||
addF("math/bits", "Reverse64",
|
||||
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
|
||||
|
|
|
|||
Loading…
Reference in New Issue