Skip to content

cmd/compile: optimization of constant pool on arm #19844

Closed
@benshi001

Description

@benshi001

For the following code

func ass12345678(a int) int {
return a + 0xffff
}

Currently go will store 0xffff to the constant pool and load it in runtime.
a.go:6 0x95a04 e59fb06c MOVW 0x6c(R15), R11
a.go:6 0x95a08 e080000b ADD R11, R0, R0
.................................
a.go:9 0x95a78 0000ffff STRD.EQ [R0], -PC, R15, R15

But gcc optimized it to
a = a + 0x10000
a = a - 1

Both 1 and 0x10000 can be directly encoded to $immediate-12 into the instructions without any access to memory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions