Hi Segher!
> On Thu, Sep 17, 2020 at 10:15:30AM -0700, David Faust via Gcc-patches wrote: >> The 'mod' and 'div' operators in eBPF are unsigned, with no signed >> counterpart. xBPF adds two new ALU operations, sdiv and smod, for >> signed division and modulus, respectively. Update bpf.md with >> 'define_insn' blocks for signed div and mod to use them when targetting >> xBPF, and add new tests to ensure they are used appropriately. > > So why does xBPF have signed versions of the divides? Is it because it > is wanted to have it in eBPF eventually? Is it because the libgcc > routines are just too slow? Is it because (the generic) libgcc does not > trap for MIN_INT / -1 ? Some other reason? > > (I'm just curious; I cannot figure it out :-) ) I don't know if eBPF will be adopting signed division instructions at some point... judging from what can be read in their documentation, most probably they will not. In xBPF we mainly want to avoid the funcall. Linking of BPF objects is still an... eer fuzzy area. Also, we reckon some potential applications of xbpf (like using it instead of dwarf in the Infinity project) may find it simpler to have the instructions than to rely on a software implementation like libgcc's.