public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/50131] New: Optimize x = -1 with "or" for -O
Date: Fri, 19 Aug 2011 20:58:00 -0000	[thread overview]
Message-ID: <bug-50131-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2011-08-19 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 20:58 hjl.tools at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-50131-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).