public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49857] New: Put constant switch-tables into flash
@ 2011-07-26 20:50 gjl at gcc dot gnu.org
  2011-07-26 20:57 ` [Bug target/49857] " eric.weddington at atmel dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-26 20:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

           Summary: Put constant switch-tables into flash
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gjl@gcc.gnu.org
                CC: eric.weddington@atmel.com
            Target: avr


Created attachment 24837
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24837
C source with constant switch statement

For constant switches like

int sw_2 (char x)
{
    switch(x) 
    { 
        case '0': return -1;
        case '1': return  2;
        case '2': return  3;
        case '3': return  5;
        case '4': return  7;
        case '5': return 11;
        case '6': return 13;
        case '7': return 17;
        case '8': return 19;
        case '9': return 23;
        case 'a':return 29;
        case 'A':return 29;
    }

    return -1;
}

avr-gcc 4.6.1 generates a lookup table (-Os -mmcu=atmega8 -S -fverbose-asm)

sw_2:
    subi r24,lo8(-(-49))     ;  csui.0,
    cpi r24,lo8(49)     ;  csui.0,
    brsh .L3     ; ,
    mov r30,r24     ;  tmp50, csui.0
    ldi r31,lo8(0)     ; ,
    subi r30,lo8(-(CSWTCH.1))     ;  tmp50,
    sbci r31,hi8(-(CSWTCH.1))     ;  tmp50,
    ld r24,Z     ;  tmp51, CSWTCH.1
    clr r25     ;  D.1929
    sbrc r24,7     ;  D.1929
    com r25     ;  D.1929
    ret
.L3:
    ldi r24,lo8(-1)     ;  D.1929,
    ldi r25,hi8(-1)     ;  D.1929,
    ret
    .size    sw_2, .-sw_2
    .data
    .type    CSWTCH.1, @object
    .size    CSWTCH.1, 49
CSWTCH.1:
    .byte    2
    .byte    3
    .byte    5
    .byte    7
    .byte    11
    .byte    13
    .byte    17
    .byte    19
    .byte    23
    .byte    -1
    .byte    -1
    .byte    -1
...

CSWTCH.1 is put in .data (.rodata would not be better) so that the lookup table
ends up in RAM.  

The table is constant and could go into flash memory, i.e. .progmem.data.

===================================

avr-gcc -v -Os -fverbose-asm -mmcu=atmega8 -W -Wall -S foo.c # dp
-mmcu=atmega128 foo.c -save-temps -Os -c
Using built-in specs.
COLLECT_GCC=e:\WinAVR\4.6.1\bin\avr-gcc.exe
COLLECT_LTO_WRAPPER=e:/winavr/4.6.1/bin/../libexec/gcc/avr/4.6.1/lto-wrapper.exe
Target: avr
Configured with: ../../gcc.gnu.org/gcc-4_6-branch/configure --target=avr
--prefix=/local/gnu/install/gcc-4.6-mingw32 --host=i586-mingw32
--build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared
--with-dwarf2
Thread model: single
gcc version 4.6.1 20110620 (prerelease) (GCC) 

GNU C (GCC) version 4.6.1 20110620 (prerelease) (avr)
    compiled by GNU C version 3.3.1 (mingw special 20030804-1), GMP version
4.3.2, MPFR version 2.4.2, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32702


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
@ 2011-07-26 20:57 ` eric.weddington at atmel dot com
  2011-12-01 12:49 ` eric.weddington at atmel dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: eric.weddington at atmel dot com @ 2011-07-26 20:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Eric Weddington <eric.weddington at atmel dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
  2011-07-26 20:57 ` [Bug target/49857] " eric.weddington at atmel dot com
@ 2011-12-01 12:49 ` eric.weddington at atmel dot com
  2012-01-07 12:23 ` gjl at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: eric.weddington at atmel dot com @ 2011-12-01 12:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Eric Weddington <eric.weddington at atmel dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|2011-07-27 00:00:00         |2011-12-01
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
  2011-07-26 20:57 ` [Bug target/49857] " eric.weddington at atmel dot com
  2011-12-01 12:49 ` eric.weddington at atmel dot com
@ 2012-01-07 12:23 ` gjl at gcc dot gnu.org
  2012-01-29 16:24 ` [Bug tree-optimization/49857] " gjl at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: gjl at gcc dot gnu.org @ 2012-01-07 12:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |addr-space
   Target Milestone|---                         |4.8.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug tree-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-01-07 12:23 ` gjl at gcc dot gnu.org
@ 2012-01-29 16:24 ` gjl at gcc dot gnu.org
  2012-01-29 17:42 ` [Bug rtl-optimization/49857] " steven at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: gjl at gcc dot gnu.org @ 2012-01-29 16:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |tree-optimization

--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2012-01-29 14:55:48 UTC ---
Changed component from "target" to "tree-optimization" because:

The code in tree-switch-conversion.c needs to be extended by, say, a target
hook that queries the backend for the right address space for the generated
lookup table, i.e. the CSWTCH.num objects.

This is needed for two reasons:

1) The data (CSWTCH.num) has to be located in the preferred section,
   i.e. in Flash and not in RAM.

2) The accesses have to use the right instructions, i.e. instructions to read
from non-generic address space (Flash) and not instructions to access generic
address space (RAM).


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-01-29 16:24 ` [Bug tree-optimization/49857] " gjl at gcc dot gnu.org
@ 2012-01-29 17:42 ` steven at gcc dot gnu.org
  2012-01-29 18:32 ` steven at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu.org @ 2012-01-29 17:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steven at gcc dot gnu.org
          Component|tree-optimization           |rtl-optimization

--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> 2012-01-29 17:24:32 UTC ---
Jump tables are generated in stmt.c, as part of expanding to RTL.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-01-29 17:42 ` [Bug rtl-optimization/49857] " steven at gcc dot gnu.org
@ 2012-01-29 18:32 ` steven at gcc dot gnu.org
  2013-03-22 14:45 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu.org @ 2012-01-29 18:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|steven at gcc dot gnu.org   |

--- Comment #3 from Steven Bosscher <steven at gcc dot gnu.org> 2012-01-29 17:51:04 UTC ---
An, no, tree-switch-conversion.c:build_one_array() must build its value_type
for elements with a specified address space.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-01-29 18:32 ` steven at gcc dot gnu.org
@ 2013-03-22 14:45 ` jakub at gcc dot gnu.org
  2013-05-31 10:59 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-22 14:45 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.0                       |4.8.1

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-22 14:44:30 UTC ---
GCC 4.8.0 is being released, adjusting target milestone.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-03-22 14:45 ` jakub at gcc dot gnu.org
@ 2013-05-31 10:59 ` jakub at gcc dot gnu.org
  2013-06-01 13:41 ` gjl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-31 10:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.1                       |4.8.2

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.1 has been released.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2013-05-31 10:59 ` jakub at gcc dot gnu.org
@ 2013-06-01 13:41 ` gjl at gcc dot gnu.org
  2014-04-22 11:37 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-06-01 13:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.2                       |4.9.0

--- Comment #6 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Bumped the milestone to 4.9


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2013-06-01 13:41 ` gjl at gcc dot gnu.org
@ 2014-04-22 11:37 ` jakub at gcc dot gnu.org
  2014-04-22 14:30 ` gjl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-22 11:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.0                       |4.9.1

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.0 has been released


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2014-04-22 11:37 ` jakub at gcc dot gnu.org
@ 2014-04-22 14:30 ` gjl at gcc dot gnu.org
  2015-04-22 12:06 ` jakub at gcc dot gnu.org
  2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: gjl at gcc dot gnu.org @ 2014-04-22 14:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Target Milestone|4.9.1                       |4.10.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2014-04-22 14:30 ` gjl at gcc dot gnu.org
@ 2015-04-22 12:06 ` jakub at gcc dot gnu.org
  2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 12:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.0                         |5.2

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug rtl-optimization/49857] Put constant switch-tables into flash
  2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2015-04-22 12:06 ` jakub at gcc dot gnu.org
@ 2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-07-16  9:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 20:50 [Bug target/49857] New: Put constant switch-tables into flash gjl at gcc dot gnu.org
2011-07-26 20:57 ` [Bug target/49857] " eric.weddington at atmel dot com
2011-12-01 12:49 ` eric.weddington at atmel dot com
2012-01-07 12:23 ` gjl at gcc dot gnu.org
2012-01-29 16:24 ` [Bug tree-optimization/49857] " gjl at gcc dot gnu.org
2012-01-29 17:42 ` [Bug rtl-optimization/49857] " steven at gcc dot gnu.org
2012-01-29 18:32 ` steven at gcc dot gnu.org
2013-03-22 14:45 ` jakub at gcc dot gnu.org
2013-05-31 10:59 ` jakub at gcc dot gnu.org
2013-06-01 13:41 ` gjl at gcc dot gnu.org
2014-04-22 11:37 ` jakub at gcc dot gnu.org
2014-04-22 14:30 ` gjl at gcc dot gnu.org
2015-04-22 12:06 ` jakub at gcc dot gnu.org
2015-07-16  9:18 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).