Re: while ();
- From: "\\\\\\o///annabee" <fack@xxxxxxxxxxxxxx>
- Date: Sun, 29 Jan 2006 10:35:28 GMT
På 15 Jan 2006 15:17:07 -0800, skrev <spamtrap@xxxxxxxxxx>:
robertwessel2@xxxxxxxxx wrote:
One thing to remember is that most CPUs, in the absence of any other information, will predict a backwards branch as taken, and a forward branch as not taken. That's why most compilers will generate the test at the end of the loop (and the form Randy described is quite common).
If you take many iterations through the loop, it won't matter much (at least on a CPU with dynamic branch prediction), since the collected branch history will cause the correct prediction after the first few iterations. If, OTOH, there were (say) only three iterations, you'd expect two mispredictions (the first and third iteration) for the test-at-top form, and only one misprediction (last iteration) in Randy's version of the test-at-bottom form.
Hi Robert and Randy,
Thanks for the input... I've updated the compiler to generate the test at the bottom, rather than at the top.
Imo, what you should do is to do nothing. (Scrap your compiler as well).
As RobbertWessel says, ( misunderstanding the implications of his own words it seems),
is that it wount matter if many iterations, and it certainly wount matter at
all then, because 3 iterations will be closer to nothing.
We saw, some time back Randall Hyde posted some while loop, which was written by an "expert",
but turned out to be slower then a loop written in 2 secs, by a assembly beginner.
It was not at all significantly slower, but it was slower.
If doing windows programming, doing a windows app, scrap any other tool than RosASM.
If you need to use another assembler, because of other requirements, develop and test as much of
the logic in RosASM and port that. You will save time in the 10x department.
If you took time to do assembly with RosAsm, over some time, past the initial learning curve you would never ask this question, because you would know that the answer is not important.
The only important thing is the USER perception of time. If it is not closer to instant, it is too slow. If it takes then 2 minutes, because there simply isnt any other way, and you can make it 1 minute and 50 seconds, this will be useless investment of energy on your part.
The user will have returned elsewhere long before the first 10 seconds have passed. And when he comes back, it might have took 3 minutes and he would have probably not noticed.
The better way to test some code is to see it run. And the only useful optimization is the Strategy optimization. Sometimes, on the later processors, you can _add_ a lot of code and end up with a FASTER running app ... True, I have seen this.
I refer to [BU_ASM / 32Bit_Assembly_tutorials / Optimizations / Strategy_Optimizations ] for more info.
Get RosAsm here < http://betov.free.fr/RosAsm.html >
-- Darran (aka Chewy509) brought to you by Google Groups!
.
- Follow-Ups:
- Re: while ();
- From: robertwessel2
- Re: while ();
- From: Chewy509
- Re: while ();
- Prev by Date: Re: Some may need reminding
- Next by Date: LOL and behold
- Previous by thread: Some may need reminding
- Next by thread: Re: while ();
- Index(es):
Relevant Pages
|