aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal')
-rw-r--r--src/cmd/compile/internal/loong64/ssa.go1
-rw-r--r--src/cmd/compile/internal/ssa/_gen/LOONG64.rules3
-rw-r--r--src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go1
-rw-r--r--src/cmd/compile/internal/ssa/opGen.go14
-rw-r--r--src/cmd/compile/internal/ssa/rewriteLOONG64.go36
5 files changed, 55 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/loong64/ssa.go b/src/cmd/compile/internal/loong64/ssa.go
index dc737732f1..2f8cb0585d 100644
--- a/src/cmd/compile/internal/loong64/ssa.go
+++ b/src/cmd/compile/internal/loong64/ssa.go
@@ -529,6 +529,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
ssa.OpLOONG64BITREV4B,
ssa.OpLOONG64BITREVW,
ssa.OpLOONG64BITREVV,
+ ssa.OpLOONG64ABSF,
ssa.OpLOONG64ABSD:
p := s.Prog(v.Op.Asm())
p.From.Type = obj.TYPE_REG
diff --git a/src/cmd/compile/internal/ssa/_gen/LOONG64.rules b/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
index a40603e93d..9793e6cf34 100644
--- a/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
@@ -773,6 +773,9 @@
(SUBF (NEGF (MULF x y)) z) && z.Block.Func.useFMA(v) => (FNMADDF x y z)
(SUBD (NEGD (MULD x y)) z) && z.Block.Func.useFMA(v) => (FNMADDD x y z)
+// Absorb conversion between 32 bit and 64 bit if both src and dst are 32 bit.
+(MOVDF ((ABS|SQRT)D (MOVFD x))) => ((ABS|SQRT)F x)
+
// generic simplifications
(ADDV x (NEGV y)) => (SUBV x y)
(SUBV x (NEGV y)) => (ADDV x y)
diff --git a/src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go b/src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go
index 9fd5ede869..ba8c067951 100644
--- a/src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go
+++ b/src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go
@@ -169,6 +169,7 @@ func init() {
{name: "SQRTD", argLength: 1, reg: fp11, asm: "SQRTD"}, // sqrt(arg0), float64
{name: "SQRTF", argLength: 1, reg: fp11, asm: "SQRTF"}, // sqrt(arg0), float32
+ {name: "ABSF", argLength: 1, reg: fp11, asm: "ABSF"}, // abs(arg0), float32
{name: "ABSD", argLength: 1, reg: fp11, asm: "ABSD"}, // abs(arg0), float64
{name: "CLZW", argLength: 1, reg: gp11, asm: "CLZW"}, // Count leading (high order) zeroes (returns 0-32)
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
index b5be6e15cb..ec82ff45a9 100644
--- a/src/cmd/compile/internal/ssa/opGen.go
+++ b/src/cmd/compile/internal/ssa/opGen.go
@@ -4486,6 +4486,7 @@ const (
OpLOONG64NEGD
OpLOONG64SQRTD
OpLOONG64SQRTF
+ OpLOONG64ABSF
OpLOONG64ABSD
OpLOONG64CLZW
OpLOONG64CLZV
@@ -69671,6 +69672,19 @@ var opcodeTable = [...]opInfo{
},
},
{
+ name: "ABSF",
+ argLen: 1,
+ asm: loong64.AABSF,
+ reg: regInfo{
+ inputs: []inputInfo{
+ {0, 4611686017353646080}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
+ },
+ outputs: []outputInfo{
+ {0, 4611686017353646080}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
+ },
+ },
+ },
+ {
name: "ABSD",
argLen: 1,
asm: loong64.AABSD,
diff --git a/src/cmd/compile/internal/ssa/rewriteLOONG64.go b/src/cmd/compile/internal/ssa/rewriteLOONG64.go
index 37aedcbe6e..93270823d5 100644
--- a/src/cmd/compile/internal/ssa/rewriteLOONG64.go
+++ b/src/cmd/compile/internal/ssa/rewriteLOONG64.go
@@ -360,6 +360,8 @@ func rewriteValueLOONG64(v *Value) bool {
return rewriteValueLOONG64_OpLOONG64MOVBstore(v)
case OpLOONG64MOVBstoreidx:
return rewriteValueLOONG64_OpLOONG64MOVBstoreidx(v)
+ case OpLOONG64MOVDF:
+ return rewriteValueLOONG64_OpLOONG64MOVDF(v)
case OpLOONG64MOVDload:
return rewriteValueLOONG64_OpLOONG64MOVDload(v)
case OpLOONG64MOVDloadidx:
@@ -3182,6 +3184,40 @@ func rewriteValueLOONG64_OpLOONG64MOVBstoreidx(v *Value) bool {
}
return false
}
+func rewriteValueLOONG64_OpLOONG64MOVDF(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVDF (ABSD (MOVFD x)))
+ // result: (ABSF x)
+ for {
+ if v_0.Op != OpLOONG64ABSD {
+ break
+ }
+ v_0_0 := v_0.Args[0]
+ if v_0_0.Op != OpLOONG64MOVFD {
+ break
+ }
+ x := v_0_0.Args[0]
+ v.reset(OpLOONG64ABSF)
+ v.AddArg(x)
+ return true
+ }
+ // match: (MOVDF (SQRTD (MOVFD x)))
+ // result: (SQRTF x)
+ for {
+ if v_0.Op != OpLOONG64SQRTD {
+ break
+ }
+ v_0_0 := v_0.Args[0]
+ if v_0_0.Op != OpLOONG64MOVFD {
+ break
+ }
+ x := v_0_0.Args[0]
+ v.reset(OpLOONG64SQRTF)
+ v.AddArg(x)
+ return true
+ }
+ return false
+}
func rewriteValueLOONG64_OpLOONG64MOVDload(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]