K
Kunal
Hello,
I need help in removing if ..else conditions inside for loops. I have
used the following method but I am not sure whether it has actually
helped.
Below is an example to illustrate what I have used.
Original code :
c= 0 ;
for (i=0; i<999; i++)
{
if (a > B)
c++ ;
}
Modified code for speed optimization
c= 0 ;
for (i=0; i<999; i++)
{
c += (a > B) ;
}
As per my reasoning, the logical expression is evaluated but no
conditional branching instructions should be generated. This should
avoid any pipeline stalls.
However, I havent found any document confirming my belief !
Any comments, suggestions or references will be a big help !
Thanks & Regards
I need help in removing if ..else conditions inside for loops. I have
used the following method but I am not sure whether it has actually
helped.
Below is an example to illustrate what I have used.
Original code :
c= 0 ;
for (i=0; i<999; i++)
{
if (a > B)
c++ ;
}
Modified code for speed optimization
c= 0 ;
for (i=0; i<999; i++)
{
c += (a > B) ;
}
As per my reasoning, the logical expression is evaluated but no
conditional branching instructions should be generated. This should
avoid any pipeline stalls.
However, I havent found any document confirming my belief !
Any comments, suggestions or references will be a big help !
Thanks & Regards