From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20550 invoked by alias); 19 Feb 2008 18:35:49 -0000 Received: (qmail 20541 invoked by uid 22791); 19 Feb 2008 18:35:48 -0000 X-Spam-Check-By: sourceware.org Received: from smtp1.dnsmadeeasy.com (HELO smtp1.dnsmadeeasy.com) (205.234.170.144) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Feb 2008 18:35:24 +0000 Received: from smtp1.dnsmadeeasy.com (localhost [127.0.0.1]) by smtp1.dnsmadeeasy.com (Postfix) with ESMTP id 4C824314887; Tue, 19 Feb 2008 18:35:35 +0000 (UTC) X-Authenticated-Name: js.dnsmadeeasy X-Transit-System: In case of SPAM please contact abuse@dnsmadeeasy.com Received: from avtrex.com (unknown [67.116.42.147]) by smtp1.dnsmadeeasy.com (Postfix) with ESMTP; Tue, 19 Feb 2008 18:35:35 +0000 (UTC) Received: from dl2.hq2.avtrex.com ([192.168.7.26]) by avtrex.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 19 Feb 2008 10:35:21 -0800 Message-ID: <47BB2168.7090600@avtrex.com> Date: Tue, 19 Feb 2008 18:47:00 -0000 From: David Daney User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Dave Korn Cc: gdb@sourceware.org Subject: Re: (len % 1) != 0 References: <5800c1cc0802162157g3ac31acas4ae95585b9b2e263@mail.gmail.com><5800c1cc0802170641g68ab2e5fte724cd076412333@mail.gmail.com><20080217152625.GA4810@caradoc.them.org><47BB03ED.5060708@baymicrosystems.com><007f01c87324$00f45a90$2e08a8c0@CAM.ARTIMI.COM> <18363.7810.91075.314867@gargle.gargle.HOWL> <008001c87325$6db805e0$2e08a8c0@CAM.ARTIMI.COM> In-Reply-To: <008001c87325$6db805e0$2e08a8c0@CAM.ARTIMI.COM> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00136.txt.bz2 Dave Korn wrote: > On 19 February 2008 18:23, Paul Koning wrote: > >>>>>>> "Dave" == Dave Korn writes: >> Dave> On 19 February 2008 16:30, Sheng-Liang Song wrote: >> >> or >> >> >> >> (len & 1) != 0 <=> (len % 2) != 0 >> >> >> >> Dave> That would have the advantage of not requiring a divide >> Dave> operation :) >> >> It shouldn't matter -- the optimizer will do the right thing, as I >> recall. > > NB len == signed int. > > Yes, it can simplify it to a bunch of shifts and sign extends and masks > without using an explicit divide, but it's not as good as a simple AND > operation. (Maybe VRP in 4.x could handle that by knowing that the result of > strlen has to be >= 0, but 3.x series won't do it). > ?? Not to be pedantic, but on 3.4.3 for mipsel-linux I get: $ cat j.c int f1 (int a) { return (a % 2) != 0; } $ mipsel-linux-gcc -c -O3 j.c $ mipsel-linux-objdump -d j.o j.o: file format elf32-tradlittlemips Disassembly of section .text: 00000000 : 0: 03e00008 jr ra 4: 30820001 andi v0,a0,0x1