• Vineet Gupta's avatar
    bitops/non-atomic: make @nr unsigned to avoid any DIV · 8f76f9c4
    Vineet Gupta authored
    signed math causes generation of costlier instructions such as DIV when
    they could be done by barrerl shifter.
    
    Worse part is this is not caught by things like bloat-o-meter since
    instruction length / symbols are typically same size.
    
    e.g.
    
    stock (signed math)
    __________________
    
    919b4614 <test_taint>:
    919b4614:	div	r2,r0,0x20
                    ^^^
    919b4618:	add2	r2,0x920f6050,r2
    919b4620:	ld_s	r2,[r2,0]
    919b4622:	lsr	r0,r2,r0
    919b4626:	j_s.d	[blink]
    919b4628:	bmsk_s	r0,r0,0
    919b462a:	nop_s
    
    (patched) unsigned math
    __________________
    
    919b4614 <test_taint>:
    919b4614:	lsr	r2,r0,0x5  @nr/32
                    ^^^
    919b4618:	add2	r2,0x920f6050,r2
    919b4620:	ld_s	r2,[r2,0]
    919b4622:	lsr	r0,r2,r0     #test_bit()
    919b4626:	j_s.d	[blink]
    919b4628:	bmsk_s	r0,r0,0
    919b462a:	nop_s
    Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
    Acked-by: default avatarWill Deacon <will@kernel.org>
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    8f76f9c4
non-atomic.h 3.06 KB