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

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

RE: [avr-gcc-list] wrong code from avr-gcc 4.1.2?


From: John Regehr
Subject: RE: [avr-gcc-list] wrong code from avr-gcc 4.1.2?
Date: Sun, 1 Jun 2008 21:50:11 -0600 (MDT)

Hi Eric-

I'm using Kevin Klues' avr-gcc debs for TinyOS. I expect that he built a patched version but I'll check with him to make sure.

I understand that it may be difficult to find resources to fix a version other than the latest one. Another possible outcome is that this sort of thing will motivate TinyOS to switch to a new compiler version. Of course there are issues with that too...

Compiler output follows. It is not very informative since that function is nearly optimized away.

John



address@hidden:~$ avr-gcc -Os -fwrapv -S small.c -o -
        .file   "small.c"
        .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
        .global __do_copy_data
        .global __do_clear_bss
        .text
.global func_1
        .type   func_1, @function
func_1:
/* prologue: frame size=0 */
/* prologue end (size=0) */
        ldi r24,lo8(1)
        ldi r25,hi8(1)
/* epilogue: frame size=0 */
        ret
/* epilogue end (size=1) */
/* function func_1 size 3 (2) */
        .size   func_1, .-func_1
        .comm g_66,4,1
        .comm g_73,4,1
/* File "small.c": code 3 = 0x0003 ( 2), prologues 0, epilogues 1 */




On Sun, 1 Jun 2008, Weddington, Eric wrote:

Hi Dr. John,

Are you using a particular WinAVR version? i.e. a patched avr-gcc 4.1.2?
Or is this stock FSF 4.1.2?

Can you post the compiler output?

Sorry, but most of the developers are dealing with HEAD/4.4 or maybe
4.3.0. I understand that you're using 4.1.2 for TinyOS.

Eric

-----Original Message-----
From:
address@hidden
[mailto:address@hidden
org] On Behalf Of John Regehr
Sent: Sunday, June 01, 2008 9:14 PM
To: address@hidden
Subject: [avr-gcc-list] wrong code from avr-gcc 4.1.2?

In the code below, avr-gcc 4.1.2 wants to return 1 from func_1() when
compiling at -Os.  Specifically I'm compiling like this:

   avr-gcc -fwrapv -Os -mmcu=atmega128 foo.c

I believe the correct answer is 0 (this is what avr-gcc-4.2.2
returns at
all optimization levels).  I don't think the -fwrapv is relevant here
but include it to be on the safe side.

John Regehr



static inline unsigned long int
div_rhs(const long int rhs)
{
     if (rhs == 0) return 1;
     return rhs;
}

unsigned long g_66;
long g_73;

int func_1 (void)
{
   unsigned long l_86 = -1L;
   unsigned long l_93 = -9L;
   if ((l_86 >= g_73) < (1 / div_rhs (l_93)))
     return 1;
   else
     return 0;
}




_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list






reply via email to

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