From fb16f4b82e2f7cb1a44cc6e32adad7ce2b0d0553 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Mon, 13 Apr 2020 01:39:45 +1000 Subject: [PATCH] cmd/compile: log large copies on riscv64 Log large copies in the riscv64 compiler. This was missed in 47ade08141b23cfeafed92943e16012d5dc5eb8b, resulting in the new test added to cmd/compile/internal/logopt failing on riscv64. Change-Id: I6f763e86f42834148e911d16928f9fbabcfa4290 Reviewed-on: https://go-review.googlesource.com/c/go/+/227804 Reviewed-by: Cherry Zhang Reviewed-by: David Chase Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/ssa/gen/RISCV64.rules | 2 +- src/cmd/compile/internal/ssa/rewriteRISCV64.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64.rules b/src/cmd/compile/internal/ssa/gen/RISCV64.rules index 3d3718b9ae7..95aadeb2b84 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64.rules +++ b/src/cmd/compile/internal/ssa/gen/RISCV64.rules @@ -404,7 +404,7 @@ (Move [8] dst src mem) -> (MOVDstore dst (MOVDload src mem) mem) // Generic move uses a loop -(Move [s] {t} dst src mem) -> +(Move [s] {t} dst src mem) && (s <= 16 || logLargeCopy(v, s)) -> (LoweredMove [t.(*types.Type).Alignment()] dst src diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go index 7405f686eb6..6a0f7f1c96f 100644 --- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go +++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -1894,6 +1894,7 @@ func rewriteValueRISCV64_OpMove(v *Value) bool { return true } // match: (Move [s] {t} dst src mem) + // cond: (s <= 16 || logLargeCopy(v, s)) // result: (LoweredMove [t.(*types.Type).Alignment()] dst src (ADDI [s-moveSize(t.(*types.Type).Alignment(), config)] src) mem) for { s := v.AuxInt @@ -1901,6 +1902,9 @@ func rewriteValueRISCV64_OpMove(v *Value) bool { dst := v_0 src := v_1 mem := v_2 + if !(s <= 16 || logLargeCopy(v, s)) { + break + } v.reset(OpRISCV64LoweredMove) v.AuxInt = t.(*types.Type).Alignment() v0 := b.NewValue0(v.Pos, OpRISCV64ADDI, src.Type) @@ -1909,6 +1913,7 @@ func rewriteValueRISCV64_OpMove(v *Value) bool { v.AddArg4(dst, src, v0, mem) return true } + return false } func rewriteValueRISCV64_OpMul16(v *Value) bool { v_1 := v.Args[1]