• Ben Shi's avatar
    cmd/compile/internal/ssa: more constant folding rules for ARM · 38fbada5
    Ben Shi authored
    (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/41679Reviewed-by: default avatarKeith Randall <khr@golang.org>
    38fbada5
rewriteARM.go 360 KB