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 rtl-optimization/17731] sub-optimal code generated for left shift


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Last reconfirmed|2006-01-16 06:19:32         |2011-05-22 17:27:32
         Resolution|                            |FIXED

--- Comment #8 from Steven Bosscher <steven at gcc dot gnu.org> 2011-05-22 15:30:58 UTC ---
(In reply to comment #2)
> Yes, that's fine.
> The java front end generates trees like <shift op <and op 31>>.
> I would like the extra "and" to be optimized out somewhere
> along the way, on a target-specific basis.

Fixed by tree-ssa::

$ cat t.c
int shift (int x, int y)
{
  int _y = y & 31;
  return x << _y;
}

$ ./cc1 -quiet -m32 -O2 t.c -fdump-tree-optimized
$ cat t.s 
    .file    "t.c"
    .text
    .p2align 4,,15
    .globl    shift
    .type    shift, @function
shift:
.LFB0:
    .cfi_startproc
    movl    4(%esp), %eax
    movl    8(%esp), %ecx
    sall    %cl, %eax
    ret
    .cfi_endproc
.LFE0:
    .size    shift, .-shift
    .ident    "GCC: (GNU) 4.6.0 20110312 (experimental) [trunk revision
170907]"
    .section    .note.GNU-stack,"",@progbits


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