]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: support -buildmode=c-shared on linux/mips64{,le}
authorXiaodong Liu <liuxiaodong@loongson.cn>
Thu, 9 Sep 2021 08:07:38 +0000 (16:07 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 21 Apr 2023 23:06:11 +0000 (23:06 +0000)
The modification of these rules is optimization to load/store global
variables. If there are a sequence of loads/stores nearby a global
variable address, the address can only be loaded from GOT once instead
of every time.

For #43264

Change-Id: Idedaf6c81f085955371320f51bca148ffb42a2d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/348732
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/liveness/plive.go
src/cmd/compile/internal/ssa/_gen/MIPS64.rules
src/cmd/compile/internal/ssa/rewriteMIPS64.go

index f7f260d8d08221758b1559025b45d6a4519ab993..5b3ff8b7ee1a9d1a288f9bf97852452c532ae98b 100644 (file)
@@ -255,7 +255,7 @@ func ParseFlags() {
        if Flag.Race && !platform.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) {
                log.Fatalf("%s/%s does not support -race", buildcfg.GOOS, buildcfg.GOARCH)
        }
-       if (*Flag.Shared || *Flag.Dynlink || *Flag.LinkShared) && !Ctxt.Arch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X) {
+       if (*Flag.Shared || *Flag.Dynlink || *Flag.LinkShared) && !Ctxt.Arch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) {
                log.Fatalf("%s/%s does not support -shared", buildcfg.GOOS, buildcfg.GOARCH)
        }
        parseSpectre(Flag.Spectre) // left as string for RecordFlags
index 3314db458ee116edea41e92dcbc79aa85ac2589c..169467e6f5a333944fada0ea12626492d15b98be 100644 (file)
@@ -546,7 +546,7 @@ func (lv *liveness) markUnsafePoints() {
                                                v = v.Args[0]
                                                continue
                                        }
-                               case ssa.Op386MOVLload, ssa.OpARM64MOVWUload, ssa.OpPPC64MOVWZload, ssa.OpWasmI64Load32U:
+                               case ssa.Op386MOVLload, ssa.OpARM64MOVWUload, ssa.OpMIPS64MOVWUload, ssa.OpPPC64MOVWZload, ssa.OpWasmI64Load32U:
                                        // Args[0] is the address of the write
                                        // barrier control. Ignore Args[1],
                                        // which is the mem operand.
index 0c14d503f64501119410bce702a51b48283cf966..2144a21352b10b6900bdc4087f4c5fe8831450b3 100644 (file)
 (ADDVconst [off1] (MOVVaddr [off2] {sym} ptr)) && is32Bit(off1+int64(off2)) => (MOVVaddr [int32(off1)+int32(off2)] {sym} ptr)
 
 // fold address into load/store
-(MOVBload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVBload  [off1+int32(off2)] {sym} ptr mem)
-(MOVBUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVBUload [off1+int32(off2)] {sym} ptr mem)
-(MOVHload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVHload  [off1+int32(off2)] {sym} ptr mem)
-(MOVHUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVHUload [off1+int32(off2)] {sym} ptr mem)
-(MOVWload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVWload  [off1+int32(off2)] {sym} ptr mem)
-(MOVWUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVWUload [off1+int32(off2)] {sym} ptr mem)
-(MOVVload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVVload  [off1+int32(off2)] {sym} ptr mem)
-(MOVFload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVFload  [off1+int32(off2)] {sym} ptr mem)
-(MOVDload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVDload  [off1+int32(off2)] {sym} ptr mem)
-
-(MOVBstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVBstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVHstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVHstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVWstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVWstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVVstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVVstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVFstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVFstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVDstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) => (MOVDstore [off1+int32(off2)] {sym} ptr val mem)
-(MOVBstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVBstorezero [off1+int32(off2)] {sym} ptr mem)
-(MOVHstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVHstorezero [off1+int32(off2)] {sym} ptr mem)
-(MOVWstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVWstorezero [off1+int32(off2)] {sym} ptr mem)
-(MOVVstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) => (MOVVstorezero [off1+int32(off2)] {sym} ptr mem)
-
-(MOVBload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVBload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVBload  [off1+int32(off2)] {sym} ptr mem)
+(MOVBUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVBUload [off1+int32(off2)] {sym} ptr mem)
+(MOVHload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVHload  [off1+int32(off2)] {sym} ptr mem)
+(MOVHUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVHUload [off1+int32(off2)] {sym} ptr mem)
+(MOVWload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVWload  [off1+int32(off2)] {sym} ptr mem)
+(MOVWUload [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVWUload [off1+int32(off2)] {sym} ptr mem)
+(MOVVload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVVload  [off1+int32(off2)] {sym} ptr mem)
+(MOVFload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVFload  [off1+int32(off2)] {sym} ptr mem)
+(MOVDload  [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVDload  [off1+int32(off2)] {sym} ptr mem)
+
+(MOVBstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVBstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVHstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVHstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVWstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVWstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVVstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVVstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVFstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVFstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVDstore [off1] {sym} (ADDVconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVDstore [off1+int32(off2)] {sym} ptr val mem)
+(MOVBstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVBstorezero [off1+int32(off2)] {sym} ptr mem)
+(MOVHstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVHstorezero [off1+int32(off2)] {sym} ptr mem)
+(MOVWstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVWstorezero [off1+int32(off2)] {sym} ptr mem)
+(MOVVstorezero [off1] {sym} (ADDVconst [off2] ptr) mem) && is32Bit(int64(off1)+off2)
+        && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => (MOVVstorezero [off1+int32(off2)] {sym} ptr mem)
+
+(MOVBload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVBload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVBUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVBUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVBUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVHload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVHload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVHload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVHUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVHUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVHUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVWload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVWload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVWload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVWUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVWUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVWUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVVload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVVload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVVload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVFload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVFload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVFload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVDload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVDload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVDload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
 
-(MOVBstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVBstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVBstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVHstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVHstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVHstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVWstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVWstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVWstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVVstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVVstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+               && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVVstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVFstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVFstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVFstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVDstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVDstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVDstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
-(MOVBstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVBstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVBstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVHstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVHstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVHstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVWstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVWstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVWstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
-(MOVVstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) =>
+(MOVVstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
+       && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       && (ptr.Op != OpSB || !config.ctxt.Flag_shared) =>
        (MOVVstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
 
 // store zero
 (MOVBload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read8(sym, int64(off)))])
 (MOVHload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))])
 (MOVWload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))])
-(MOVVload  [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))])
+(MOVVload [off] {sym} (SB) _) && symIsRO(sym) => (MOVVconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))])
index 3d1ec08ada2eb15a40e778dbf5a4121a0a57b6d9..095d93a033d2081f40d2e46baa5c98d563f1e258 100644 (file)
@@ -2590,8 +2590,10 @@ func rewriteValueMIPS64_OpMIPS64LoweredAtomicStore64(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVBUload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVBUload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBUload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2602,7 +2604,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBUload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBUload)
@@ -2612,7 +2614,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBUload(v *Value) bool {
                return true
        }
        // match: (MOVBUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2624,7 +2626,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBUload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBUload)
@@ -2675,8 +2677,10 @@ func rewriteValueMIPS64_OpMIPS64MOVBUreg(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVBload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVBload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2687,7 +2691,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBload)
@@ -2697,7 +2701,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBload(v *Value) bool {
                return true
        }
        // match: (MOVBload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2709,7 +2713,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBload)
@@ -2774,8 +2778,10 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVBstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2787,7 +2793,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBstore)
@@ -2797,7 +2803,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
                return true
        }
        // match: (MOVBstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2810,7 +2816,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBstore)
@@ -2942,8 +2948,10 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVBstorezero(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVBstorezero [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBstorezero [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2954,7 +2962,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstorezero(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBstorezero)
@@ -2964,7 +2972,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstorezero(v *Value) bool {
                return true
        }
        // match: (MOVBstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVBstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -2976,7 +2984,7 @@ func rewriteValueMIPS64_OpMIPS64MOVBstorezero(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVBstorezero)
@@ -2990,8 +2998,10 @@ func rewriteValueMIPS64_OpMIPS64MOVBstorezero(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVDload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVDload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3002,7 +3012,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVDload)
@@ -3012,7 +3022,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool {
                return true
        }
        // match: (MOVDload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVDload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3024,7 +3034,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVDload)
@@ -3039,8 +3049,10 @@ func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVDstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVDstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3052,7 +3064,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVDstore)
@@ -3062,7 +3074,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool {
                return true
        }
        // match: (MOVDstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVDstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3075,7 +3087,7 @@ func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVDstore)
@@ -3089,8 +3101,10 @@ func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVFload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVFload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVFload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3101,7 +3115,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVFload)
@@ -3111,7 +3125,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFload(v *Value) bool {
                return true
        }
        // match: (MOVFload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVFload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3123,7 +3137,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVFload)
@@ -3138,8 +3152,10 @@ func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVFstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVFstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3151,7 +3167,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVFstore)
@@ -3161,7 +3177,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool {
                return true
        }
        // match: (MOVFstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVFstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3174,7 +3190,7 @@ func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVFstore)
@@ -3188,8 +3204,10 @@ func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVHUload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVHUload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHUload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3200,7 +3218,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHUload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHUload)
@@ -3210,7 +3228,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHUload(v *Value) bool {
                return true
        }
        // match: (MOVHUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3222,7 +3240,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHUload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHUload)
@@ -3298,7 +3316,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHload(v *Value) bool {
        b := v.Block
        config := b.Func.Config
        // match: (MOVHload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3309,7 +3327,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHload)
@@ -3319,7 +3337,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHload(v *Value) bool {
                return true
        }
        // match: (MOVHload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3331,7 +3349,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHload)
@@ -3440,8 +3458,10 @@ func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVHstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3453,7 +3473,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHstore)
@@ -3463,7 +3483,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool {
                return true
        }
        // match: (MOVHstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3476,7 +3496,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHstore)
@@ -3574,8 +3594,10 @@ func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVHstorezero(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVHstorezero [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHstorezero [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3586,7 +3608,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstorezero(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHstorezero)
@@ -3596,7 +3618,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstorezero(v *Value) bool {
                return true
        }
        // match: (MOVHstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVHstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3608,7 +3630,7 @@ func rewriteValueMIPS64_OpMIPS64MOVHstorezero(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVHstorezero)
@@ -3625,7 +3647,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVload(v *Value) bool {
        b := v.Block
        config := b.Func.Config
        // match: (MOVVload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3636,7 +3658,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVload)
@@ -3646,7 +3668,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVload(v *Value) bool {
                return true
        }
        // match: (MOVVload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3658,7 +3680,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVload)
@@ -3728,8 +3750,10 @@ func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVVstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3741,7 +3765,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVstore)
@@ -3751,7 +3775,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool {
                return true
        }
        // match: (MOVVstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3764,7 +3788,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVstore)
@@ -3794,8 +3818,10 @@ func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVVstorezero(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVVstorezero [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVstorezero [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3806,7 +3832,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstorezero(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVstorezero)
@@ -3816,7 +3842,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstorezero(v *Value) bool {
                return true
        }
        // match: (MOVVstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVVstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3828,7 +3854,7 @@ func rewriteValueMIPS64_OpMIPS64MOVVstorezero(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVVstorezero)
@@ -3842,8 +3868,10 @@ func rewriteValueMIPS64_OpMIPS64MOVVstorezero(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVWUload(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVWUload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWUload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3854,7 +3882,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWUload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWUload)
@@ -3864,7 +3892,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWUload(v *Value) bool {
                return true
        }
        // match: (MOVWUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3876,7 +3904,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWUload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWUload)
@@ -3974,7 +4002,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWload(v *Value) bool {
        b := v.Block
        config := b.Func.Config
        // match: (MOVWload [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWload [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -3985,7 +4013,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWload(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWload)
@@ -3995,7 +4023,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWload(v *Value) bool {
                return true
        }
        // match: (MOVWload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -4007,7 +4035,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWload(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWload)
@@ -4149,8 +4177,10 @@ func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool {
        v_2 := v.Args[2]
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVWstore [off1] {sym} (ADDVconst [off2] ptr) val mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWstore [off1+int32(off2)] {sym} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -4162,7 +4192,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWstore)
@@ -4172,7 +4202,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool {
                return true
        }
        // match: (MOVWstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -4185,7 +4215,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool {
                ptr := v_0.Args[0]
                val := v_1
                mem := v_2
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWstore)
@@ -4249,8 +4279,10 @@ func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool {
 func rewriteValueMIPS64_OpMIPS64MOVWstorezero(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
+       b := v.Block
+       config := b.Func.Config
        // match: (MOVWstorezero [off1] {sym} (ADDVconst [off2] ptr) mem)
-       // cond: is32Bit(int64(off1)+off2)
+       // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWstorezero [off1+int32(off2)] {sym} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -4261,7 +4293,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstorezero(v *Value) bool {
                off2 := auxIntToInt64(v_0.AuxInt)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(is32Bit(int64(off1) + off2)) {
+               if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWstorezero)
@@ -4271,7 +4303,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstorezero(v *Value) bool {
                return true
        }
        // match: (MOVWstorezero [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem)
-       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2))
+       // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)
        // result: (MOVWstorezero [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem)
        for {
                off1 := auxIntToInt32(v.AuxInt)
@@ -4283,7 +4315,7 @@ func rewriteValueMIPS64_OpMIPS64MOVWstorezero(v *Value) bool {
                sym2 := auxToSym(v_0.Aux)
                ptr := v_0.Args[0]
                mem := v_1
-               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) {
+               if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) {
                        break
                }
                v.reset(OpMIPS64MOVWstorezero)