Computer Chess Club Archives


Search

Terms

Messages

Subject: very simple question on inlining

Author: Georg v. Zimmermann

Date: 04:25:09 11/30/03


Do modern compilers understand the following 2 code parts are exactly
equivialent ? Do they understand to also eliminate the ifs in the second example
when inlining ?

Thanks.

Oh and if I have typose in there , its just an example, I think you get the idea
anyway.


PS.
Congrats to Shredder !


Example 1.)

int test ()
{

	for (int a = 0; a < 77; a++)
	{
		if (oneArray[a]) return 0;
	}

	for (a = 0; a < 77; a++)
	{
		if (anotherArray[a]) return 0;
	}
	return 1;
}

-------------------------------------------------------
Example 2.)


inline int subTest1 ()
{
	for (int a = 0; a < 77; a++)
	{
		if (oneArray[a]) return 0;
	}
	return 1;
}

inline int subTest2 ()
{
	for (int a = 0; a < 77; a++)
	{
		if (anotherArray[a]) return 0;
	}
	return 1;
}


int test ()
{

	if (!subTest1())
		return 0;
	if (!subTest2())
		return 0;

	return 1;
}



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.