]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/ssa: more constant folding rules for ARM
authorBen Shi <powerman1st@163.com>
Tue, 25 Apr 2017 10:53:10 +0000 (10:53 +0000)
committerKeith Randall <khr@golang.org>
Sat, 29 Apr 2017 02:53:46 +0000 (02:53 +0000)
commit38fbada5579823378217d57671de54fc5ebfa8c6
treec7eb08e0f32f3ef02f1c132f3313a89967969199
parentc4335f81a29dd6d43db7337707a27908c5059b0c
cmd/compile/internal/ssa: more constant folding rules for ARM

(ADDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (SUBconst [int64(int32(-c))] x)
(SUBconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (ADDconst [int64(int32(-c))] x)
Currently
a = a + 0xfffffff1 is compiled to ï¼ˆvariable a is in R0)
MVN $14, R11
ADD R11, R0, R0
After applying the above 2 rules, it becomes
SUB $15, R0, R0

(BICconst [c] (BICconst [d] x)) -> (BICconst [int64(int32(c|d))] x)
This rule also optimizes the generated ARM code.

The other rules are added to avoid to generate less optimized ARM code
when substitutions ADD->SUB happen.

Change-Id: I3ead9aae2b446b674e2ab42d37259d38ceb93a4d
Reviewed-on: https://go-review.googlesource.com/41679
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewriteARM.go