Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2002:
[Freeciv-Dev] Re: [RFC] Path finding implementation.
Home

[Freeciv-Dev] Re: [RFC] Path finding implementation.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Cc: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>, Freeciv Development List <freeciv-dev@xxxxxxxxxxx>, "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [RFC] Path finding implementation.
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Mon, 22 Jul 2002 21:07:41 +0200

On Mon, 22 Jul 2002, rf13@xxxxxxxxxxxxxxxxx wrote:
> On Mon, Jul 22, 2002 at 12:25:17AM +0200, Gaute B Strokkenes wrote:
>> On Sat, 29 Jun 2002, rf13@xxxxxxxxxxxxxxxxx wrote:
>> > On Fri, Jun 28, 2002 at 10:28:49PM +0100, Gregory Berkolaiko
>> > wrote:
>> >> Maybe my compiler does not optimize x % 128 to x | 127 ??
>> 
>> You mean "x & 127".
>> 
>> > gcc -S is your friend. But I'm sure that it does.
> 
>> Only if x is an unsigned type, remember.
> 
> $ cat a.c
> int f(int x) { return x%128;}
> $ gcc -O2 -S a.c
> $ cat a.s

$ cat a.c
int f(int x) { return x%128;}
$ gcc-3.0 -O2 -S a.c
$ cat b.c
int f(int x) { return ((unsigned) x)%128;}
$ gcc-3.0 -O2 -S b.c
$ diff -u a.s b.s
--- a.s Mon Jul 22 21:04:55 2002
+++ b.s Mon Jul 22 21:05:05 2002
@@ -1,4 +1,4 @@
-       .file   "a.c"
+       .file   "b.c"
        .text
        .align 4
 .globl f
@@ -7,18 +7,9 @@
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
-       testl   %eax, %eax
-       movl    %eax, %edx
-       js      .L3
-.L2:
-       andl    $-128, %edx
-       subl    %edx, %eax
+       andl    $127, %eax
        popl    %ebp
        ret
-       .p2align 2
-.L3:
-       leal    127(%eax), %edx
-       jmp     .L2
 .Lfe1:
        .size   f,.Lfe1-f
        .ident  "GCC: (GNU) 3.0.4"

> Please people try this before you say anything.

Boggle.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
Does that mean I'm not a well-adjusted person??


[Prev in Thread] Current Thread [Next in Thread]