[Mono-devel-list] First CIL Regex performance result

Miguel de Icaza miguel at ximian.com
Sat Feb 28 13:11:52 EST 2004


Hello,

> Everything that I taught could be usefull is now on our Blog at 
> http://aeglos.dyndns.org/tip-mono
> 
> We would be verry happy if somebody could tell us if we are in the good 
> way.  The framework we use work very well and we are eager to support 
> more construct.  But, if something is unefficient, we must correct it NOW.

There are a few areas where the code generated could be improved, and
where our JIT might not be able to optimize things today:

	* In location 0x8c, you do a:

		blt IL_0096
		br  IL_0075

	IL_0096:

	  You can do a simple jump optimization, and change that to:

		bge IL_0075

	* In 0xba, you do something similar:

		IL_00ba:  beq IL_00c4
		IL_00bf:  br IL_0075
		IL_00c4:  br IL_012d

	  There is an obvious optimization there, but am puzzled by why do you
	  have the beq there in the first place, there is no compare there, and
	  various nops before, which makes me wonder about the intent.

	* Loop inversion:

	  A loop like this:

		while (cond){
			code;
		}

	  Is sometimes compiled as:

	  l1:
		cond
		bne end
		code;
		br  l1
	  end:

	  The problem is that testing the condition at the end of the loop always takes
	  two branches.  You can use a technique called loop-inversion, that changes the
	  generated code into:

	  	br test;
	  l1:
		code
	  test:
		cond
		be l1

	  This way, you only branch one per test.

	  MCS generates code like this for loops.

	* Caching values?

	  Maybe you might want to copy at the function startup the scan_ptr value into
	  a local variable, and if you need the value afterwards, move the local to the
	  field later on.

Miguel.



More information about the Mono-devel-list mailing list