From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13851 invoked by alias); 26 May 2003 13:53:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 13774 invoked by uid 48); 26 May 2003 13:53:11 -0000 Date: Mon, 26 May 2003 13:58:00 -0000 From: "pb@gcc.gnu.org" To: gcc-bugs@gcc.gnu.org Message-ID: <20030526135310.10982.pb@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" X-Bugzilla-Reason: CC X-SW-Source: 2003-05/txt/msg02851.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982 Summary: [arm] poor optimisation of "if (var & const)" Product: gcc Version: unknown Status: NEW Severity: enhancement Priority: P2 Component: optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: pb@gcc.gnu.org CC: gcc-bugs@gcc.gnu.org GCC target triplet: arm-linux Compiling this code: f(int a) { if (a & 0xfff) return 1; return 0; } with -O2 yields: mov r0, r0, asl #20 mov r0, r0, lsr #20 cmp r0, #0 movne r0, #1 moveq r0, #0 There's no need to fully calculate the value of the AND, since all that we care about is whether it's zero or not. So, I think the first three instructions could be replaced by a single one: movs r0, r0, asl #20 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.