Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: Dave Korn <dave.korn@artimi.com>
Cc: gdb@sourceware.org
Subject: Re: (len % 1) != 0
Date: Tue, 19 Feb 2008 18:47:00 -0000	[thread overview]
Message-ID: <47BB2168.7090600@avtrex.com> (raw)
In-Reply-To: <008001c87325$6db805e0$2e08a8c0@CAM.ARTIMI.COM>

Dave Korn wrote:
> On 19 February 2008 18:23, Paul Koning wrote:
> 
>>>>>>> "Dave" == Dave Korn <dave.korn@artimi.com> 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 <f1>:
    0:   03e00008        jr      ra
    4:   30820001        andi    v0,a0,0x1


  reply	other threads:[~2008-02-19 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-17  5:57 Bin Chen
2008-02-17 14:13 ` Eli Zaretskii
2008-02-17 14:41   ` Bin Chen
2008-02-17 15:26     ` Daniel Jacobowitz
2008-02-19 16:32       ` Sheng-Liang Song
2008-02-19 18:25         ` Dave Korn
2008-02-19 18:30           ` David Daney
     [not found]           ` <18363.7810.91075.314867@gargle.gargle.HOWL>
2008-02-19 18:35             ` Dave Korn
2008-02-19 18:47               ` David Daney [this message]
2008-02-19 18:49                 ` Daniel Jacobowitz
2008-02-19 19:08                 ` Dave Korn
2008-02-19 21:41           ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47BB2168.7090600@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=dave.korn@artimi.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox