avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Need help compiling testcase with gcc 3.3.5 or 3.4.3


From: Andy Hutchinson
Subject: [avr-gcc-list] Need help compiling testcase with gcc 3.3.5 or 3.4.3
Date: Fri, 28 Jan 2005 00:28:06 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

I have been testing GCC 4.0 for avr wrt loop optimisations. I need to compare results with earlier release to see if this is new or old limitation.

Attached is short makefile and source. Only important thing is to keep optimisation options the same.

Can somebody help me out here? Ive got way too many versions of gcc live right now to deal with more. The comments explain the effects in 4.0.


3.3.1 or 3.3.5 plus 3.4.3 would be great.


Thanks!



makefile
========

OPT = s
MCU = atmega169
CC = avr-gcc

CFLAGS = -mmcu=$(MCU) -W Wall -v -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -O$(OPT)

.c.s:
   $(CC) $(CFLAGS) -c  -S $<

all:    testcase.s
clean:
   rm -f *.o
   rm -f testcase.s



testcase.c
==========
extern int foo(void);
volatile char  value;
/* Test ablity of gcc to optimise simple loops
* Expectations - all loops should reduce to simple decrement, test and branch
* Assembler code being
*
* Looptop:
* <body>
* sbiw Rx,1;
* brlt looptop (or similar)
*/

/* TESTCASE 1 the simple loop.
*
 * loop reversed (i=10....1) - OK
*/
void testloop1(void)
{
   int i;
   /*a simple loop thats ok*/
   for (i=0;i<10;i++)
   {
       foo();
   }
} /*TESTCASE 2 - add inner loop - directed at itself (neither forward nor backward)
*
* doloop - loop reversed  (i=9....0) OK
* decrement uses *addhi pattern with -1 as subtract - OK
* uses sbrs - not OK!
* Intention was for peephole (L 2347 avr.md) to combine subtract, test and branch (3 insn) * by finding compare NE 65535 after subtract. This pattern no longer applies.
* We now have GE 0 - which no longer matches!
* RTL ends up with "*sbrx_and_branchhi" pattern as equivalent x & 32768 sign test (2 insn)
* Hack - add ANOTHER peephole to use GE 0
* Better maybe - define decrement,test and jump insn and let combiner figure it out.
* Also - why is gcc inconsistent in loop reversal bounds????
* Need more info to design a robust fix!!
*/

void testloop2(void)
{
   int i;
   for (i=0;i<10;i++)
   {
       while (!value);
       foo();
   }
}
/* TESTCASE 3 add inner loop - forward jump 'while'
*
* doloop not reversed - not OK
* Cause is forward jump inside loop setting maybe_multiple flag that stops
* optimisation. Very poor the loop counter is never used, and there is no way it can * get set mutiple times regardless of jumps inside loop. Need to file bug report
*
* Loop increment using *addhi pattern OK
* Test and jump using compare OK
*/
void testloop3(void)
{
   int i;
   for (i=0;i<10;i++)
   {
       while (!value)
       {
       foo();
       }
   }
}
/* TESTCASE 4
*
* Same as above but with inner while loop
*
* Loop reversed (i=9.....0) - OK
* Same code pattern matching probelm as testcase 2
*/
void testloop4(void)
{
   int i;
   for (i=0;i<10;i++)
   {
       do
       {
           foo();
       } while (!value);
   }
}

/* TESTCASE 4
*
* Same as above but no inner loop - just 'if'
*
* Loop reversed - (i=10.....1) - OK
* Again why is gcc using 10...1 as opposed to 9....0.
*/
void testloop5(void)
{
   int i;
   for (i=0;i<10;i++)
   {
       if (!value)
       {
           foo();
       }
   }
}





reply via email to

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