• Jakub Kicinski's avatar
    nfp: bpf: optimize add/sub of a negative constant · 6c59500c
    Jakub Kicinski authored
    NFP instruction set can fit small immediates into the instruction.
    Negative integers, however, will never fit because they will have
    highest bit set.  If we swap the ALU op between ADD and SUB and
    negate the constant we have a better chance of fitting small negative
    integers into the instruction itself and saving one or two cycles.
    
    immed[gprB_21, 0xfffffffc]
    alu[gprA_4, gprA_4, +, gprB_21], gpr_wrboth
    immed[gprB_21, 0xffffffff]
    alu[gprA_5, gprA_5, +carry, gprB_21], gpr_wrboth
    
    now becomes:
    
    alu[gprA_4, gprA_4, -, 4], gpr_wrboth
    alu[gprA_5, gprA_5, -carry, 0], gpr_wrboth
    Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    6c59500c
jit.c 90.3 KB