diff options
author | Joel Sing <joel@sing.id.au> | 2020-03-03 03:45:22 +1100 |
---|---|---|
committer | Joel Sing <joel@sing.id.au> | 2020-03-15 08:19:07 +0000 |
commit | 26154f31ad6c801d8bad5ef58df1e9263c6beec7 (patch) | |
tree | c9dd979940d6dcea886b70bdf41cbe17331c995b /src/cmd/compile/internal/ssa/gen/RISCV64.rules | |
parent | 7b2f0ba5b91b4b2b659fb46638ff56f51be9b2b5 (diff) | |
download | go-26154f31ad6c801d8bad5ef58df1e9263c6beec7.tar.gz go-26154f31ad6c801d8bad5ef58df1e9263c6beec7.zip |
cmd/compile: use NEG/NEGW pseudo-instructions on riscv64
Also rewrite subtraction of zero to NEG/NEGW.
Change-Id: I216e286d1860055f2a07fe2f772cd50f366ea097
Reviewed-on: https://go-review.googlesource.com/c/go/+/221691
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/gen/RISCV64.rules')
-rw-r--r-- | src/cmd/compile/internal/ssa/gen/RISCV64.rules | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64.rules b/src/cmd/compile/internal/ssa/gen/RISCV64.rules index d6ed61a461..a4b141b4fb 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64.rules +++ b/src/cmd/compile/internal/ssa/gen/RISCV64.rules @@ -84,10 +84,10 @@ (Xor16 ...) -> (XOR ...) (Xor8 ...) -> (XOR ...) -(Neg64 x) -> (SUB (MOVDconst) x) -(Neg32 x) -> (SUB (MOVWconst) x) -(Neg16 x) -> (SUB (MOVHconst) x) -(Neg8 x) -> (SUB (MOVBconst) x) +(Neg64 ...) -> (NEG ...) +(Neg32 ...) -> (NEG ...) +(Neg16 ...) -> (NEG ...) +(Neg8 ...) -> (NEG ...) (Neg32F ...) -> (FNEGS ...) (Neg64F ...) -> (FNEGD ...) @@ -497,5 +497,14 @@ // Subtraction of zero with sign extension. (SUBW x (MOVWconst [0])) -> (ADDIW [0] x) +// Subtraction from zero. +(SUB (MOVBconst [0]) x) -> (NEG x) +(SUB (MOVHconst [0]) x) -> (NEG x) +(SUB (MOVWconst [0]) x) -> (NEG x) +(SUB (MOVDconst [0]) x) -> (NEG x) + +// Subtraction from zero with sign extension. +(SUBW (MOVDconst [0]) x) -> (NEGW x) + // remove redundant *const ops (ADDI [0] x) -> x |