<p dir="ltr">Hmm, but arent the benefits very compiler dependent? Since this isnt the innermost loop, is the readability loss worth it? </p>
<div class="gmail_quote">On Jun 29, 2015 9:27 PM, "Steve Borho" <<a href="mailto:steve@borho.org">steve@borho.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It is avoiding the C short-circuit logic that is necessary for &&. With<br>
& the compiler does not have to perform early-out jumps for each<br>
condition. Instead it does all the & operations then does a single<br>
conditional jump.<br>
<br>
It can often be faster, but you have to take a lot of care that the<br>
& does the right thing.<br>
<br>
On 06/29, Deepthi Nandakumar wrote:<br>
> Hi,<br>
><br>
> How does this improve the generated asm code/cycles taken?<br>
><br>
> On Sat, Jun 27, 2015 at 7:43 AM, Min Chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>> wrote:<br>
><br>
> > # HG changeset patch<br>
> > # User Min Chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>><br>
> > # Date 1435370055 25200<br>
> > # Node ID a8198965fbf18d7ced2cd8e8acd07fcc4ee6a2b3<br>
> > # Parent 229602ba850eb11c171d8c3cbb049dda4b41abda<br>
> > improve duplicate MV check by reduce condition jump<br>
> > ---<br>
> > source/encoder/motion.cpp | 4 ++--<br>
> > 1 files changed, 2 insertions(+), 2 deletions(-)<br>
> ><br>
> > diff -r 229602ba850e -r a8198965fbf1 source/encoder/motion.cpp<br>
> > --- a/source/encoder/motion.cpp Fri Jun 26 18:54:13 2015 -0700<br>
> > +++ b/source/encoder/motion.cpp Fri Jun 26 18:54:15 2015 -0700<br>
> > @@ -645,7 +645,7 @@<br>
> > for (int i = 0; i < numCandidates; i++)<br>
> > {<br>
> > MV m = mvc[i].clipped(qmvmin, qmvmax);<br>
> > - if (m.notZero() && m != pmv && m != bestpre) // check already<br>
> > measured<br>
> > + if (m.notZero() & (m != pmv ? 1 : 0) & (m != bestpre ? 1 :<br>
> > 0)) // check already measured<br>
> > {<br>
> > int cost = ref->lowresQPelCost(fenc, blockOffset, m, sad)<br>
> > + mvcost(m);<br>
> > if (cost < bprecost)<br>
> > @@ -661,7 +661,7 @@<br>
> > for (int i = 0; i < numCandidates; i++)<br>
> > {<br>
> > MV m = mvc[i].clipped(qmvmin, qmvmax);<br>
> > - if (m.notZero() && m != pmv && m != bestpre) // check already<br>
> > measured<br>
> > + if (m.notZero() & (m != pmv ? 1 : 0) & (m != bestpre ? 1 :<br>
> > 0)) // check already measured<br>
> > {<br>
> > int cost = subpelCompare(ref, m, sad) + mvcost(m);<br>
> > if (cost < bprecost)<br>
> ><br>
> > _______________________________________________<br>
> > x265-devel mailing list<br>
> > <a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
> > <a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
> ><br>
<br>
> _______________________________________________<br>
> x265-devel mailing list<br>
> <a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
> <a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<br>
<br>
--<br>
Steve Borho<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div>