From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1165 invoked by alias); 21 Apr 2007 07:25:40 -0000 Received: (qmail 489 invoked by uid 48); 21 Apr 2007 07:25:27 -0000 Date: Sat, 21 Apr 2007 07:25:00 -0000 Subject: [Bug c/31644] New: Code snippet that fails to compile with optimization enabled X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dhylands at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-04/txt/msg01542.txt.bz2 The following code snippet fails to compile with -Os -O1 -O2 or -O3. It compiles fine using -O0 I tested both the Win32 and linux versions of the compiler and they both fail the same way. The exact command line used was: avr-gcc -c -mmcu=atmega168 -Os ee-fail.c Removing the second call to fill_pwm_table also allows the code to compile. The error message received from the compiler are as follows: ee-fail.c: In function 'build_pwm_table': /home/dhylands/avr-4.1.1/lib/gcc/avr/4.1.1/../../../../avr/include/avr/eeprom.h:208: error: can't find a register in class 'BASE_POINTER_REGS' while reloading 'asm' /home/dhylands/avr-4.1.1/lib/gcc/avr/4.1.1/../../../../avr/include/avr/eeprom.h:208: error: can't find a register in class 'BASE_POINTER_REGS' while reloading 'asm' avr-gcc -v on my linux box reports: Using built-in specs. Target: avr Configured with: ../../source/gcc-4.1.1/configure -v --target=avr --disable-nls --prefix=/home/dhylands/avr-4.1.1 --with-gnu-ld --with-gnu-as --enable-languages=c,c++ --quiet --disable-libssp --with-dwarf2 Thread model: single gcc version 4.1.1 #include uint8_t pwm_tab_1 [126]; static uint16_t ee_chan_1_min EEMEM = 140, ee_chan_1_cent EEMEM = 188, ee_chan_1_max EEMEM = 240, ee_chan_1_forw_min EEMEM = 20, ee_chan_1_forw_max EEMEM = 90, ee_chan_1_back_max EEMEM = 80; void fill_pwm_table (int8_t chan_num, uint8_t pwm [], int16_t forward_max, int16_t center, int16_t reverse_min, int16_t forward_high, int16_t forward_low, int16_t reverse_high ); void build_pwm_table (void) { int16_t center_1, forward_max_1, reverse_min_1, forward_high_1, forward_low_1, reverse_high_1; center_1 = eeprom_read_word (&ee_chan_1_cent); forward_max_1 = eeprom_read_word (&ee_chan_1_max); reverse_min_1 = eeprom_read_word (&ee_chan_1_min); forward_high_1 = eeprom_read_word (&ee_chan_1_forw_max); forward_low_1 = eeprom_read_word (&ee_chan_1_forw_min); reverse_high_1 = eeprom_read_word (&ee_chan_1_back_max); fill_pwm_table (1, pwm_tab_1, forward_max_1, center_1, reverse_min_1, forward_high_1, forward_low_1, reverse_high_1); fill_pwm_table (1, pwm_tab_1, forward_max_1, center_1, reverse_min_1, forward_high_1, forward_low_1, reverse_high_1); } -- Summary: Code snippet that fails to compile with optimization enabled Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dhylands at gmail dot com GCC host triplet: i686-pc-linux-gnu GCC target triplet: avr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31644