Skip to content

Commit afe5175

Browse files
committed
cmd/compile: loads from readonly globals into const for mips64x
Ref: CL 141118 Update #26498 Change-Id: If4ea55c080b9aa10183eefe81fefbd4072deaf3a Reviewed-on: https://go-review.googlesource.com/c/go/+/280646 Trust: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
1 parent 600259b commit afe5175

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

src/cmd/compile/internal/ssa/gen/MIPS64.rules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,9 @@
681681
(GTZ (MOVVconst [c]) yes no) && c <= 0 => (First no yes)
682682
(GEZ (MOVVconst [c]) yes no) && c >= 0 => (First yes no)
683683
(GEZ (MOVVconst [c]) yes no) && c < 0 => (First no yes)
684+
685+
// fold readonly sym load
686+
(MOVBload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read8(sym, int64(off)))])
687+
(MOVHload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))])
688+
(MOVWload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))])
689+
(MOVVload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))])

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

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

test/codegen/strings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func ConstantLoad() {
3030
// arm:`MOVW\t\$48`,`MOVW\t\$49`,`MOVW\t\$50`
3131
// arm64:`MOVD\t\$12592`,`MOVD\t\$50`
3232
// wasm:`I64Const\t\$12592`,`I64Store16\t\$0`,`I64Const\t\$50`,`I64Store8\t\$2`
33+
// mips64:`MOVV\t\$48`,`MOVV\t\$49`,`MOVV\t\$50`
3334
bsink = []byte("012")
3435

3536
// 858927408 = 0x33323130

0 commit comments

Comments
 (0)