public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/50131] New: Optimize x = -1 with "or" for -O
@ 2011-08-19 20:58 hjl.tools at gmail dot com
  2011-08-19 21:19 ` [Bug target/50131] " hjl.tools at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2011-08-19 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50131
           Summary: Optimize x = -1 with "or" for -O
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hjl.tools@gmail.com
                CC: ubizjak@gmail.com


[hjl@gnu-6 rtm-1]$ cat x.c
int
foo1 ()
{
  return -1;
}

short
foo2 ()
{
  return -1;
}

long long
foo3 ()
{
  return -1;
}
[hjl@gnu-6 rtm-1]$ gcc -S -Os x.c 
[hjl@gnu-6 rtm-1]$ cat x.s
    .file    "x.c"
    .text
    .globl    foo1
    .type    foo1, @function
foo1:
.LFB0:
    .cfi_startproc
    orl    $-1, %eax
    ret
    .cfi_endproc
.LFE0:
    .size    foo1, .-foo1
    .globl    foo2
    .type    foo2, @function
foo2:
.LFB1:
    .cfi_startproc
    orl    $-1, %eax
    ret
    .cfi_endproc
.LFE1:
    .size    foo2, .-foo2
    .globl    foo3
    .type    foo3, @function
foo3:
.LFB2:
    .cfi_startproc
    orq    $-1, %rax
    ret
    .cfi_endproc
.LFE2:
    .size    foo3, .-foo3
    .ident    "GCC: (GNU) 4.6.0 20110603 (Red Hat 4.6.0-10)"
    .section    .note.GNU-stack,"",@progbits
[hjl@gnu-6 rtm-1]$ gcc -S -O2 x.c 
[hjl@gnu-6 rtm-1]$ cat x.s
    .file    "x.c"
    .text
    .p2align 4,,15
    .globl    foo1
    .type    foo1, @function
foo1:
.LFB0:
    .cfi_startproc
    movl    $-1, %eax
    ret
    .cfi_endproc
.LFE0:
    .size    foo1, .-foo1
    .p2align 4,,15
    .globl    foo2
    .type    foo2, @function
foo2:
.LFB1:
    .cfi_startproc
    movl    $-1, %eax
    ret
    .cfi_endproc
.LFE1:
    .size    foo2, .-foo2
    .p2align 4,,15
    .globl    foo3
    .type    foo3, @function
foo3:
.LFB2:
    .cfi_startproc
    movq    $-1, %rax
    ret
    .cfi_endproc
.LFE2:
    .size    foo3, .-foo3
    .ident    "GCC: (GNU) 4.6.0 20110603 (Red Hat 4.6.0-10)"
    .section    .note.GNU-stack,"",@progbits
[hjl@gnu-6 rtm-1]$ 

I was expecting "or" for -O.


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

end of thread, other threads:[~2021-12-15  1:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19 20:58 [Bug target/50131] New: Optimize x = -1 with "or" for -O hjl.tools at gmail dot com
2011-08-19 21:19 ` [Bug target/50131] " hjl.tools at gmail dot com
2011-08-20  8:37 ` jakub at gcc dot gnu.org
2011-08-20 20:04 ` hjl.tools at gmail dot com
2011-08-21  9:20 ` rguenth at gcc dot gnu.org
2011-08-23 14:57 ` hjl.tools at gmail dot com
2021-12-15  1:34 ` pinskia 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).