From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf-next 7/7] nfp: bpf: migrate to advanced reciprocal divide in reciprocal_div.h Date: Tue, 26 Jun 2018 13:59:24 -0700 Message-ID: <20180626135924.0050ab10@cakuba.netronome.com> References: <20180625035421.2991-1-jakub.kicinski@netronome.com> <20180625035421.2991-8-jakub.kicinski@netronome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: alexei.starovoitov@gmail.com, daniel@iogearbox.net, oss-drivers@netronome.com, netdev@vger.kernel.org To: Jiong Wang Return-path: Received: from mail-qt0-f194.google.com ([209.85.216.194]:37789 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbeFZU73 (ORCPT ); Tue, 26 Jun 2018 16:59:29 -0400 Received: by mail-qt0-f194.google.com with SMTP id a18-v6so16487411qtj.4 for ; Tue, 26 Jun 2018 13:59:28 -0700 (PDT) In-Reply-To: <20180625035421.2991-8-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, 24 Jun 2018 20:54:21 -0700, Jakub Kicinski wrote: > + * NOTE: because we are using "reciprocal_value_adv" which doesn't > + * support dividend with MSB set, so we need to JIT separate NFP > + * sequence to handle such case. It could be a simple sequence if there > + * is conditional move, however there isn't for NFP. So, we don't bother > + * generating compare-if-set-branch sequence by rejecting the program > + * straight away when the u32 dividend has MSB set. Divide by such a > + * large constant would be rare in practice. Also, the programmer could > + * simply rewrite it as "result = divisor >= the_const". Thinking about this again, can we just use carry bit? The code may end up shorter than the explanation why we don't support that case :P immed[c, 0] alu[--, a, -, b] alu[c, c, +carry, 0] Should be equivalent to: c = a >= b (Thanks to Edwin for double-checking the carry semantics.)