aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>2025-08-15 16:19:01 +0800
committerGopher Robot <gobot@golang.org>2025-08-21 11:19:34 -0700
commit9632ba8160dd93107af3577334bcadfe40068e42 (patch)
treef90ac24a9c13f3551399ceb0f49dd051180174ff /test/codegen
parent8dcab6f4505d198b5609182b4b5928bd190b21a8 (diff)
downloadgo-9632ba8160dd93107af3577334bcadfe40068e42.tar.xz
cmd/compile: optimize some patterns into revb2h/revb4h instruction on loong64
Pattern1: (the type of c is uint16) c>>8 | c<<8 To: revb2h c Pattern2: (the type of c is uint32) (c & 0xff00ff00)>>8 | (c & 0x00ff00ff)<<8 To: revb2h c Pattern3: (the type of c is uint64) (c & 0xff00ff00ff00ff00)>>8 | (c & 0x00ff00ff00ff00ff)<<8 To: revb4h c Change-Id: Ic6231a3f476cbacbea4bd00e31193d107cb86cda Reviewed-on: https://go-review.googlesource.com/c/go/+/696335 Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/bitfield.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/codegen/bitfield.go b/test/codegen/bitfield.go
index 44cf09f86f..6374d70650 100644
--- a/test/codegen/bitfield.go
+++ b/test/codegen/bitfield.go
@@ -338,20 +338,26 @@ func shift_no_cmp(x int) int {
func rev16(c uint64) (uint64, uint64, uint64) {
// arm64:`REV16`,-`AND`,-`LSR`,-`AND`,-`ORR\tR[0-9]+<<8`
+ // loong64:`REVB4H`,-`MOVV`,-`AND`,-`SRLV`,-`AND`,-`SLLV`,-`OR`
b1 := ((c & 0xff00ff00ff00ff00) >> 8) | ((c & 0x00ff00ff00ff00ff) << 8)
// arm64:-`ADD\tR[0-9]+<<8`
+ // loong64:-`ADDV`
b2 := ((c & 0xff00ff00ff00ff00) >> 8) + ((c & 0x00ff00ff00ff00ff) << 8)
// arm64:-`EOR\tR[0-9]+<<8`
+ // loong64:-`XOR`
b3 := ((c & 0xff00ff00ff00ff00) >> 8) ^ ((c & 0x00ff00ff00ff00ff) << 8)
return b1, b2, b3
}
func rev16w(c uint32) (uint32, uint32, uint32) {
// arm64:`REV16W`,-`AND`,-`UBFX`,-`AND`,-`ORR\tR[0-9]+<<8`
+ // loong64:`REVB2H`,-`AND`,-`SRL`,-`AND`,-`SLL`,-`OR`
b1 := ((c & 0xff00ff00) >> 8) | ((c & 0x00ff00ff) << 8)
// arm64:-`ADD\tR[0-9]+<<8`
+ // loong64:-`ADDV`
b2 := ((c & 0xff00ff00) >> 8) + ((c & 0x00ff00ff) << 8)
// arm64:-`EOR\tR[0-9]+<<8`
+ // loong64:-`XOR`
b3 := ((c & 0xff00ff00) >> 8) ^ ((c & 0x00ff00ff) << 8)
return b1, b2, b3
}