tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Generated code optimization?


From: Zoltán Lörincz
Subject: [Tinycc-devel] Generated code optimization?
Date: Mon, 21 Feb 2005 10:36:00 +0200

Hello all,

last year in November i asked on this newsgroup about how could one
generate code for a Virtual Machine. Based on the advices i got i
implemented a byte code generator.
I used tree general integer registers A,B,C load-store based, right
now the code generator doesn't support float/double types.
Everything is working fine, but the performance i obtained is really
disappointing. The execution of the byte code is 30-45 slower then the
original code generated whith tcc.

Now i have to do optimizations for obtaining better performances. 

For the following c code:

 unsigned int addNum  = 0;
 unsigned int  Factor = 5;
 unsigned char pch[2];
 int i,j;
 pch[0] = 20;
 addNum = pch[0] + 5*Factor;
 if (addNum == 45)

my generator generates:
1: LDC_A_I4 0
2: STL_A_I4 -4
3: LDC_A_I4 5
4: STL_A_I4 -8
5: LDC_A_I4 20
6: STL_A_I1 -10
7: LDL_A_I4 -8
8: LDC_B_I4 5
9: MULU_BA_I4
10: LDLU_B_I1 -10
11: ADD_AB_I4
12: STL_B_I4 -4
13: LDL_A_I4 -4
14: LDC_B_I4 45
15: JNE_AB_I4 L84

This code could be optimized in the following way:

1: LDC_A_I4 0
2: STL_A_I4 -4
3: LDC_B_I4 5
4: STL_B_I4 -8
5: LDC_A_I4 20
6: STL_A_I1 -10
7: LDL_A_I4 5
8: MULU_BA_I4
9: LDLU_B_I1 -10
10: ADD_AB_I4
11: STL_B_I4 -4
12: LDC_A_I4 45
13: JNE_AB_I4 L84

As you can see this short code can be reduced with two instructions if
the generator could use the information about the values which are
currently stored in the real registers.

Can somebody give me some advice if this is possible with tcc, or if
it is possible then how could i achieve this optimization.

Thank you  a lot.
Zoltan Lorincz.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]