[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os
From: |
Thomas D. Dean |
Subject: |
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os |
Date: |
Thu, 15 May 2008 12:30:04 -0700 (PDT) |
I changed the variables to volatile and that fixed things.
The compiler does not seem to move things around the
sin/cos/tan/asin/acos/atan functions, only the atan2.
I put the code segment below. I was looking into size/time for these
functions. I saw what I expected around all the functions except
atan2(). Is this because of two arguments???
BTW, I use standard includes and the code does use PORTA and _BV(),
just the comment was in lower case.
tomdean
double rad;
double sin_rad, cos_rad;
double atan_rad;
while (1) {
TRACE_ON(TRACE0);
start = timer_current();
rad = M_PI/4.0;
TRACE_ON(TRACE1);
sin_rad = sin(rad); // 214 usec
TRACE_OFF(TRACE1);
TRACE_ON(TRACE2);
dtostrf(rad,6,3,&line3[4]); // 85 usec
TRACE_OFF(TRACE2);
line3[10]=')';
dtostrf(sin_rad,6,3,&line3[14]);
TRACE_ON(TRACE3);
cos_rad = atan(sin_rad); // 220 usec
TRACE_OFF(TRACE3);
dtostrf(rad,6,3,&line4[4]);
line4[10]=')';
dtostrf(cos_rad,6,3,&line4[14]);
line3[20] = ' ';
line4[20] = ' ';
TRACE_ON(TRACE4); // porta |= _bv(04)
atan_rad = atan2(cos_rad,sin_rad);
TRACE_OFF(TRACE4); // porta &= ~_bv(04)
dtostrf(atan_rad,6,3,&line4[26]);
lcd_print(1,&line1[0]); // 1.6 msec
lcd_print(2,&line2[0]); // 1.6 msec
lcd_print(3,&line3[0]); // 1.6 msec
lcd_print(4,&line4[0]); // 1.6 msec
TRACE_OFF(TRACE0);
}
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, (continued)