Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/cmd/compile/internal/amd64/simdssa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cmd/compile/internal/midway/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,13 @@ func (c *DeepCopier) CopySimpleStmt(s syntax.SimpleStmt) syntax.SimpleStmt {
newList.ElemList = append(newList.ElemList, c.CopyExpr(el))
}
}
newList.SetPos(list.Pos())
newS.Lhs = newList
} else if id, ok := s.Lhs.(*syntax.Name); ok && s.Def {
newS.Lhs = c.CopyName(id, true)
} else {
newS.Lhs = c.CopyExpr(s.Lhs)
}
newS.Lhs.SetPos(s.Lhs.Pos())
newS.SetPos(s.Pos())
return newS
case *syntax.AssignStmt:
Expand Down
53 changes: 36 additions & 17 deletions src/cmd/compile/internal/riscv64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {

case ssaop.OpRISCV64LoweredZero:
ptr := v.Args[0].Reg()
sc := v.AuxValAndOff()
n := sc.Val64()

mov, sz := largestMove(sc.Off64())
n, align := v.AuxSizeAndAlign()
mov, sz := largestMove(align)

// mov ZERO, (offset)(Rarg0)
var off int64
Expand All @@ -809,9 +807,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {

case ssaop.OpRISCV64LoweredZeroLoop:
ptr := v.Args[0].Reg()
sc := v.AuxValAndOff()
n := sc.Val64()
mov, sz := largestMove(sc.Off64())
n, align := v.AuxSizeAndAlign()
mov, sz := largestMove(align)
chunk := 8 * sz

if n <= 3*chunk {
Expand All @@ -820,9 +817,21 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {

tmp := v.RegTmp()

if n >= 1<<31 {
p := s.Prog(riscv.AMOV)
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
p.To.Type = obj.TYPE_REG
p.To.Reg = tmp
}
p := s.Prog(riscv.AADD)
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
if n >= 1<<31 {
p.From.Type = obj.TYPE_REG
p.From.Reg = tmp
} else {
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
}
p.Reg = ptr
p.To.Type = obj.TYPE_REG
p.To.Reg = tmp
Expand Down Expand Up @@ -871,9 +880,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
break
}

sa := v.AuxValAndOff()
n := sa.Val64()
mov, sz := largestMove(sa.Off64())
n, align := v.AuxSizeAndAlign()
mov, sz := largestMove(align)

var off int64
tmp := int16(riscv.REG_X5)
Expand All @@ -900,19 +908,30 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
break
}

sc := v.AuxValAndOff()
n := sc.Val64()
mov, sz := largestMove(sc.Off64())
n, align := v.AuxSizeAndAlign()
mov, sz := largestMove(align)
chunk := 8 * sz

if n <= 3*chunk {
v.Fatalf("MoveLoop too small:%d, expect:%d", n, 3*chunk)
}
tmp := int16(riscv.REG_X5)

if n >= 1<<31 {
p := s.Prog(riscv.AMOV)
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
p.To.Type = obj.TYPE_REG
p.To.Reg = riscv.REG_X6
}
p := s.Prog(riscv.AADD)
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
if n >= 1<<31 {
p.From.Type = obj.TYPE_REG
p.From.Reg = riscv.REG_X6
} else {
p.From.Type = obj.TYPE_CONST
p.From.Offset = n - n%chunk
}
p.Reg = src
p.To.Type = obj.TYPE_REG
p.To.Reg = riscv.REG_X6
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/ssa/_gen/RISCV64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,11 @@

// Unroll zeroing in medium size (at most 192 bytes i.e. 3 cachelines)
(Zero [s] {t} ptr mem) && s <= 24*ssa.MoveSize(t.Alignment(), config) =>
(LoweredZero [ssa.MakeValAndOff(int32(s),int32(t.Alignment()))] ptr mem)
(LoweredZero [s] {t.Alignment()} ptr mem)

// Generic zeroing uses a loop
(Zero [s] {t} ptr mem) && s > 24*ssa.MoveSize(t.Alignment(), config) =>
(LoweredZeroLoop [ssa.MakeValAndOff(int32(s),int32(t.Alignment()))] ptr mem)
(LoweredZeroLoop [s] {t.Alignment()} ptr mem)

// Checks
(IsNonNil ...) => (SNEZ ...)
Expand Down Expand Up @@ -449,12 +449,12 @@
// Generic move
(Move [s] {t} dst src mem) && s > 0 && s <= 3*8*ssa.MoveSize(t.Alignment(), config)
&& ssa.LogLargeCopyValue(v, s) =>
(LoweredMove [ssa.MakeValAndOff(int32(s),int32(t.Alignment()))] dst src mem)
(LoweredMove [s] {t.Alignment()} dst src mem)

// Generic move uses a loop
(Move [s] {t} dst src mem) && s > 3*8*ssa.MoveSize(t.Alignment(), config)
&& ssa.LogLargeCopyValue(v, s) =>
(LoweredMoveLoop [ssa.MakeValAndOff(int32(s),int32(t.Alignment()))] dst src mem)
(LoweredMoveLoop [s] {t.Alignment()} dst src mem)

// Boolean ops; 0=false, 1=true
(AndB ...) => (AND ...)
Expand Down
28 changes: 14 additions & 14 deletions src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ func init() {
// general unrolled zeroing
// arg0 = address of memory to zero
// arg1 = mem
// auxint = element size and type alignment
// auxint = size
// aux = alignment (as an int64)
// returns mem
// mov ZERO, (OFFSET)(Rarg0)
{
name: "LoweredZero",
aux: "SymValAndOff",
aux: "SizeAndAlign",
typ: "Mem",
argLength: 2,
symEffect: "Write",
faultOnNilArg0: true,
addrSinkArg0: true,
reg: regInfo{
Expand All @@ -310,15 +310,15 @@ func init() {
},
// general unaligned zeroing
// arg0 = address of memory to zero (clobber)
// arg2 = mem
// auxint = element size and type alignment
// arg1 = mem
// auxint = size
// aux = alignment (as an int64)
// returns mem
{
name: "LoweredZeroLoop",
aux: "SymValAndOff",
aux: "SizeAndAlign",
typ: "Mem",
argLength: 2,
symEffect: "Write",
needIntTemp: true,
faultOnNilArg0: true,
addrSinkArg0: true,
Expand All @@ -332,14 +332,14 @@ func init() {
// arg0 = address of dst memory (clobber)
// arg1 = address of src memory (clobber)
// arg2 = mem
// auxint = size and type alignment
// auxint = size
// aux = alignment (as an int64)
// returns mem
// mov (offset)(Rarg1), TMP
// mov TMP, (offset)(Rarg0)
{
name: "LoweredMove",
aux: "SymValAndOff",
symEffect: "Write",
aux: "SizeAndAlign",
argLength: 3,
reg: regInfo{
inputs: []regMask{gpMask.minus(regNamed["X5"]), gpMask.minus(regNamed["X5"])},
Expand All @@ -354,8 +354,9 @@ func init() {
// general unaligned move
// arg0 = address of dst memory (clobber)
// arg1 = address of src memory (clobber)
// arg3 = mem
// auxint = alignment
// arg2 = mem
// auxint = size
// aux = alignment (as an int64)
// returns mem
// ADD $sz, X6
//loop:
Expand All @@ -367,9 +368,8 @@ func init() {
// BNE X6, Rarg1, loop
{
name: "LoweredMoveLoop",
aux: "SymValAndOff",
aux: "SizeAndAlign",
argLength: 3,
symEffect: "Write",
reg: regInfo{
inputs: []regMask{gpMask.minus(r5toR6), gpMask.minus(r5toR6)},
clobbers: r5toR6,
Expand Down
Loading
Loading