This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to improve AVR register allocation.


Attached patch changes order of local and global register allocation for AVR target.

Existing order fragments register pool, making it rapidly impossible to allocate register set for larger operands.

This patch reduces such fragmentation and consequently improve allocation.

General mixed code is showing 1.5% improvement in size. Though code using consistently larger operands (long, float) will see more savings.

Call saved registers and function parameter usage are unaffected, so all libraries and linked code are unaffected.



--- C:\Documents and Settings\Andy\Desktop\avr.c Fri Jan 11 19:20:43 2008
+++ C:\Documents and Settings\Andy\Desktop\avr.c.patched Fri Jan 11 19:17:44 2008
@@ -4817,43 +4817,9 @@
order_regs_for_local_alloc (void)
{
unsigned int i;
- static const int order_0[] = {
- 24,25,
- 18,19,
- 20,21,
- 22,23,
- 30,31,
- 26,27,
- 28,29,
- 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
- 0,1,
- 32,33,34,35
- };
- static const int order_1[] = {
- 18,19,
- 20,21,
- 22,23,
- 24,25,
- 30,31,
- 26,27,
- 28,29,
- 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
- 0,1,
- 32,33,34,35
- };
- static const int order_2[] = {
- 25,24,
- 23,22,
- 21,20,
- 19,18,
- 30,31,
- 26,27,
- 28,29,
- 17,16,
- 15,14,13,12,11,10,9,8,7,6,5,4,3,2,
- 1,0,
- 32,33,34,35
- };
+ static const int order_0[] = REG_ALLOC_ORDER_0;
+ static const int order_1[] = REG_ALLOC_ORDER_1;
+ static const int order_2[] = REG_ALLOC_ORDER_2;
const int *order = (TARGET_ORDER_1 ? order_1 :
TARGET_ORDER_2 ? order_2 :
--- C:\Documents and Settings\Andy\Desktop\avr.h Fri Jan 11 19:11:07 2008
+++ C:\Documents and Settings\Andy\Desktop\avr.h.patched Fri Jan 11 19:20:10 2008
@@ -160,18 +160,26 @@
1,1,/* STACK */ \
1,1 /* arg pointer */ }


-#define REG_ALLOC_ORDER { \
- 24,25, \
- 18,19, \
- 20,21, \
- 22,23, \
- 30,31, \
- 26,27, \
- 28,29, \
- 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, \
- 0,1, \
- 32,33,34,35 \
- }
+#define REG_ALLOC_ORDER_0 {\
+ 18,26,22,30,20,24,19,21,23,25,27,31,28,29, \
+ 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,\
+ 0,1,\
+ 32,33,34,35 } + +#define REG_ALLOC_ORDER_1 {\
+ 18,19,20,21,22,23,24,25,30,31,26,27,28,29,\
+ 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,\
+ 0,1,\
+ 32,33,34,35 }
+ +#define REG_ALLOC_ORDER_2 { \
+ 25,24,23,22,21,20,19,18,30,31,26,27,28,29,\
+ 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,\
+ 1,0,\
+ 32,33,34,35 }
+
+
+#define REG_ALLOC_ORDER REG_ALLOC_ORDER_0


#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]