• erifan01's avatar
    cmd/compile: add an optimization rule for math/bits.ReverseBytes16 on arm · fee84cc9
    erifan01 authored
    This CL adds two rules to turn patterns like ((x<<8) | (x>>8)) (the type of
    x is uint16, "|" can also be "+" or "^") to a REV16 instruction on arm v6+.
    This optimization rule can be used for math/bits.ReverseBytes16.
    
    Benchmarks on arm v6:
    name               old time/op  new time/op  delta
    ReverseBytes-32    2.86ns ± 0%  2.86ns ± 0%   ~     (all equal)
    ReverseBytes16-32  2.86ns ± 0%  2.86ns ± 0%   ~     (all equal)
    ReverseBytes32-32  1.29ns ± 0%  1.29ns ± 0%   ~     (all equal)
    ReverseBytes64-32  1.43ns ± 0%  1.43ns ± 0%   ~     (all equal)
    
    Change-Id: I819e633c9a9d308f8e476fb0c82d73fb73dd019f
    Reviewed-on: https://go-review.googlesource.com/c/go/+/159019Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
    Run-TryBot: Cherry Zhang <cherryyz@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    fee84cc9
ARM.rules 92.3 KB