mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero
compilecmp linux/amd64: math/bits math/bits.Div32 122 -> 121 (-0.82%) math/bits.Rem32 39 -> 38 (-2.56%) math/bits [cmd/compile] math/bits.Rem32 39 -> 38 (-2.56%) math/bits.Div32 122 -> 121 (-0.82%) runtime runtime.funcMaxSPDelta 296 -> 294 (-0.68%) runtime.dumpGCProg 677 -> 666 (-1.62%) runtime.(*itabTableType).find 66 -> 65 (-1.52%) runtime.(*itabTableType).add 71 -> 70 (-1.41%) runtime.funpack32 122 -> 121 (-0.82%) vendor/golang.org/x/net/dns/dnsmessage vendor/golang.org/x/net/dns/dnsmessage.(*Message).pack 211 -> 200 (-5.21%) vendor/golang.org/x/net/dns/dnsmessage.(*Header).pack 163 -> 161 (-1.23%) vendor/golang.org/x/net/dns/dnsmessage.NewBuilder 589 -> 581 (-1.36%) runtime [cmd/compile] runtime.dumpGCProg 677 -> 666 (-1.62%) runtime.funpack32 122 -> 121 (-0.82%) runtime.(*itabTableType).add 71 -> 70 (-1.41%) runtime.(*itabTableType).find 66 -> 65 (-1.52%) internal/types/errors internal/types/errors.Code.String 666 -> 634 (-4.80%) internal/types/errors [cmd/compile] internal/types/errors.Code.String 666 -> 634 (-4.80%) debug/gosym debug/gosym.(*LineTable).stringFrom 436 -> 435 (-0.23%) debug/dwarf debug/dwarf.Class.String 186 -> 175 (-5.91%) vendor/golang.org/x/text/unicode/norm vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).runeAt 181 -> 180 (-0.55%) vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).assignRune 222 -> 221 (-0.45%) debug/macho debug/macho.RelocTypeARM64.String 186 -> 175 (-5.91%) debug/macho.RelocTypeGeneric.String 186 -> 175 (-5.91%) debug/macho.RelocTypeX86_64.String 186 -> 175 (-5.91%) debug/macho.RelocTypeARM.String 186 -> 175 (-5.91%) internal/xcoff internal/xcoff.getString 173 -> 172 (-0.58%) debug/pe debug/pe.StringTable.String 278 -> 277 (-0.36%) math/big math/big.(*Int).Int64 35 -> 34 (-2.86%) math/big.(*Float).ord 57 -> 56 (-1.75%) math/big.Accuracy.String 219 -> 217 (-0.91%) math/big.(*Int).Cmp 153 -> 152 (-0.65%) go/constant go/constant.makeInt 155 -> 154 (-0.65%) archive/tar archive/tar.(*Reader).readHeader.func2 51 -> 50 (-1.96%) crypto/rsa crypto/rsa.VerifyPKCS1v15 1288 -> 1285 (-0.23%) crypto/rsa.decryptPKCS1v15 495 -> 493 (-0.40%) vendor/golang.org/x/net/idna vendor/golang.org/x/net/idna.(*Profile).simplify 114 -> 113 (-0.88%) vendor/golang.org/x/net/idna.validateFromPunycode 607 -> 591 (-2.64%) encoding/asn1 encoding/asn1.parseBitString 298 -> 297 (-0.34%) log/slog log/slog.TextHandler.attrSep 57 -> 56 (-1.75%) log/slog.(*handleState).appendKey 747 -> 746 (-0.13%) log/slog.JSONHandler.attrSep 57 -> 56 (-1.75%) log/slog.(*TextHandler).attrSep 59 -> 58 (-1.69%) log/slog.(*JSONHandler).attrSep 59 -> 58 (-1.69%) cmd/internal/objabi cmd/internal/objabi.SymKind.String 219 -> 207 (-5.48%) vendor/golang.org/x/crypto/cryptobyte vendor/golang.org/x/crypto/cryptobyte.(*String).readLengthPrefixed 315 -> 313 (-0.63%) cmd/internal/goobj cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215 (-0.46%) cmd/internal/goobj.(*Reader).BytesAt 96 -> 95 (-1.04%) html/template html/template.state.String 219 -> 207 (-5.48%) cmd/internal/obj cmd/internal/obj.AddrType.String 219 -> 207 (-5.48%) go/build go/build.(*Context).importGo 4511 -> 4505 (-0.13%) cmd/internal/gcprog cmd/internal/gcprog.progbits 569 -> 549 (-3.51%) cmd/compile/internal/base cmd/compile/internal/base.PkgLinksym 373 -> 367 (-1.61%) cmd/cgo main.(*Package).writeDefsFunc 6117 -> 6085 (-0.52%) cmd/compile/internal/types cmd/compile/internal/types.Kind.String 219 -> 207 (-5.48%) cmd/compile/internal/types.AlgKind.String 207 -> 201 (-2.90%) cmd/internal/gcprog [cmd/compile] cmd/internal/gcprog.progbits 569 -> 549 (-3.51%) crypto/tls crypto/tls.CurveID.String 273 -> 265 (-2.93%) cmd/internal/objabi [cmd/compile] cmd/internal/objabi.SymKind.String 219 -> 207 (-5.48%) cmd/internal/goobj [cmd/compile] cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215 (-0.46%) cmd/internal/goobj.(*Reader).BytesAt 96 -> 95 (-1.04%) math/big [cmd/compile] math/big.(*Float).ord 57 -> 56 (-1.75%) math/big.(*Int).Cmp 153 -> 152 (-0.65%) math/big.(*Int).Int64 35 -> 34 (-2.86%) math/big.Accuracy.String 219 -> 217 (-0.91%) go/constant [cmd/compile] go/constant.makeInt 155 -> 154 (-0.65%) cmd/internal/obj [cmd/compile] cmd/internal/obj.AddrType.String 219 -> 207 (-5.48%) cmd/link/internal/sym cmd/link/internal/sym.SymKind.String 219 -> 207 (-5.48%) cmd/compile/internal/base [cmd/compile] cmd/compile/internal/base.PkgLinksym 317 -> 315 (-0.63%) go/build [cmd/compile] go/build.(*Context).importGo 4511 -> 4505 (-0.13%) cmd/go/internal/script cmd/go/internal/script.(*Engine).ListCmds 1269 -> 1263 (-0.47%) cmd/go/internal/modindex cmd/go/internal/modindex.fromBytes 1206 -> 1199 (-0.58%) cmd/go/internal/modindex.(*decoder).boolAt 212 -> 201 (-5.19%) cmd/go/internal/modindex.(*reader).bool 229 -> 218 (-4.80%) cmd/link/internal/loader cmd/link/internal/loader.(*FuncInfo).File 142 -> 141 (-0.70%) cmd/compile/internal/types [cmd/compile] cmd/compile/internal/types.Kind.String 219 -> 207 (-5.48%) cmd/compile/internal/types.(*Sym).LinksymABI 333 -> 332 (-0.30%) cmd/compile/internal/types.AlgKind.String 207 -> 201 (-2.90%) cmd/link/internal/loadmacho cmd/link/internal/loadmacho.macholoadsym 1243 -> 1236 (-0.56%) cmd/vendor/golang.org/x/sys/unix cmd/vendor/golang.org/x/sys/unix.(*FileHandle).Bytes 80 -> 79 (-1.25%) cmd/vendor/golang.org/x/sys/unix.Mkdev 54 -> 52 (-3.70%) cmd/go/internal/work cmd/go/internal/work.(*Builder).printLinkerConfig 1865 -> 1864 (-0.05%) cmd/go/internal/run cmd/go/internal/run.runRun 3197 -> 3182 (-0.47%) cmd/compile/internal/ssa [cmd/compile] cmd/compile/internal/ssa.rewriteValueAMD64 21221 -> 19514 (-8.04%) file before after Δ % math/bits.s 2373 2371 -2 -0.084% math/bits [cmd/compile].s 2373 2371 -2 -0.084% runtime.s 520472 520467 -5 -0.001% vendor/golang.org/x/net/dns/dnsmessage.s 74378 74357 -21 -0.028% runtime [cmd/compile].s 582206 582203 -3 -0.001% internal/types/errors.s 750 718 -32 -4.267% internal/types/errors [cmd/compile].s 750 718 -32 -4.267% debug/gosym.s 34742 34741 -1 -0.003% debug/dwarf.s 113249 113238 -11 -0.010% vendor/golang.org/x/text/unicode/norm.s 62802 62800 -2 -0.003% debug/macho.s 29021 28977 -44 -0.152% internal/xcoff.s 17911 17910 -1 -0.006% debug/pe.s 23421 23420 -1 -0.004% math/big.s 163522 163517 -5 -0.003% go/constant.s 28512 28511 -1 -0.004% archive/tar.s 58377 58376 -1 -0.002% crypto/rsa.s 26261 26256 -5 -0.019% vendor/golang.org/x/net/idna.s 21342 21325 -17 -0.080% encoding/asn1.s 45357 45356 -1 -0.002% log/slog.s 78618 78613 -5 -0.006% cmd/internal/objabi.s 15878 15866 -12 -0.076% vendor/golang.org/x/crypto/cryptobyte.s 30577 30575 -2 -0.007% cmd/internal/goobj.s 11515 11513 -2 -0.017% html/template.s 87816 87804 -12 -0.014% cmd/internal/obj.s 124786 124774 -12 -0.010% go/build.s 67665 67659 -6 -0.009% cmd/internal/gcprog.s 5856 5836 -20 -0.342% cmd/compile/internal/base.s 41802 41796 -6 -0.014% cmd/internal/obj/arm64.s 144141 144172 +31 +0.022% cmd/cgo.s 197681 197649 -32 -0.016% cmd/compile/internal/types.s 62811 62793 -18 -0.029% cmd/internal/gcprog [cmd/compile].s 5856 5836 -20 -0.342% crypto/tls.s 318862 318854 -8 -0.003% cmd/internal/objabi [cmd/compile].s 15887 15875 -12 -0.076% cmd/internal/goobj [cmd/compile].s 11596 11594 -2 -0.017% math/big [cmd/compile].s 165178 165173 -5 -0.003% go/constant [cmd/compile].s 29743 29742 -1 -0.003% cmd/internal/obj [cmd/compile].s 165646 165634 -12 -0.007% cmd/link/internal/sym.s 1829 1817 -12 -0.656% cmd/compile/internal/base [cmd/compile].s 41937 41935 -2 -0.005% go/build [cmd/compile].s 67601 67595 -6 -0.009% cmd/go/internal/script.s 79959 79953 -6 -0.008% cmd/go/internal/modindex.s 85936 85907 -29 -0.034% cmd/internal/obj/arm64 [cmd/compile].s 144090 144121 +31 +0.022% cmd/link/internal/loader.s 77864 77863 -1 -0.001% cmd/compile/internal/types [cmd/compile].s 76072 76053 -19 -0.025% cmd/link/internal/loadmacho.s 20367 20360 -7 -0.034% cmd/vendor/golang.org/x/sys/unix.s 118027 118024 -3 -0.003% cmd/go/internal/work.s 285265 285264 -1 -0.000% cmd/go/internal/run.s 4758 4743 -15 -0.315% cmd/compile/internal/ssa.s 3191919 3192241 +322 +0.010% cmd/compile/internal/ssa [cmd/compile].s 3362994 3361609 -1385 -0.041% total 30756856 30755380 -1476 -0.005% Change-Id: Ia259c87216af6ff67efe33c7d39f3dbde7f37a43 Reviewed-on: https://go-review.googlesource.com/c/go/+/522975 Auto-Submit: Keith Randall <khr@golang.org> Run-TryBot: Jakub Ciolek <jakub@ciolek.dev> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org>
This commit is contained in:
parent
0d69747d91
commit
c1dfbf72e1
|
@ -1449,6 +1449,10 @@
|
|||
(TESTW (MOVLconst [c]) x) => (TESTWconst [int16(c)] x)
|
||||
(TESTB (MOVLconst [c]) x) => (TESTBconst [int8(c)] x)
|
||||
|
||||
// shorten bitwise AND/TESTQ if upper 32 bits are known to be zero.
|
||||
(ANDQ x y) && (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) => (ANDL x y)
|
||||
(TESTQ x y) && (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) => (TESTL x y)
|
||||
|
||||
// TEST %reg,%reg is shorter than CMP
|
||||
(CMPQconst x [0]) => (TESTQ x x)
|
||||
(CMPLconst x [0]) => (TESTL x x)
|
||||
|
|
|
@ -3094,6 +3094,22 @@ func rewriteValueAMD64_OpAMD64ANDQ(v *Value) bool {
|
|||
v.copyOf(x)
|
||||
return true
|
||||
}
|
||||
// match: (ANDQ x y)
|
||||
// cond: (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3))
|
||||
// result: (ANDL x y)
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
x := v_0
|
||||
y := v_1
|
||||
if !(zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) {
|
||||
continue
|
||||
}
|
||||
v.reset(OpAMD64ANDL)
|
||||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (ANDQ x l:(MOVQload [off] {sym} ptr mem))
|
||||
// cond: canMergeLoadClobber(v, l, x) && clobber(l)
|
||||
// result: (ANDQload x [off] {sym} ptr mem)
|
||||
|
@ -22702,6 +22718,22 @@ func rewriteValueAMD64_OpAMD64TESTQ(v *Value) bool {
|
|||
}
|
||||
break
|
||||
}
|
||||
// match: (TESTQ x y)
|
||||
// cond: (zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3))
|
||||
// result: (TESTL x y)
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
x := v_0
|
||||
y := v_1
|
||||
if !(zeroUpper32Bits(x, 3) || zeroUpper32Bits(y, 3)) {
|
||||
continue
|
||||
}
|
||||
v.reset(OpAMD64TESTL)
|
||||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (TESTQ l:(MOVQload {sym} [off] ptr mem) l2)
|
||||
// cond: l == l2 && l.Uses == 2 && clobber(l)
|
||||
// result: @l.Block (CMPQconstload {sym} [makeValAndOff(0, off)] ptr mem)
|
||||
|
|
Loading…
Reference in a new issue