From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6959 invoked by alias); 22 Nov 2011 23:11:29 -0000 Received: (qmail 6949 invoked by uid 22791); 22 Nov 2011 23:11:28 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_SR,TW_TL 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; Tue, 22 Nov 2011 23:11:12 +0000 From: "meissner at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/51274] New: Starting with GCC 4.5, powerpc generated different code for x != 0. Date: Tue, 22 Nov 2011 23:42: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: minor X-Bugzilla-Who: meissner at gcc dot gnu.org 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-11/txt/msg02268.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51274 Bug #: 51274 Summary: Starting with GCC 4.5, powerpc generated different code for x != 0. Classification: Unclassified Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: meissner@gcc.gnu.org Host: powerpc64-linux power-linux Target: powerpc64-linux Build: powerpc64-linux In doing some investigation for optimizations of comparisons for power7, I noticed that starting with GCC 4.5, the compiler no longer generates the code it used to for setting x = (y != 0). In the rs6000.md file, these optimizations start with the insn "ne0si". In the 4.4 time frame, for -m32 (and for -m32 -mpowerpc64, which is PR 36557), gcc would generate: addic 9,3,-1 subfe 0,9,3 However, it wouldn't generate this code for -m64. Starting with 4.5, it generates the code for !(x == 0), or: cntlzw 3,3 srwi 3,3,5 xori 3,3,1 We should either remove the insns in rs6000.md that no longer are matching, or fix them so they do match. I suspect that the longer code sequence is actually faster on the newer processors, since you don't need to track the carry between the two insns.