<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><div>Most compiler will do a good optimize on it, the && must generate jump since maybe side effect on previous operator.</div><div><br></div><div>this condition and above mvc[i].clipped(qmvmin, qmvmax) is highest component in MotionEstimate::motionEstimate</div><div></div><div id="divNeteaseMailCard"></div><div><br></div>At 2015-06-30 00:42:48,"Deepthi Nandakumar" <deepthi@multicorewareinc.com> wrote:<br> <blockquote id="isReplyContent" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><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: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">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" target="_blank" rel="noreferrer">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" target="_blank" rel="noreferrer">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" target="_blank" rel="noreferrer">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div>
</blockquote></div>