Skip to content

Commit b1e933d

Browse files
sophie-zhaoabner-chenc
authored andcommitted
cmd/compile: avoid extending when already sufficiently masked on loong64
Reduce the number of go toolchain instructions on loong64 as follows. file before after Δ % asm 562400 561348 -1052 -0.1871% cgo 488268 487932 -336 -0.0688% compile 2505750 2503710 -2040 -0.0814% cover 525874 525506 -368 -0.0700% link 714162 713562 -600 -0.0840% preprofile 240250 240054 -196 -0.0816% vet 794074 793742 -332 -0.0418% go 1598284 1597680 -604 -0.0378% gofmt 324126 323926 -200 -0.0617% total 7753188 7747460 -5728 -0.0739% Change-Id: I3406113553b0fc4947d763ab66e57e69aa98c020 Reviewed-on: https://go-review.googlesource.com/c/go/+/683615 Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Mark Freeman <[email protected]>
1 parent 880ca33 commit b1e933d

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

src/cmd/compile/internal/ssa/_gen/LOONG64.rules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,14 @@
843843

844844
(MOVBUreg (ANDconst [c] x)) => (ANDconst [c&0xff] x)
845845

846+
// Avoid extending when already sufficiently masked.
847+
(MOVBreg x:(ANDconst [c] y)) && c >= 0 && int64(int8(c)) == c => x
848+
(MOVHreg x:(ANDconst [c] y)) && c >= 0 && int64(int16(c)) == c => x
849+
(MOVWreg x:(ANDconst [c] y)) && c >= 0 && int64(int32(c)) == c => x
850+
(MOVBUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint8(c)) == c => x
851+
(MOVHUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint16(c)) == c => x
852+
(MOVWUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint32(c)) == c => x
853+
846854
// Prefetch instructions (hint specified using aux field)
847855
// For PRELD{,X} A value of hint indicates:
848856
// hint=0 is defined as load prefetch to L1-cache

src/cmd/compile/internal/ssa/rewriteLOONG64.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)