• LE Manh Cuong's avatar
    cmd/compile: optimize bitset tests · c5f142fa
    LE Manh Cuong authored
    The assembly output for x & c == c, where c is power of 2:
    
    	MOVQ	"".set+8(SP), AX
    	ANDQ	$8, AX
    	CMPQ	AX, $8
    	SETEQ	"".~r2+24(SP)
    
    With optimization using bitset:
    
    	MOVQ	"".set+8(SP), AX
    	BTL	$3, AX
    	SETCS	"".~r2+24(SP)
    
    output less than 1 instruction.
    
    However, there is no speed improvement:
    
    name         old time/op  new time/op  delta
    AllBitSet-8  0.35ns ± 0%  0.35ns ± 0%   ~     (all equal)
    
    Fixes #31904
    
    Change-Id: I5dca4e410bf45716ed2145e3473979ec997e35d4
    Reviewed-on: https://go-review.googlesource.com/c/go/+/175957
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarKeith Randall <khr@golang.org>
    c5f142fa
generic.rules 104 KB