This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/17151] New: x >> (y % WORDSIZE) not optimized


gcc 3.5-tree-ssa-lno 20040823 (merged 20040718)

gcc doesn't optimize shift count modulo word size, but curiously it does when
adding one more bit:

unsigned long f(unsigned long x, unsigned long y) { return x >> (y % 64); }
unsigned long g(unsigned long x, unsigned long y) { return x >> (y % 128); }

f:
        and $17,63,$17
        srl $16,$17,$0
        ret

g:
        srl $16,$17,$0
        ret

It seems this is not a regression, already 2.95 behaved like this.

-- 
           Summary: x >> (y % WORDSIZE) not optimized
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: minor
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: falk at debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: alphaev68-unknown-linux-gnu
  GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]