From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18759 invoked by alias); 25 Jan 2013 17:12:54 -0000 Received: (qmail 18635 invoked by uid 48); 25 Jan 2013 17:12:26 -0000 From: "tilman@code-monkey.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND Date: Fri, 25 Jan 2013 17:12: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: tilman@code-monkey.de 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: 2013-01/txt/msg02380.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110 Bug #: 56110 Summary: Sub-optimal code: unnecessary CMP after AND Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: tilman@code-monkey.de Target: arm Compiling this code unsigned f1 (unsigned x, unsigned m) { if (m & 0x008080) x >>= 8; return x; } with gcc 4.7.2 gives this code for ARMv5: $ armv5tel-softfloat-linux-gnueabi-gcc -O2 -S -o- f1.c [...] ldr r3, .L6 and r3, r1, r3 @ XXX cmp r3, #0 @ XXX movne r0, r0, lsr #8 bx lr [...] AFAICS we could get rid of the CMP if we used ANDS instead of AND: ldr r3, .L6 ands r3, r1, r3 movne r0, r0, lsr #8 bx lr