Depends on 'x' type and location.
If 'x' is global and its value cannot be estimated, then you'll get:
if(!x) goto L2;
doTrue();
goto L3;
L2:
doFalse();
L3:
doTheRest();
If x is something else.... hm...
Probably, a probability having x all zeros less smaller than having 'x'
non-zero.
For example, intel c compiler shows it as a comment...
~d
On Monday 16 December 2002 16:50, David Brown wrote:
> I often like to look through the generated assembly code - it helps me be
> sure that the code will do what I want, and to be sure that I am not
> accidently doing something very inefficiently. One thing I notice is that
> the way code for if-else blocks is generated seems a bit odd. Consider the
> code:
> if (x) doTrue() else doFalse();
> doTheRest();
>
> This compiles roughly to:
> if (!x) goto L1
> doTrue();
> L2:
> doTheRest();
> ret
> L1:
> doFalse()
> goto L2
>
> I would have thought the obvious code would be:
> if (!x) goto L1
> doTrue();
> goto L2
> L1:
> doFalse();
> L2:
> doTheRest();
> ret
>
>
> Is there any reason for generating the first form? It means one less jump
> for the true case, but one more jump for the false case. It also makes it
> a lot more difficult to follow the generated assembly code.
>
>
>
> mvh.
>
> David
>
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:
> With Great Power, Comes Great Responsibility
> Learn to use your power at OSDN's High Performance Computing Channel
> http://hpc.devchannel.org/
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
--
/********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 3468202, 5585314
********************************************************************/