aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewritedec64.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2017-03-14 13:25:12 -0700
committerKeith Randall <khr@golang.org>2017-03-16 02:44:16 +0000
commitd5dc4905191c3f7cfeb52e93331d10ebd33301f5 (patch)
treeefbe9f8a06b01b0510d8a09fa4edcc4f2c6fb133 /src/cmd/compile/internal/ssa/rewritedec64.go
parent16200c73331a679b43efc4699b5806c64a556f09 (diff)
downloadgo-d5dc4905191c3f7cfeb52e93331d10ebd33301f5.tar.gz
go-d5dc4905191c3f7cfeb52e93331d10ebd33301f5.zip
cmd/compile: intrinsics for math/bits.TrailingZerosX
Implement math/bits.TrailingZerosX using intrinsics. Generally reorganize the intrinsic spec a bit. The instrinsics data structure is now built at init time. This will make doing the other functions in math/bits easier. Update sys.CtzX to return int instead of uint{64,32} so it matches math/bits.TrailingZerosX. Improve the intrinsics a bit for amd64. We don't need the CMOV for <64 bit versions. Update #18616 Change-Id: Ic1c5339c943f961d830ae56f12674d7b29d4ff39 Reviewed-on: https://go-review.googlesource.com/38155 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewritedec64.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewritedec64.go40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/cmd/compile/internal/ssa/rewritedec64.go b/src/cmd/compile/internal/ssa/rewritedec64.go
index 8d2f0d60ad..d04676fadb 100644
--- a/src/cmd/compile/internal/ssa/rewritedec64.go
+++ b/src/cmd/compile/internal/ssa/rewritedec64.go
@@ -368,34 +368,30 @@ func rewriteValuedec64_OpCtz64(v *Value, config *Config) bool {
_ = b
// match: (Ctz64 x)
// cond:
- // result: (Int64Make (Const32 <config.fe.TypeUInt32()> [0]) (Add32 <config.fe.TypeUInt32()> (Ctz32 <config.fe.TypeUInt32()> (Int64Lo x)) (And32 <config.fe.TypeUInt32()> (Com32 <config.fe.TypeUInt32()> (Zeromask (Int64Lo x))) (Ctz32 <config.fe.TypeUInt32()> (Int64Hi x)))))
+ // result: (Add32 <config.fe.TypeUInt32()> (Ctz32 <config.fe.TypeUInt32()> (Int64Lo x)) (And32 <config.fe.TypeUInt32()> (Com32 <config.fe.TypeUInt32()> (Zeromask (Int64Lo x))) (Ctz32 <config.fe.TypeUInt32()> (Int64Hi x))))
for {
x := v.Args[0]
- v.reset(OpInt64Make)
- v0 := b.NewValue0(v.Pos, OpConst32, config.fe.TypeUInt32())
- v0.AuxInt = 0
+ v.reset(OpAdd32)
+ v.Type = config.fe.TypeUInt32()
+ v0 := b.NewValue0(v.Pos, OpCtz32, config.fe.TypeUInt32())
+ v1 := b.NewValue0(v.Pos, OpInt64Lo, config.fe.TypeUInt32())
+ v1.AddArg(x)
+ v0.AddArg(v1)
v.AddArg(v0)
- v1 := b.NewValue0(v.Pos, OpAdd32, config.fe.TypeUInt32())
- v2 := b.NewValue0(v.Pos, OpCtz32, config.fe.TypeUInt32())
- v3 := b.NewValue0(v.Pos, OpInt64Lo, config.fe.TypeUInt32())
- v3.AddArg(x)
+ v2 := b.NewValue0(v.Pos, OpAnd32, config.fe.TypeUInt32())
+ v3 := b.NewValue0(v.Pos, OpCom32, config.fe.TypeUInt32())
+ v4 := b.NewValue0(v.Pos, OpZeromask, config.fe.TypeUInt32())
+ v5 := b.NewValue0(v.Pos, OpInt64Lo, config.fe.TypeUInt32())
+ v5.AddArg(x)
+ v4.AddArg(v5)
+ v3.AddArg(v4)
v2.AddArg(v3)
- v1.AddArg(v2)
- v4 := b.NewValue0(v.Pos, OpAnd32, config.fe.TypeUInt32())
- v5 := b.NewValue0(v.Pos, OpCom32, config.fe.TypeUInt32())
- v6 := b.NewValue0(v.Pos, OpZeromask, config.fe.TypeUInt32())
- v7 := b.NewValue0(v.Pos, OpInt64Lo, config.fe.TypeUInt32())
+ v6 := b.NewValue0(v.Pos, OpCtz32, config.fe.TypeUInt32())
+ v7 := b.NewValue0(v.Pos, OpInt64Hi, config.fe.TypeUInt32())
v7.AddArg(x)
v6.AddArg(v7)
- v5.AddArg(v6)
- v4.AddArg(v5)
- v8 := b.NewValue0(v.Pos, OpCtz32, config.fe.TypeUInt32())
- v9 := b.NewValue0(v.Pos, OpInt64Hi, config.fe.TypeUInt32())
- v9.AddArg(x)
- v8.AddArg(v9)
- v4.AddArg(v8)
- v1.AddArg(v4)
- v.AddArg(v1)
+ v2.AddArg(v6)
+ v.AddArg(v2)
return true
}
}