Ben Shi
unread,Apr 25, 2017, 5:56:40 AM4/25/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
For the source file
package main
import "fmt"
var a uint32
func main() {
a += 0xfffffff1
fmt.Println(a)
}
current go will compile to
a.go:8 0x8121c e59b0000 MOVW (R11), R0
a.go:8 0x81220 e3e0b00e MVN $14, R11
a.go:8 0x81224 e080000b ADD R11, R0, R0
a.go:8 0x81228 e59fb05c MOVW 0x5c(R15), R11
I think
MOVW (R11), R0
SUB $15, R0, R0
MOVW 0x5c(R15), R11
are better.
How about add two new constant folding rules in ARM.rules:
(ADDconst [c] x) && !isARMImm12(c) && isARMImm12(0-c) -> (SUBconst [0-c] x)
(SUBconst [c] x) && !isARMImm12(c) && isARMImm12(0-c) -> (ADDconst [0-c] x)
Ben Shi