Two new ssa rules for arm

204 views
Skip to first unread message

Ben Shi

unread,
Apr 25, 2017, 5:56:40 AM4/25/17
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

Reply all
Reply to author
Forward
0 new messages