lkml.org 
[lkml]   [2022]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 2/2] minmax: clamp more efficiently by avoiding extra comparison
On Mon, Sep 26, 2022 at 8:30 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Mon, Sep 26, 2022 at 03:34:35PM +0200, Jason A. Donenfeld wrote:
> > [...]
> > In this case, we actually gain a branch, unfortunately, because the
> > compiler's replacement axioms no longer as cleanly apply.
> >
> > So all and all, this change is a bit of a mixed bag.
>
> I'm on the fence -- I think the new macro is a more correct way to
> describe the operation, though on the other hand, the old way provides a
> simple way to compose the bounds checks.
>
> I suspect we should probably optimize for _performance_, not code size,
> so if the new branch is actually visible via cycle counts in "perf"
> output, probably we shouldn't use this patch, and instead add a comment
> about why it is defined the way it is.

I *want* the better algorithm to yield better performance, because
that's a much less confusing world. But it seems like we have grounds
for suspecting that might not be the case. So until I come up with
some real measurements, I agree we should hold off on this 2/2.

Jason

\
 
 \ /
  Last update: 2022-09-26 23:34    [W:0.087 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site