]> Cypherpunks repositories - gostls13.git/commit
[dev.ssa] cmd/internal/obj/arm64: fix encoding constant into some instructions
authorCherry Zhang <cherryyz@google.com>
Wed, 3 Aug 2016 15:47:40 +0000 (11:47 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 10 Aug 2016 20:33:11 +0000 (20:33 +0000)
commit748aa84424418fb71c2528e7340df0ad6075b265
tree906d259dcbfb236800db4df9a1b99ae02276c17d
parentc069bc49963bd5c2c152fe600fdcb9a2b7b58f76
[dev.ssa] cmd/internal/obj/arm64: fix encoding constant into some instructions

When a constant can be encoded in a logical instruction (BITCON), do
it this way instead of using the constant pool. The BITCON testing
code runs faster than table lookup (using map):

(on AMD64 machine, with pseudo random input)
BenchmarkIsBitcon-4    300000000          4.04 ns/op
BenchmarkTable-4       50000000         27.3 ns/op

The equivalent C code of BITCON testing is formally verified with
model checker CBMC against linear search of the lookup table.

Also handle cases when a constant can be encoded in a MOV instruction.
In this case, materializa the constant into REGTMP without using the
constant pool.

When constants need to be added to the constant pool, make sure to
check whether it fits in 32-bit. If not, store 64-bit.

Both legacy and SSA compiler backends are happy with this.

Fixes #16226.

Change-Id: I883e3069dee093a1cdc40853c42221a198a152b0
Reviewed-on: https://go-review.googlesource.com/26631
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/internal/obj/arm64/a.out.go
src/cmd/internal/obj/arm64/anames7.go
src/cmd/internal/obj/arm64/asm7.go
src/cmd/internal/obj/arm64/obj7.go