From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7186 invoked by alias); 19 Aug 2011 20:23:24 -0000 Received: (qmail 7178 invoked by uid 22791); 19 Aug 2011 20:23:23 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_OV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Aug 2011 20:23:10 +0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01695.txt.bz2 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.