]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add rewrite rules for conditional instructions on arm64
authorfanzha02 <fannie.zhang@arm.com>
Mon, 18 Jan 2021 06:32:49 +0000 (14:32 +0800)
committerfannie zhang <Fannie.Zhang@arm.com>
Thu, 18 Mar 2021 01:46:58 +0000 (01:46 +0000)
commitf5e6d3e879f487066d1a05b8000a7187247558f7
treefa8fe9da000478f7086b6aaa66d242e5774b1736
parent51e4bb236cb8feb8118ed6dd768ddac834dad2ef
cmd/compile: add rewrite rules for conditional instructions on arm64

This CL adds rewrite rules for CSETM, CSINC, CSINV, and CSNEG. By adding
these rules, we can save one instruction.

For example,

  func test(cond bool, a int) int {
    if cond {
      a++
    }
    return a
  }

Before:

  MOVD "".a+8(RSP), R0
  ADD $1, R0, R1
  MOVBU "".cond(RSP), R2
  CMPW $0, R2
  CSEL NE, R1, R0, R0

After:

  MOVBU "".cond(RSP), R0
  CMPW $0, R0
  MOVD "".a+8(RSP), R0
  CSINC EQ, R0, R0, R0

This patch is a copy of CL 285694. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: Ic1a79e8b8ece409b533becfcb7950f11e7b76f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/302231
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/arm64/ssa.go
src/cmd/compile/internal/ssa/gen/ARM64.rules
src/cmd/compile/internal/ssa/gen/ARM64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteARM64.go
test/codegen/condmove.go