diff options
author | Austin Clements <austin@google.com> | 2018-01-11 16:50:09 -0500 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-03-08 22:25:29 +0000 |
commit | da022da900e3c52750894458067136ec799d5c12 (patch) | |
tree | 2edde3c03b395c512b88b1e7c00769653e1434b9 /src/cmd/compile/internal/ssa/prove.go | |
parent | 6436270dadb232e3ef1afc0d4cf714bcb9434910 (diff) | |
download | go-da022da900e3c52750894458067136ec799d5c12.tar.gz go-da022da900e3c52750894458067136ec799d5c12.zip |
cmd/compile: simplify OpSlicemask optimization
The previous CL introduced isConstDelta. Use it to simplify the
OpSlicemask optimization in the prove pass. This passes toolstash
-cmp.
Change-Id: If2aa762db4cdc0cd1c581a536340530a9831081b
Reviewed-on: https://go-review.googlesource.com/87481
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/prove.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/prove.go | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index f723ea5e90..d90f0cad33 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -748,19 +748,8 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) { if v.Op != OpSlicemask { continue } - add := v.Args[0] - if add.Op != OpAdd64 && add.Op != OpAdd32 { - continue - } - // Note that the arg of slicemask was originally a sub, but - // was rewritten to an add by generic.rules (if the thing - // being subtracted was a constant). - x := add.Args[0] - y := add.Args[1] - if x.Op == OpConst64 || x.Op == OpConst32 { - x, y = y, x - } - if y.Op != OpConst64 && y.Op != OpConst32 { + x, delta := isConstDelta(v.Args[0]) + if x == nil { continue } // slicemask(x + y) @@ -769,7 +758,7 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) { if !ok { continue } - if lim.umin > uint64(-y.AuxInt) { + if lim.umin > uint64(-delta) { if v.Args[0].Op == OpAdd64 { v.reset(OpConst64) } else { |