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

           Summary: AVR: Redundant comparisons in binary-seach switch/case
                    expansion
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: g...@gcc.gnu.org
                CC: eric.wedding...@atmel.com
            Target: avr


Created attachment 24864
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24864
cswitch.c: C test case

avr-gcc emits redundant comparisons like these:

cpi r24,lo8(55)     ;  22    *cmpqi/3    [length = 1]
breq .L10     ;  23    branch    [length = 1]
cpi r24,lo8(56)     ;  24    *cmpqi/3    [length = 1]
brge .L19     ;  25    branch    [length = 1]

which could just as well be

cpi r24,lo8(55)     ;  22    *cmpqi/3    [length = 1]
breq .L10     ;  23    branch    [length = 1]
brge .L19     ;  25    branch    [length = 1]

or these:

cpi r24,lo8(100)     ;  61    *cmpqi/3    [length = 1]
breq .L16     ;  62    branch    [length = 1]
cpi r24,lo8(100)     ;  63    *cmpqi/3    [length = 1]
brlt .L15     ;  64    branch    [length = 1]

which could just as well be

cpi r24,lo8(100)     ;  61    *cmpqi/3    [length = 1]
breq .L16     ;  62    branch    [length = 1]
brlt .L15     ;  64    branch    [length = 1]

This concernes signed/unsigned comparisons for QI/HI/SI

-- command line ----------------------------------------------

avr-gcc cswitch.c -dp -S -Os

-- configure -------------------------------------------------

../../gcc.gnu.org/trunk/configure --target=avr
--prefix=/home/john/gnu/install/gcc-4.7 --disable-nls --disable-shared
--enable-languages=c,c++ --with-dwarf2 --disable-lto

-- GCC  -------------------------------------------------

as of 4.7.0 trunk, r176818 from 2011-07-27

Reply via email to